/* Centralized System Pages Styles - Single source of truth */

/* ============================================
   CSS Variables
   ============================================ */
:root {
  /* System-page backgrounds — derived from the theme's own brand colors instead of
     hardcoded palettes. Each gradient runs from a theme color to that same color 50%
     lightened (color-mix … 50%, white). The var() fallbacks are the theme defaults, so
     on membership pages that render without theme context (see base-system.html) the
     gradients still resolve to a sensible brand-ish tone rather than a broken value.
     Semantic mapping: 404/warning → secondary, 500 → danger, maintenance → primary,
     success → success. */
  --system-gradient-2: linear-gradient(135deg, var(--color-secondary, #6c757d) 0%, color-mix(in srgb, var(--color-secondary, #6c757d) 50%, white) 100%);
  --system-gradient-3: linear-gradient(135deg, var(--color-primary, #1e3a8a) 0%, color-mix(in srgb, var(--color-primary, #1e3a8a) 50%, white) 100%);
  --system-gradient-success: linear-gradient(135deg, var(--color-success, #28a745) 0%, color-mix(in srgb, var(--color-success, #28a745) 50%, white) 100%);
  --system-gradient-error: linear-gradient(135deg, var(--color-danger, #dc3545) 0%, color-mix(in srgb, var(--color-danger, #dc3545) 50%, white) 100%);
  --system-gradient-warning: linear-gradient(135deg, var(--color-secondary, #6c757d) 0%, color-mix(in srgb, var(--color-secondary, #6c757d) 50%, white) 100%);
  --system-gradient-dark: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);

  --system-shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.07), 0 1px 4px rgba(0, 0, 0, 0.04);

  --system-radius: 1rem;
  --system-max-width: 480px;
  --system-padding: 2.5rem;
  --system-padding-mobile: 1.5rem;
}

/* ============================================
   Base System Page Layout
   ============================================ */

/* Self-contained resets — system pages may load this sheet standalone (inlined into
   base-system.html) without modern.css, so it can't rely on a global box-sizing/font. */
.system-page-body,
.system-page-body *,
.system-page-body *::before,
.system-page-body *::after {
  box-sizing: border-box;
}

.system-page-body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-body, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  color: var(--color-text, #111827);
}

.system-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, var(--color-bg, #ffffff) 0%, var(--color-bg-secondary, #f5f7fa) 100%);
}

/* ============================================
   System Container
   ============================================ */

.system-container {
  background: var(--color-bg, white);
  padding: var(--system-padding);
  border-radius: var(--system-radius);
  box-shadow: var(--system-shadow-lg);
  border: 1px solid var(--color-border, #e5e7eb);
  max-width: var(--system-max-width);
  width: 100%;
  text-align: center;
}

/* ============================================
   Brand / Logo
   ============================================ */

.system-brand {
  margin-bottom: 2rem;
}

.system-logo {
  max-width: 250px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.system-brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text, #111827);
  letter-spacing: -0.01em;
}

/* ============================================
   System Icon
   ============================================ */

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

.system-icon svg {
  width: 24px;
  height: 24px;
  stroke: white;
  fill: none;
  stroke-width: 2;
}

/* Icon Variants */
.system-icon.icon-error {
  background: #ef4444;
}

.system-icon.icon-success {
  background: #22c55e;
}

.system-icon.icon-warning {
  background: #f59e0b;
}

.system-icon.icon-info {
  background: #3b82f6;
}

/* ============================================
   Typography
   ============================================ */

.system-title {
  font-size: clamp(1.375rem, 3.5vw, 2rem);
  margin-bottom: 0.75rem;
  color: var(--color-text, #111827);
  font-weight: 700;
  line-height: 1.25;
}

.system-message {
  color: var(--color-text-secondary, #6b7280);
  margin-bottom: 1.5rem;
  line-height: 1.6;
  font-size: 1rem;
}

/* Error Code Display */
.system-code {
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 900;
  background: linear-gradient(135deg, var(--color-primary, #667eea) 0%, var(--color-primary, #764ba2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 1rem 0;
  line-height: 1;
}

/* ============================================
   Status Messages
   ============================================ */

.system-status {
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  font-weight: 500;
  font-size: 0.9375rem;
  text-align: left;
}

.system-status.success {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.system-status.error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.system-status.warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.system-status.info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ============================================
   Actions/Buttons
   ============================================ */

.system-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.btn {
  padding: 0.6875rem 1.5rem;
  border-radius: 0.5rem;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  display: inline-block;
  cursor: pointer;
  border: 2px solid transparent;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.btn-primary {
  background: var(--color-primary, #667eea);
  color: white;
  border-color: var(--color-primary, #667eea);
}

.btn-primary:hover {
  opacity: 0.88;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  color: white;
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary, #667eea);
  border-color: var(--color-primary, #667eea);
}

.btn-secondary:hover {
  background: var(--color-primary, #667eea);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary, #667eea);
  border-color: transparent;
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--color-primary, #667eea) 10%, transparent);
}

/* ============================================
   Forms in System Pages
   ============================================ */

.system-form {
  max-width: 400px;
  margin: 1.5rem auto;
  text-align: left;
}

.system-form .form-group {
  margin-bottom: 1.25rem;
}

.system-form label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #4b5563);
}

.system-form .form-actions {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.system-form .form-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border, #e5e7eb);
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
}

.system-form .form-footer a {
  color: var(--color-primary, #667eea);
  text-decoration: none;
  font-weight: 600;
}

.system-form .form-footer a:hover {
  text-decoration: underline;
}

/* ============================================
   HubSpot membership widgets (member_login / register / reset)
   These emit HubSpot's own .hs-input / .hs-button / .hs-login-widget-* classes
   (NOT .hs-form). Scoped under .system-form so nothing leaks to regular forms.
   ============================================ */

.system-form .hs-form-field {
  margin-bottom: 1.125rem;
}

.system-form .hs-login-widget-email-label,
.system-form .hs-login-widget-password-label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #4b5563);
}

.system-form input.hs-input[type="text"],
.system-form input.hs-input[type="email"],
.system-form input.hs-input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.6875rem 0.875rem;
  font: inherit;
  color: var(--color-text, #111827);
  background: var(--color-bg, #ffffff);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 0.5rem;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.system-form input.hs-input:focus {
  outline: none;
  border-color: var(--color-primary, #667eea);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #667eea) 18%, transparent);
}

/* Remember-me / consent: checkbox inline with its label */
.system-form input.hs-input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0 0.5rem 0 0;
  vertical-align: middle;
  accent-color: var(--color-primary, #667eea);
}

.system-form input.hs-input[type="checkbox"] + label,
.system-form label.hs-form-booleancheckbox-display {
  display: inline;
  font-weight: 400;
  color: var(--color-text, #374151);
}

/* "Show password" / forgot-password links */
.system-form .hs-login-widget-show-password {
  color: var(--color-primary, #667eea);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
}

.system-form .hs-login-widget-show-password:hover {
  text-decoration: underline;
}

/* Submit button — full-width, themed */
.system-form .hs-submit,
.system-form .actions {
  margin-top: 1.25rem;
}

.system-form input.hs-button,
.system-form .hs-button.primary {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 2.75rem;
  padding: 0.6875rem 1.5rem;
  font: inherit;
  font-weight: 600;
  color: var(--color-primary-contrast, #ffffff);
  background: var(--color-primary, #667eea);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.system-form input.hs-button:hover,
.system-form .hs-button.primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Passwordless separator ("or") */
.system-form .form-separator {
  display: block;
  text-align: center;
  margin: 1.25rem 0;
  color: var(--color-text-secondary, #9ca3af);
  font-size: 0.8125rem;
}

/* Validation errors */
.system-form .hs-error-msg,
.system-form .hs-membership-global-error {
  display: block;
  color: var(--color-danger, #b91c1c);
  font-size: 0.8125rem;
  font-weight: 400;
  margin-top: 0.375rem;
}

.system-form ul.hs-error-msgs {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ============================================
   Additional Sections
   ============================================ */

.system-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border, #e5e7eb);
}

.system-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--color-text, #111827);
}

/* Contact Info */
.system-contact {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--color-bg-secondary, #f9fafb);
  border: 1px solid var(--color-border-light, #f3f4f6);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
}

.system-contact a {
  color: var(--color-primary, #667eea);
  text-decoration: none;
  font-weight: 600;
}

.system-contact a:hover {
  text-decoration: underline;
}

/* Progress Bar */
.system-progress {
  width: 100%;
  height: 6px;
  background: var(--color-border, #e5e7eb);
  border-radius: 3px;
  overflow: hidden;
  margin: 1.5rem 0;
}

.system-progress-fill {
  height: 100%;
  background: var(--color-primary, #667eea);
  border-radius: 3px;
  animation: system-progress 3s ease-in-out infinite;
}

@keyframes system-progress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* Timer/Countdown */
.system-countdown {
  font-size: 0.875rem;
  color: var(--color-text-secondary, #6b7280);
  margin-top: 0.75rem;
}

.system-countdown span {
  font-weight: 600;
  color: var(--color-primary, #667eea);
}

/* ============================================
   Page-Specific Backgrounds
   ============================================ */

/* Error pages keep intentionally dramatic colored backgrounds */
.system-page.page-error-404 {
  background: var(--system-gradient-2);
}

.system-page.page-error-500 {
  background: var(--system-gradient-error);
}

.system-page.page-error-403 {
  background: var(--system-gradient-warning);
}

.system-page.page-maintenance {
  background: var(--system-gradient-3);
}

.system-page.page-success {
  background: var(--system-gradient-success);
}

/* Auth pages: clean, brand-aware background */
.system-page.page-auth {
  background: linear-gradient(160deg, var(--color-bg, #ffffff) 0%, var(--color-bg-secondary, #f5f7fa) 100%);
}

/* Auth pages show logo as brand mark — icon is redundant */
.system-page.page-auth .system-icon {
  display: none;
}

/* ============================================
   Dark Mode
   ============================================
   Auto dark-mode (prefers-color-scheme) lives in css/dark.css, gated by the
   theme setting. The manual [data-theme-override="dark"] rules below stay
   here — they only match when the header dark-mode JS sets the attribute.
   ============================================ */

[data-theme-override="dark"] .system-container {
  border-color: var(--color-border, #374151);
}

[data-theme-override="dark"] .system-status.success {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

[data-theme-override="dark"] .system-status.error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

[data-theme-override="dark"] .system-status.warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

[data-theme-override="dark"] .system-status.info {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 640px) {
  .system-container {
    padding: var(--system-padding-mobile);
  }

  .system-actions {
    flex-direction: column;
    width: 100%;
  }

  .system-actions .btn {
    width: 100%;
  }

  .system-form .form-actions {
    flex-direction: column;
  }

  .system-form .form-actions .btn {
    width: 100%;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .system-page {
    background: white;
    min-height: auto;
  }

  .system-container {
    box-shadow: none;
    border-color: #000;
  }

  .system-actions {
    display: none;
  }
}
