/*
  Modal Component Styles
  Professional modal design for newsletter subscription
*/

/* Modal Overlay */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--vh, 1vh) * 100); /* Use custom viewport height for mobile */
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

/* Modal Content */
.modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  z-index: 1001;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--fg);
}

.modal-close {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 50%;
  color: #dc2626 !important; /* Red by default for clear affordance */
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--surface);
  color: #b91c1c !important; /* Darker red on hover */
  transform: scale(1.1);
}

/* Modal Body */
.modal-body {
  padding: 2rem;
  text-align: center;
}

.modal-icon {
  width: 80px;
  height: 80px;
  background: var(--primary-50);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  color: var(--primary);
}

.modal-body h3 {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0 0 1rem;
  color: var(--fg);
}

.modal-body p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 2rem;
  font-size: 1rem;
}

/* Modal Newsletter Form */
.modal-newsletter-form {
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.modal-newsletter-form input {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s ease;
  background: white;
}

.modal-newsletter-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}

.modal-newsletter-form .btn {
  width: 100%;
  justify-content: center;
  gap: 0.5rem;
}

/* Newsletter Status in Modal */
.modal-body .newsletter-status {
  margin: 1.5rem 0;
  padding: 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.modal-body .newsletter-status.loading {
  background: var(--primary-50);
  color: var(--primary);
  border: 1px solid var(--primary);
}

.modal-body .newsletter-status.success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #22c55e;
}

.modal-body .newsletter-status.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #ef4444;
}

.newsletter-status .status-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.newsletter-status .status-icon svg {
  animation: spin 1s linear infinite;
}

.newsletter-status.success .status-icon svg,
.newsletter-status.error .status-icon svg {
  animation: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Modal Footer */
.modal-footer {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.modal-disclaimer {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
}

.modal-actions .btn {
  font-size: 0.875rem;
}

/* Responsive Design */

/* Large Desktop (1200px+) */
@media (min-width: 1200px) {
  .modal-content {
    max-width: 600px;
  }
  
  .modal-header {
    padding: 2.5rem 2.5rem 1.5rem;
  }
  
  .modal-body {
    padding: 2.5rem;
  }
  
  .modal-header h2 {
    font-size: 1.75rem;
  }
  
  .modal-body h3 {
    font-size: 1.5rem;
  }
  
  .modal-icon {
    width: 96px;
    height: 96px;
  }
}

/* Tablet (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .modal {
    padding: 1rem;
  }
  
  .modal-content {
    max-width: 520px;
    max-height: 85vh;
  }
  
  .modal-header {
    padding: 2rem 2rem 1.25rem;
  }
  
  .modal-body {
    padding: 2rem;
  }
  
  .modal-header h2 {
    font-size: 1.5rem;
  }
  
  .modal-body h3 {
    font-size: 1.375rem;
  }
  
  .modal-icon {
    width: 80px;
    height: 80px;
  }
  
  .modal-newsletter-form input {
    padding: 1.125rem 1.25rem;
    font-size: 1rem;
  }
  
  .modal-newsletter-form .btn {
    padding: 1.125rem 1.5rem;
    font-size: 1rem;
  }
}

/* Mobile Large (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
  .modal {
    padding: 0.75rem;
  }
  
  .modal-content {
    max-height: 90vh;
    border-radius: var(--radius);
  }
  
  .modal-header {
    padding: 1.75rem 1.75rem 1rem;
  }
  
  .modal-body {
    padding: 1.75rem;
  }
  
  .modal-header h2 {
    font-size: 1.375rem;
  }
  
  .modal-body h3 {
    font-size: 1.25rem;
  }
  
  .modal-body p {
    font-size: 0.95rem;
    line-height: 1.5;
  }
  
  .modal-icon {
    width: 72px;
    height: 72px;
    margin-bottom: 1.25rem;
  }
  
  .modal-newsletter-form input {
    padding: 1rem 1.125rem;
    font-size: 1rem;
  }
  
  .modal-newsletter-form .btn {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    min-height: 48px; /* Better touch target */
  }
}

/* Mobile Small (320px - 480px) */
@media (max-width: 480px) {
  .modal {
    padding: 0.5rem;
    align-items: flex-start;
    padding-top: 2rem;
  }
  
  .modal-content {
    max-height: 95vh;
    border-radius: var(--radius);
    width: calc(100% - 1rem);
    margin: 0 auto;
  }
  
  .modal-header {
    padding: 1.5rem 1.5rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .modal-body {
    padding: 1.5rem;
  }
  
  .modal-header h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
  }
  
  .modal-close {
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
  
  .modal-body h3 {
    font-size: 1.125rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
  }
  
  .modal-body p {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1.5rem;
  }
  
  .modal-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
  }
  
  .form-group {
    margin-bottom: 1.25rem;
  }
  
  .modal-newsletter-form input {
    padding: 0.875rem 1rem;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 48px;
    border-radius: var(--radius);
  }
  
  .modal-newsletter-form .btn {
    padding: 0.875rem 1rem;
    font-size: 1rem;
    min-height: 48px;
    border-radius: var(--radius);
  }
  
  .modal-footer {
    padding-top: 1.25rem;
  }
  
  .modal-disclaimer {
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
  }
  
  .modal-actions .btn {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    min-height: 44px;
  }
  
  .modal-body .newsletter-status {
    margin: 1.25rem 0;
    padding: 0.875rem;
    font-size: 0.8rem;
  }
}

/* Extra Small Mobile (320px and below) */
@media (max-width: 320px) {
  .modal {
    padding: 0.25rem;
    padding-top: 1rem;
  }
  
  .modal-content {
    width: calc(100% - 0.5rem);
    max-height: 98vh;
  }
  
  .modal-header {
    padding: 1.25rem 1.25rem 0.75rem;
  }
  
  .modal-body {
    padding: 1.25rem;
  }
  
  .modal-header h2 {
    font-size: 1.125rem;
  }
  
  .modal-body h3 {
    font-size: 1rem;
  }
  
  .modal-body p {
    font-size: 0.85rem;
  }
  
  .modal-icon {
    width: 56px;
    height: 56px;
  }
  
  .modal-newsletter-form input {
    padding: 0.75rem 0.875rem;
  }
  
  .modal-newsletter-form .btn {
    padding: 0.75rem 0.875rem;
  }
}

/* Landscape Mobile Orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .modal {
    align-items: flex-start;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .modal-content {
    max-height: 95vh;
    overflow-y: auto;
  }
  
  .modal-header {
    padding: 1rem 1.5rem 0.75rem;
  }
  
  .modal-body {
    padding: 1rem 1.5rem 1.5rem;
  }
  
  .modal-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
  }
  
  .modal-body h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }
  
  .modal-body p {
    font-size: 0.875rem;
    margin-bottom: 1rem;
  }
  
  .form-group {
    margin-bottom: 1rem;
  }
  
  .modal-footer {
    padding-top: 1rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal-content,
  .modal-close {
    transition: none;
  }
  
  .modal.active .modal-content {
    transform: none;
  }
  
  .newsletter-status .status-icon svg {
    animation: none;
  }
}

/* Focus styles */
.modal-close:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .modal-content {
    border: 2px solid currentColor;
  }
  
  .modal-icon {
    border: 2px solid var(--primary);
  }
}
