/* =====================================================
   Aiternos Client Forms — Main Design System
   main.css — Shared variables, resets, components
   ===================================================== */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Brand colours */
  --color-primary:       #00CFFF;
  --color-primary-dark:  #0099CC;
  --color-primary-hover: #00B8E6;
  --color-primary-alpha: rgba(0, 207, 255, 0.12);
  --color-primary-soft:  rgba(0, 207, 255, 0.06);

  /* Backgrounds */
  --color-page-bg:       #EEF2F7;
  --color-bg:            #FFFFFF;
  --color-surface:       #F8F9FA;
  --color-surface-alt:   #F0F2F5;

  /* Text */
  --color-text:          #1A1A2E;
  --color-text-secondary:#6B7280;
  --color-placeholder:   #9CA3AF;

  /* Border */
  --color-border:        #E5E7EB;
  --color-border-focus:  #00CFFF;

  /* Status */
  --color-success:       #22C55E;
  --color-success-soft:  rgba(34, 197, 94, 0.1);
  --color-error:         #EF4444;
  --color-error-soft:    rgba(239, 68, 68, 0.08);
  --color-warning:       #F59E0B;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);

  /* Border radius */
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-pill: 24px;
  --radius-full: 999px;

  /* Typography */
  --font-family:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs:  12px;
  --font-size-sm:  13px;
  --font-size-base:15px;
  --font-size-md:  16px;
  --font-size-lg:  18px;
  --font-size-xl:  22px;
  --font-size-2xl: 28px;
  --line-height:   1.7;

  /* Spacing scale */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-fast: all 0.15s ease;

  /* Option card selected (inner fill for gradient-border technique) */
  --color-option-checked-bg: #F0FCFF;
}

/* ── Dark Mode Tokens ── */
[data-theme="dark"] {
  --color-page-bg:       #0C0E17;
  --color-bg:            #13162A;
  --color-surface:       #13162A;
  --color-surface-alt:   #1E2240;

  --color-text:          #E0E6F0;
  --color-text-secondary:#9CA3AF;
  --color-placeholder:   #4B5563;

  --color-border:        #1E2240;
  --color-border-focus:  #00CFFF;

  --color-primary-soft:  rgba(26, 58, 255, 0.15);
  --color-primary-alpha: rgba(0, 207, 255, 0.15);
  --color-success-soft:  rgba(34, 197, 94, 0.15);
  --color-error-soft:    rgba(239, 68, 68, 0.12);

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.4), 0 2px 8px rgba(0,207,255,0.05);
  --shadow-md: 0 4px 24px rgba(0,207,255,0.08), 0 1px 4px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,207,255,0.10), 0 2px 8px rgba(0,0,0,0.5);

  --color-option-checked-bg: #1E2240;
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-page-bg);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  font-size: var(--font-size-base);
}

a {
  color: var(--color-primary-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul, ol {
  list-style: none;
}

/* ── Typography ── */
h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
}

h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  line-height: 1.35;
  color: var(--color-text);
}

h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text);
}

h4 {
  font-size: var(--font-size-md);
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text);
}

p {
  color: var(--color-text-secondary);
  line-height: var(--line-height);
}

/* ── Page Header / Nav Bar ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 var(--space-4);
  gap: var(--space-4);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
}

.site-logo__img {
  height: 32px;
  width: auto;
}

.site-logo__text {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Header controls wrapper (theme switch + lang toggle) ── */
.site-header__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Language Toggle ── */
.lang-toggle {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.lang-toggle__btn {
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: var(--transition-fast);
  cursor: pointer;
}

.lang-toggle__btn.active {
  background: linear-gradient(135deg, #1A3AFF, #00CFFF);
  color: #ffffff;
  font-weight: 600;
}

.lang-toggle__btn:hover:not(.active) {
  color: var(--color-text);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px var(--space-6);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background: linear-gradient(135deg, #1A3AFF, #00CFFF, #1A3AFF);
  background-size: 300% 300%;
  animation: drift 22s ease infinite;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(26, 58, 255, 0.3);
}

.btn--primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #00CFFF, #1A3AFF, #2D4FFF, #00CFFF);
  background-size: 300% 300%;
  animation: drift 22s ease infinite;
  opacity: 0;
  transition: opacity 0.4s ease;
  border-radius: inherit;
}

.btn--primary > span,
.btn--primary .arrow-wrap {
  position: relative;
  z-index: 1;
}

/* Wraps the text label and arrow together so they never break apart */
.btn-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn--primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 207, 255, 0.35), 0 2px 6px rgba(26, 58, 255, 0.25);
}

