/* Email Capture Component Styles */
/* Reusable email capture form for calculator/optimizer result pages */

/* ===== Container ===== */
.email-capture {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  transition: border-color 0.2s ease;
}

.email-capture:hover {
  border-color: var(--accent-primary);
}

/* ===== Header ===== */
.email-capture-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.email-capture h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.email-capture-description {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Honeypot (hidden from users) ===== */
.email-capture-honey {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ===== Form ===== */
.email-capture-form {
  margin-bottom: 1rem;
}

.email-capture-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.email-capture-input-wrapper {
  width: 100%;
  position: relative;
}

.email-capture-input-wrapper input[type="email"] {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  margin: 0;
}

.email-capture-input-wrapper input[type="email"]::placeholder {
  color: var(--text-muted);
}

.email-capture-input-wrapper input[type="email"]:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(124, 197, 174, 0.15);
}

.email-capture-input-wrapper input[type="email"]:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.email-capture-input-wrapper input[type="email"]:invalid:not(:placeholder-shown) {
  border-color: #ef4444;
}

.email-capture-input-wrapper input[type="email"].error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Error message */
.email-capture-error {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: #ef4444;
}

.email-capture-error[hidden] {
  display: none;
}

/* ===== Submit Button ===== */
.email-capture-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  width: 100%;
  background: var(--accent-primary);
  color: #141c24;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  white-space: nowrap;
}

.email-capture-submit:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.email-capture-submit:active:not(:disabled) {
  transform: translateY(0);
}

.email-capture-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.email-capture-submit .submit-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.email-capture-submit .submit-text[hidden],
.email-capture-submit .submit-loading[hidden] {
  display: none;
}

/* Spinner */
.email-capture-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(20, 28, 36, 0.3);
  border-top-color: #141c24;
  border-radius: 50%;
  animation: email-capture-spin 0.8s linear infinite;
}

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

/* ===== Opt-in Checkbox ===== */
.email-capture-optin {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.email-capture-optin input[type="checkbox"] {
  /* Reset Pico styles */
  -webkit-appearance: checkbox;
  -moz-appearance: checkbox;
  appearance: checkbox;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.email-capture-optin .optin-text {
  line-height: 1.4;
}

/* ===== Success State ===== */
.email-capture-success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 1rem;
  background: rgba(124, 197, 174, 0.15);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.email-capture-success[hidden] {
  display: none;
}

.email-capture-success .success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--accent-primary);
  color: #141c24;
  border-radius: 50%;
  font-weight: bold;
  font-size: 0.875rem;
}

.email-capture-success .success-message {
  font-weight: 500;
  color: var(--accent-primary);
}

/* ===== Privacy Link ===== */
.email-capture-privacy {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.email-capture-privacy .privacy-link {
  color: var(--text-secondary);
  text-decoration: underline;
  transition: color 0.2s;
}

.email-capture-privacy .privacy-link:hover {
  color: var(--accent-primary);
}

/* ===== Light Theme Overrides ===== */
[data-theme="light"] .email-capture-success {
  background: rgba(91, 168, 142, 0.1);
}

[data-theme="light"] .email-capture-success .success-message {
  color: var(--accent-primary);
}

[data-theme="light"] .email-capture-error {
  color: #dc2626;
}

[data-theme="light"] .email-capture-input-wrapper input[type="email"].error {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .email-capture {
    padding: 1.25rem;
  }

  .email-capture-header {
    margin-bottom: 1rem;
  }

  .email-capture h4 {
    font-size: 1rem;
  }

  .email-capture-description {
    font-size: 0.875rem;
  }
}

/* Task 2.1: Increase checkbox touch target on mobile */
@media (max-width: 768px) {
  .email-capture-optin {
    padding: 0.5rem 0;
    gap: 0.75rem;
  }

  .email-capture-optin input[type="checkbox"] {
    width: 22px;
    height: 22px;
    position: relative;
  }

  /* Expand tap area beyond visible checkbox */
  .email-capture-optin input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: -11px;
    left: -11px;
    right: -11px;
    bottom: -11px;
  }
}
