/* Newsletter Signup Component */
.contact-newsletter {
  background: var(--color-white);
  border-left-color: var(--color-blue);
  position: relative;
  overflow: hidden;
  grid-column: 1 / -1; /* Span all columns */
  max-width: 900px; /* Three times the typical width */
  margin: 0 auto; /* Center horizontally */
  justify-self: center; /* Center within grid */
}

.newsletter-form-type {
  margin-top: auto;
  position: relative;
  z-index: 1;
}

.newsletter-input-wrapper {
  display: flex;
  gap: 0;
  border: 2px solid var(--color-black);
  background: var(--color-white);
  transition: all var(--transition-base);
  position: relative;
}

.newsletter-input-wrapper:focus-within {
  box-shadow: 0 0 0 3px var(--shadow-color-light);
  transform: translateY(-2px);
}

.newsletter-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-code);
  font-size: var(--font-size-sm);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}

.newsletter-input:focus {
  outline: none;
  border-color: transparent;
}

.newsletter-input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.newsletter-submit {
  position: relative;
  border: none;
  border-left: 2px solid var(--color-blue);
  padding: var(--space-md) var(--space-lg);
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: var(--color-blue);
  color: var(--color-white);
  cursor: pointer;
  transition: all var(--transition-base);
}

.newsletter-submit:disabled,
.form-button-type.newsletter-submit:disabled {
  background: var(--color-border-medium) !important;
  border-left-color: var(--color-border-medium) !important;
  color: var(--color-text-disabled, var(--color-black)) !important;  /* Semantic disabled text color with fallback */
  cursor: not-allowed !important;
  opacity: 1 !important;  /* Full opacity for better readability */
}

.newsletter-submit .button-icon {
  font-size: var(--font-size-lg);
}

/* Override all hover effects for newsletter submit button */
.newsletter-submit:hover {
  background: var(--color-blue) !important;
  transform: none !important;
  border-color: var(--color-blue) !important;
  color: var(--color-white) !important;
}

.newsletter-submit:disabled:hover,
.form-button-type.newsletter-submit:disabled:hover {
  background: var(--color-border-medium) !important;
  transform: none !important;
  border-left-color: var(--color-border-medium) !important;
  color: var(--color-text-disabled, var(--color-black)) !important;  /* Maintain semantic disabled text color on hover */
}

.newsletter-submit:hover::before {
  left: -100% !important; /* Hide any sliding background animations */
}

/* Consent Checkbox */
.newsletter-consent {
  margin-top: var(--space-md);
}

.newsletter-consent .checkbox-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* Error States */
.newsletter-input[aria-invalid="true"] {
  color: var(--color-error);
}

.newsletter-input-wrapper.error {
  border-color: var(--color-error);
}

.error-message:not(:empty) {
  display: block;
  margin-top: var(--space-xs);
  font-family: var(--font-sans);
  animation: slideDown var(--transition-base) ease-out;
}

/* Success State */
.newsletter-success {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-background-secondary);
  border: 1px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.newsletter-success[aria-hidden="false"] {
  display: flex;
  animation: fadeIn var(--transition-slow) ease-out;
}

.newsletter-success .success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  color: var(--color-white);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: bold;
}

/* Loading State */
.newsletter-submit[aria-busy="true"] {
  pointer-events: none;
  opacity: 0.7;
}

.newsletter-submit[aria-busy="true"] .button-text {
  opacity: 0;
}

.newsletter-submit[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-white);
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
  .newsletter-input-wrapper {
    flex-direction: column;
  }

  .newsletter-submit {
    border-left: none;
    border-top: 2px solid var(--color-black);
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }

  .newsletter-submit:disabled {
    border-top-color: var(--color-border-medium);
  }

  .newsletter-input {
    text-align: center;
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 48px;
  }

  .newsletter-consent .checkbox-label {
    font-size: var(--font-size-xs);
  }
}

/* Accessibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .newsletter-input-wrapper {
    border-width: 3px;
  }

  .newsletter-submit {
    border-left-width: 3px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .newsletter-submit .button-icon,
  .newsletter-submit[aria-busy="true"]::after {
    transition: none;
    animation: none;
  }
}

/* ==========================================================================
   POPUP NOTIFICATION STYLES
   ========================================================================== */

.newsletter-popup {
  position: fixed;
  bottom: var(--space-lg, 20px);
  right: var(--space-lg, 20px);
  max-width: 400px;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-white);
  border: 2px solid var(--color-black);
  box-shadow: 4px 4px 0 0 var(--color-black);
  z-index: var(--z-index-toast, 10000);
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  opacity: 0;
  transform: translateY(var(--space-lg, 20px));
  transition: opacity var(--transition-base), transform var(--transition-base);
  font-family: var(--font-sans);
}