.btn--primary:hover::before {
  opacity: 1;
}

.btn--primary:active {
  transform: translateY(0) scale(1);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: #D1D5DB;
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.btn--sm {
  padding: 7px var(--space-4);
  font-size: var(--font-size-sm);
}

.btn--lg {
  padding: 14px var(--space-8);
  font-size: var(--font-size-md);
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Loading spinner on button */
.btn.loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@keyframes drift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes diag-spin {
  0%   { transform: translate(0, 0);        opacity: 1; }
  45%  { transform: translate(14px, -14px); opacity: 0; }
  46%  { transform: translate(-14px, 14px); opacity: 0; }
  100% { transform: translate(0, 0);        opacity: 1; }
}

/* Arrow wrap — diagonal exit/enter animation on CTA hover */
.arrow-wrap {
  overflow: hidden;
  height: 16px;
  width: 16px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.arrow-wrap svg {
  position: absolute;
  inset: 0;
  margin: auto;
}

.btn--primary:hover .arrow-wrap svg {
  animation: diag-spin 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Badges / Status Pills ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge--success {
  background: var(--color-success-soft);
  color: #16A34A;
}

.badge--warning {
  background: rgba(245,158,11,0.1);
  color: #B45309;
}

.badge--info {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}

.badge--neutral {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

/* ── Dot indicator for badge ── */
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Alert / Notice ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.alert--error {
  background: var(--color-error-soft);
  border: 1px solid rgba(239,68,68,0.15);
  color: #B91C1C;
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  background: var(--color-text);
  color: #fff;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 320px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast--success {
  background: #15803D;
}

.toast--error {
  background: #B91C1C;
}

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

/* ── Page wrapper ── */
.page-main {
  min-height: calc(100vh - 65px);
  padding: var(--space-10) 0 var(--space-16);
}

@media (max-width: 767px) {
  .site-logo__text {
    display: none;
  }
}

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: var(--space-6) var(--space-5);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  border-top: 1px solid var(--color-border);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  :root {
    --font-size-2xl: 22px;
    --font-size-xl:  18px;
    --font-size-lg:  16px;
  }

  .page-main {
    padding: var(--space-6) 0 var(--space-12);
  }

  .toast {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
    max-width: none;
  }
}

/* ═══════════════════════════════════════════════════
   Theme Switch Component
   ═══════════════════════════════════════════════════ */
.theme-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

.theme-switch__track {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.theme-switch__icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  z-index: 1;
  transition: color 0.3s ease;
  color: var(--color-text);       /* both icons dark in light mode */
  pointer-events: none;
}

/* Sun = active in light mode → cyan highlight */
.theme-switch__icon:first-of-type {
  color: #00CFFF;
}

.theme-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.3s ease;
  pointer-events: none;
}

/* ── Dark mode state ── */
[data-theme="dark"] .theme-switch__track {
  background: linear-gradient(135deg, #1A3AFF, #00CFFF);
  border-color: transparent;
}

[data-theme="dark"] .theme-switch__thumb {
  transform: translateX(24px);
}

/* Dark mode: both icons white */
[data-theme="dark"] .theme-switch__icon {
  color: #ffffff;
}

/* Moon = active in dark mode → cyan highlight */
[data-theme="dark"] .theme-switch__icon:last-of-type {
  color: #00CFFF;
}

/* ── Dark mode overrides for shared components ── */
[data-theme="dark"] .site-header {
  background: var(--color-bg);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .lang-toggle {
  background: var(--color-surface-alt);
}

[data-theme="dark"] .alert--error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.25);
  color: #FCA5A5;
}

[data-theme="dark"] .toast {
  background: var(--color-surface-alt);
  color: var(--color-text);
}
