/**
 * NewsMailer Pro — Base Public Frontend Stylesheet
 *
 * Contains:
 *  - CSS custom properties (variables) for easy theming
 *  - Base form wrapper and layout styles
 *  - Email input field styles (shared across all button styles)
 *  - Form response/message area styles
 *  - Loading state styles
 *  - Accessibility improvements
 *  - Responsive styles
 *
 * NOTE: Button-specific styles are in their own separate files:
 *  - button-style-1.css
 *  - button-style-2.css
 *  - button-style-3.css
 *
 * @package NewsMailer_Pro
 */

/* ============================================================
   CSS CUSTOM PROPERTIES (Variables)
   ============================================================ */
:root {
  --nmp-primary: #2271b1;
  --nmp-primary-hover: #135e96;
  --nmp-success: #00a32a;
  --nmp-error: #d63638;
  --nmp-warning: #dba617;
  --nmp-text: #1d2327;
  --nmp-text-light: #50575e;
  --nmp-border: #c3c4c7;
  --nmp-border-focus: #2271b1;
  --nmp-bg: #ffffff;
  --nmp-bg-light: #f6f7f7;
  --nmp-radius: 6px;
  --nmp-radius-lg: 10px;
  --nmp-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --nmp-shadow-focus: 0 0 0 3px rgba(34, 113, 177, 0.25);
  --nmp-transition: all 0.2s ease;
  --nmp-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --nmp-input-height: 48px;
  --nmp-input-padding: 0 16px;
  --nmp-input-font-size: 15px;
}

/* ============================================================
   FORM WRAPPER
   ============================================================ */
.nmp-form-wrapper {
  display: block;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  font-family: var(--nmp-font);
  box-sizing: border-box;
}

.nmp-form-wrapper *,
.nmp-form-wrapper *::before,
.nmp-form-wrapper *::after {
  box-sizing: border-box;
}

/* ============================================================
   FORM ELEMENT
   ============================================================ */
.nmp-subscription-form {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* Form row — horizontal layout for input + button */
.nmp-form-row {
  display: flex;
  align-items: stretch;
  width: 100%;
  gap: 0;
}

/* ============================================================
   EMAIL INPUT FIELD — Shared base styles
   ============================================================ */
.nmp-email-input {
  display: block;
  flex: 1 1 auto;
  min-width: 0; /* Prevent flex overflow */
  height: var(--nmp-input-height);
  padding: var(--nmp-input-padding);
  font-size: var(--nmp-input-font-size);
  font-family: var(--nmp-font);
  color: var(--nmp-text);
  background-color: var(--nmp-bg);
  border: 2px solid var(--nmp-border);
  border-right: none; /* Merges cleanly with the button */
  border-radius: var(--nmp-radius) 0 0 var(--nmp-radius);
  outline: none;
  transition: var(--nmp-transition);
  -webkit-appearance: none;
  appearance: none;
}

.nmp-email-input::placeholder {
  color: var(--nmp-text-light);
  opacity: 1;
}

.nmp-email-input:focus {
  border-color: var(--nmp-border-focus);
  box-shadow: var(--nmp-shadow-focus);
  z-index: 1;
  position: relative;
}

/* Error state on input */
.nmp-email-input.nmp-input-error {
  border-color: var(--nmp-error);
}

.nmp-email-input.nmp-input-error:focus {
  box-shadow: 0 0 0 3px rgba(214, 54, 56, 0.25);
}

/* Disabled state */
.nmp-email-input:disabled {
  background-color: var(--nmp-bg-light);
  cursor: not-allowed;
  opacity: 0.7;
}

/* ============================================================
   SUBSCRIBE BUTTON — Shared base styles
   (Visual styling is in button-style-*.css files)
   ============================================================ */
.nmp-subscribe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: var(--nmp-input-height);
  padding: 0 24px;
  font-size: var(--nmp-input-font-size);
  font-family: var(--nmp-font);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 0 var(--nmp-radius) var(--nmp-radius) 0;
  transition: var(--nmp-transition);
  text-decoration: none;
  line-height: 1;
  -webkit-appearance: none;
  appearance: none;
}

.nmp-subscribe-btn:focus {
  outline: 2px solid var(--nmp-border-focus);
  outline-offset: 2px;
}

.nmp-subscribe-btn:disabled,
.nmp-subscribe-btn.nmp-loading {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Loading spinner icon inside button */
.nmp-subscribe-btn.nmp-loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: nmp-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ============================================================
   FORM RESPONSE MESSAGE AREA
   ============================================================ */
.nmp-form-response {
  display: none; /* Hidden by default — shown via JS */
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--nmp-radius);
  font-size: 14px;
  font-family: var(--nmp-font);
  line-height: 1.5;
  font-weight: 500;
}

/* Success message */
.nmp-form-response.nmp-success {
  display: block;
  color: #0a4b1e;
  background-color: #d1fae5;
  border: 1px solid #6ee7b7;
}

/* Error message */
.nmp-form-response.nmp-error {
  display: block;
  color: #7f1d1d;
  background-color: #fee2e2;
  border: 1px solid #fca5a5;
}

/* ============================================================
   STACKED LAYOUT (input above button — for narrow containers)
   ============================================================ */
.nmp-form-wrapper.nmp-stacked .nmp-form-row {
  flex-direction: column;
  gap: 8px;
}

.nmp-form-wrapper.nmp-stacked .nmp-email-input {
  border: 2px solid var(--nmp-border);
  border-radius: var(--nmp-radius);
  width: 100%;
}

.nmp-form-wrapper.nmp-stacked .nmp-subscribe-btn {
  border-radius: var(--nmp-radius);
  width: 100%;
  height: var(--nmp-input-height);
}

/* ============================================================
   RESPONSIVE — Stack form vertically on small screens
   ============================================================ */
@media (max-width: 480px) {
  .nmp-form-row {
    flex-direction: column;
    gap: 8px;
  }

  .nmp-email-input {
    border: 2px solid var(--nmp-border);
    border-radius: var(--nmp-radius);
    width: 100%;
    border-right: 2px solid var(--nmp-border);
  }

  .nmp-email-input:focus {
    border-color: var(--nmp-border-focus);
  }

  .nmp-subscribe-btn {
    border-radius: var(--nmp-radius);
    width: 100%;
    height: var(--nmp-input-height);
  }
}

/* ============================================================
   ACCESSIBILITY — Reduced motion support
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .nmp-subscribe-btn,
  .nmp-email-input,
  .nmp-form-response {
    transition: none;
  }
  .nmp-subscribe-btn.nmp-loading::before {
    animation: none;
  }
}