.newsletter-popup--visible {
  opacity: 1;
  transform: translateY(0);
}

.newsletter-popup__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  font-weight: bold;
  font-size: var(--font-size-sm);
}

.newsletter-popup--success .newsletter-popup__icon {
  background: var(--color-success);
  color: var(--color-white);
}

.newsletter-popup--error .newsletter-popup__icon {
  background: var(--color-error);
  color: var(--color-white);
}

.newsletter-popup__message {
  flex: 1;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

.newsletter-popup__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
  transition: opacity var(--transition-base);
}

.newsletter-popup__close:hover {
  opacity: 1;
}

.newsletter-popup__close:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  opacity: 1;
}

/* Dark mode popup styles */
[data-theme="dark"] .newsletter-popup {
  background: var(--color-surface);
  border-color: var(--color-border-medium);
  box-shadow: 4px 4px 0 0 var(--color-border-medium);
}

[data-theme="dark"] .newsletter-popup__message {
  color: var(--color-text-primary);
}

[data-theme="dark"] .newsletter-popup__close {
  color: var(--color-text-secondary);
}

/* Mobile responsive popup */
@media (max-width: 768px) {
  .newsletter-popup {
    bottom: var(--space-sm, 10px);
    left: var(--space-sm, 10px);
    right: var(--space-sm, 10px);
    max-width: none;
  }
}

/* Reduced motion support for popup animations */
@media (prefers-reduced-motion: reduce) {
  .newsletter-popup {
    transition: none;
  }

  .newsletter-popup--visible {
    transform: none;
  }
}

/* ==========================================================================
   DARK MODE ENHANCEMENTS
   ========================================================================== */

/* Newsletter component dark mode support */
[data-theme="dark"] .contact-newsletter {
  background: var(--color-surface);
  border-left-color: var(--color-blue);
}

[data-theme="dark"] .newsletter-input-wrapper {
  border-color: var(--color-border-medium);
  background: var(--color-surface);
}

[data-theme="dark"] .newsletter-input-wrapper:focus-within {
  box-shadow: 0 0 0 3px var(--shadow-color-light);
  border-color: var(--color-blue);
}

[data-theme="dark"] .newsletter-input {
  color: var(--color-text-primary);
  background: transparent;
}

[data-theme="dark"] .newsletter-input::placeholder {
  color: var(--color-text-muted);
}

[data-theme="dark"] .newsletter-submit {
  background: var(--color-blue);
  border-left-color: var(--color-blue);
  color: var(--color-text-inverse);
}

[data-theme="dark"] .newsletter-submit:disabled,
[data-theme="dark"] .form-button-type.newsletter-submit:disabled {
  background: var(--color-border-medium) !important;
  border-left-color: var(--color-border-medium) !important;
  color: var(--color-text-disabled-inverse, var(--color-white)) !important;  /* Semantic disabled text color for dark mode with fallback */
}

[data-theme="dark"] .newsletter-submit:disabled:hover,
[data-theme="dark"] .form-button-type.newsletter-submit:disabled:hover {
  background: var(--color-border-medium) !important;
  border-left-color: var(--color-border-medium) !important;
  color: var(--color-text-disabled-inverse, var(--color-white)) !important;  /* Maintain semantic disabled text color on hover in dark mode */
}

/* Enhanced error state visibility in dark mode */
[data-theme="dark"] .newsletter-input[aria-invalid="true"] {
  color: var(--color-error);
}

[data-theme="dark"] .newsletter-input-wrapper.error {
  border-color: var(--color-error);
  background: var(--color-error-light);
}

/* Success state visibility in dark mode */
[data-theme="dark"] .newsletter-success {
  background: var(--color-success-light);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .newsletter-success .success-icon {
  background: var(--color-success);
  color: var(--color-white);
}

/* Consent checkbox styling in dark mode */
[data-theme="dark"] .newsletter-consent .checkbox-label {
  color: var(--color-text-secondary);
}

/* Loading spinner visibility in dark mode */
[data-theme="dark"] .newsletter-submit[aria-busy="true"]::after {
  border-color: var(--color-text-inverse);
  border-right-color: transparent;
}

/* Mobile responsive dark mode adjustments */
@media (max-width: 768px) {
  [data-theme="dark"] .newsletter-submit {
    border-top-color: var(--color-blue);
    border-left: none;
  }
  
  [data-theme="dark"] .newsletter-submit:disabled {
    border-top-color: var(--color-border-medium);
  }
}
