/* =============================================================
   FLAIRT — Design System CSS
   Design tokens as CSS custom properties + component styles
   Stack: Django templates + Tailwind CSS + Preline UI
   ============================================================= */

/* ─── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* Brand colours */
  --color-brand:         #E8147A;
  --color-brand-light:   #FF4DA6;
  --color-brand-dark:    #B5005E;
  --color-violet:        #A855F7;
  --color-violet-light:  #C084FC;
  --color-violet-dark:   #7C3AED;
  --color-gold:          #F59E0B;

  /* Semantic */
  --color-success:       #10B981;
  --color-warning:       #F59E0B;
  --color-error:         #EF4444;
  --color-info:          #A855F7;

  /* Backgrounds */
  --color-bg-base:       #FAFAF9;
  --color-bg-surface:    #FFFFFF;
  --color-bg-muted:      #FAF5FF;

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

  /* Borders */
  --color-border:        #F0ECF8;
  --color-border-focus:  var(--color-brand);

  /* Gradients */
  --gradient-brand:      linear-gradient(135deg, #E8147A, #A855F7);
  --gradient-brand-r:    linear-gradient(135deg, #A855F7, #E8147A);
  --gradient-subtle:     linear-gradient(135deg, rgba(232,20,122,.06), rgba(168,85,247,.06));

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-sans:    'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;

  /* Type scale */
  --text-display: 3.25rem;  /* 52px */
  --text-h1:      2.25rem;  /* 36px */
  --text-h2:      1.75rem;  /* 28px */
  --text-h3:      1.25rem;  /* 20px */
  --text-body:    0.9375rem;/* 15px */
  --text-sm:      0.875rem; /* 14px */
  --text-xs:      0.75rem;  /* 12px */

  /* Spacing (8px grid) */
  --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;

  /* Border radii */
  --radius-sm:   8px;
  --radius-btn:  12px;
  --radius-card: 20px;
  --radius-lg:   24px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-brand:      0 4px 24px rgba(232,20,122,.12);
  --shadow-brand-lg:   0 8px 40px rgba(232,20,122,.18);
  --shadow-card:       0 2px 12px rgba(0,0,0,.06);
  --shadow-card-hover: 0 8px 32px rgba(0,0,0,.10);
  --shadow-input:      0 0 0 3px rgba(232,20,122,.10);
  --shadow-input-err:  0 0 0 3px rgba(239,68,68,.10);

  /* Motion */
  --dur-fast:     120ms;
  --dur-normal:   200ms;
  --dur-slow:     350ms;
  --dur-deliberate: 600ms;
  --ease-standard: cubic-bezier(.4,.0,.2,1);
  --ease-enter:    cubic-bezier(.0,.0,.2,1);
  --ease-exit:     cubic-bezier(.4,.0,1,1);
  --ease-spring:   cubic-bezier(.34,1.56,.64,1);
}

/* ─── BASE RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

/* ─── TYPOGRAPHY HELPERS ─────────────────────────────────────── */
.font-display { font-family: var(--font-display); }
.font-mono    { font-family: var(--font-mono); }

.text-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── BUTTONS ────────────────────────────────────────────────── */

/* Primary — brand gradient */
.btn-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--gradient-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  box-shadow: var(--shadow-brand);
  transition:
    opacity        var(--dur-normal) var(--ease-standard),
    transform      var(--dur-fast)   var(--ease-standard),
    box-shadow     var(--dur-normal) var(--ease-standard);
}
.btn-brand:hover  { opacity:.91; transform:translateY(-1px); box-shadow:var(--shadow-brand-lg); color:#fff; text-decoration:none; }
.btn-brand:active { opacity:.82; transform:translateY(0); }
.btn-brand:disabled,
.btn-brand[disabled],
.btn-brand.loading { opacity:.55; cursor:not-allowed; transform:none; pointer-events:none; }

/* Outline */
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  background: transparent;
  color: var(--color-brand);
  border: 1.5px solid var(--color-brand);
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition:
    background  var(--dur-normal) var(--ease-standard),
    color       var(--dur-normal) var(--ease-standard),
    transform   var(--dur-fast)   var(--ease-standard);
}
.btn-outline:hover { background:rgba(232,20,122,.06); transform:translateY(-1px); color:var(--color-brand); text-decoration:none; }

/* Ghost */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color var(--dur-normal) var(--ease-standard),
    color        var(--dur-normal) var(--ease-standard),
    background   var(--dur-normal) var(--ease-standard);
}
.btn-ghost:hover { border-color:var(--color-brand); color:var(--color-brand); background:rgba(232,20,122,.04); text-decoration:none; }

/* Danger */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  background: var(--color-error);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity var(--dur-normal) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.btn-danger:hover { opacity:.88; transform:translateY(-1px); color:#fff; text-decoration:none; }

/* Social / third-party */
.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: white;
  color: var(--color-text-primary);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    border-color var(--dur-normal) var(--ease-standard),
    box-shadow   var(--dur-normal) var(--ease-standard),
    transform    var(--dur-fast)   var(--ease-standard);
}
.btn-social:hover { border-color:#D1D5DB; box-shadow:var(--shadow-card); transform:translateY(-1px); color:var(--color-text-primary); text-decoration:none; }
.btn-social i { font-size: 18px; }

/* Size modifiers */
.btn-sm { padding: 8px 16px !important; font-size: var(--text-xs) !important; }
.btn-lg { padding: 16px 32px !important; font-size: 1rem !important; }
.btn-full { width: 100%; }

/* Loading spinner inside button */
.btn-brand.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 8px;
}

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

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur-normal) var(--ease-standard),
              transform  var(--dur-normal) var(--ease-standard);
}
.card-hover:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.card-brand  { box-shadow: var(--shadow-brand); }
.card-p      { padding: var(--space-6); }
.card-p-lg   { padding: var(--space-8); }

/* ─── FORM ELEMENTS ──────────────────────────────────────────── */
.form-group  { margin-bottom: var(--space-5); }

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: 11px 16px;
  background: white;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  color: var(--color-text-primary);
  outline: none;
  transition:
    border-color var(--dur-normal) var(--ease-standard),
    box-shadow   var(--dur-normal) var(--ease-standard);
}
.form-input::placeholder        { color: var(--color-text-tertiary); }
.form-input:focus               { border-color: var(--color-brand); box-shadow: var(--shadow-input); }
.form-input.is-invalid          { border-color: var(--color-error); box-shadow: var(--shadow-input-err); }
.form-input.is-valid            { border-color: var(--color-success); }

.form-error {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

/* ── Help tooltip (password requirements on hover) ─────────────── */
.help-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 4px;
  cursor: default;
}
.help-tooltip i {
  font-size: .8rem;
  color: var(--color-brand);
  opacity: .8;
}
.help-tooltip-body {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 260px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-secondary);
  line-height: 1.55;
  box-shadow: var(--shadow-md);
  z-index: 50;
  white-space: normal;
  pointer-events: none;
}
.help-tooltip:hover .help-tooltip-body,
.help-tooltip:focus .help-tooltip-body {
  display: block;
}

/* Password wrapper */
.input-wrap {
  position: relative;
}
.input-wrap .form-input {
  padding-right: 44px;
}
.input-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color var(--dur-fast) var(--ease-standard);
}
.input-suffix:hover { color: var(--color-brand); }

/* ─── DIVIDER WITH TEXT ──────────────────────────────────────── */
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-tertiary);
  margin: var(--space-5) 0;
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--color-border);
}

/* ─── BADGES ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-brand   { background: rgba(232,20,122,.10); color: var(--color-brand); }
.badge-violet  { background: rgba(168,85,247,.10);  color: var(--color-violet); }
.badge-success { background: rgba(16,185,129,.10);  color: var(--color-success); }
.badge-warning { background: rgba(245,158,11,.10);  color: var(--color-gold); }
.badge-error   { background: rgba(239,68,68,.10);   color: var(--color-error); }
.badge-neutral { background: rgba(107,114,128,.08); color: var(--color-text-secondary); }

/* ─── SCORE RING (CSS-only, conic-gradient) ──────────────────── */
.score-ring {
  --score: 75;
  --ring-color: var(--color-brand);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(
    var(--ring-color) calc(var(--score) * 1%),
    var(--color-border) 0
  );
}
.score-ring-inner {
  background: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--color-text-primary);
}
/* Sizes */
.score-ring-md { width: 80px;  height: 80px; }
.score-ring-md .score-ring-inner { width: 60px; height: 60px; font-size: 1rem; }
.score-ring-lg { width: 120px; height: 120px; }
.score-ring-lg .score-ring-inner { width: 90px;  height: 90px;  font-size: 1.4rem; }

/* ─── PROGRESS BAR ───────────────────────────────────────────── */
.progress-track {
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--gradient-brand);
  transition: width var(--dur-slow) var(--ease-enter);
}

/* ─── TOAST NOTIFICATIONS ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  border-left: 4px solid var(--color-brand);
  pointer-events: all;
  animation: toastIn var(--dur-slow) var(--ease-enter) forwards;
}
.toast.hiding { animation: toastOut var(--dur-normal) var(--ease-exit) forwards; }

.toast-success { border-left-color: var(--color-success); }
.toast-error   { border-left-color: var(--color-error); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info    { border-left-color: var(--color-violet); }

.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error   .toast-icon { color: var(--color-error); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info    .toast-icon { color: var(--color-violet); }

.toast-body    { flex: 1; min-width: 0; }
.toast-title   { font-size: var(--text-sm); font-weight: 700; color: var(--color-text-primary); margin-bottom: 2px; }
.toast-message { font-size: var(--text-xs); color: var(--color-text-secondary); line-height: 1.5; }
.toast-close   { background:none; border:none; cursor:pointer; color:var(--color-text-tertiary); font-size:16px; padding:0; flex-shrink:0; line-height:1; transition:color var(--dur-fast) var(--ease-standard); }
.toast-close:hover { color: var(--color-text-primary); }

@keyframes toastIn  { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); }    to { opacity:0; transform:translateX(16px); } }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,.45);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn var(--dur-normal) var(--ease-enter) forwards;
}
.modal-backdrop[hidden] { display: none; }

.modal-box {
  background: white;
  border-radius: var(--radius-card);
  box-shadow: 0 24px 80px rgba(0,0,0,.18);
  width: 100%;
  max-width: 480px;
  animation: slideUp var(--dur-slow) var(--ease-spring) forwards;
  overflow: hidden;
}
.modal-header {
  padding: var(--space-6) var(--space-6) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
}
.modal-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
.modal-close { background:none; border:none; cursor:pointer; color:var(--color-text-tertiary); font-size:20px; line-height:1; transition:color var(--dur-fast) var(--ease-standard); }
.modal-close:hover { color: var(--color-text-primary); }
.modal-body   { padding: var(--space-6); }
.modal-footer { padding: var(--space-4) var(--space-6) var(--space-6); display:flex; gap:10px; justify-content:flex-end; }

@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

/* ─── NAVBAR ─────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}
.topnav-logo {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text-primary);
  text-decoration: none;
  flex-shrink: 0;
}
.topnav-logo .ai-accent {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topnav-spacer { flex: 1; }

/* ─── AUTH SPLIT LAYOUT ──────────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-panel-brand {
  background: var(--gradient-brand);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: var(--space-10) var(--space-10) var(--space-8);
  position: relative;
  overflow: hidden;
}

/* Decorative circles */
.auth-panel-brand::before {
  content: '';
  position: absolute;
  width: 360px; height: 360px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  top: -80px; right: -80px;
}
.auth-panel-brand::after {
  content: '';
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  bottom: 40px; left: -60px;
}

.auth-panel-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  background: var(--color-bg-base);
  overflow-y: auto;
}

.auth-form-wrap { width: 100%; max-width: 400px; }

@media (max-width: 768px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-panel-brand { display: none; }
  .auth-panel-form { padding: var(--space-8) var(--space-6); min-height: 100vh; }
}

/* ─── STAT CARD ──────────────────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}
.stat-card-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
}
.stat-card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1.1;
}

/* ─── AVATAR ─────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  font-weight: 700;
}
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-md { width: 48px; height: 48px; font-size: 1rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ─── LOADING SKELETON ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #F0ECF8 25%, #FAF5FF 50%, #F0ECF8 75%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ─── ALERT BANNERS ──────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  font-size: var(--text-sm);
  border-left: 4px solid;
}
.alert-success { background: rgba(16,185,129,.08);  border-color: var(--color-success); color: #065f46; }
.alert-error   { background: rgba(239,68,68,.08);   border-color: var(--color-error);   color: #991b1b; }
.alert-warning { background: rgba(245,158,11,.08);  border-color: var(--color-warning); color: #92400e; }
.alert-info    { background: rgba(168,85,247,.08);  border-color: var(--color-violet);  color: #5b21b6; }

/* ─── STEP INDICATORS ────────────────────────────────────────── */
.step-list { display: flex; gap: 0; align-items: center; }
.step-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
  transition: all var(--dur-normal) var(--ease-standard);
}
.step-dot.done   { background: var(--color-success); border-color: var(--color-success); color: white; }
.step-dot.active { background: var(--gradient-brand); border-color: var(--color-brand);  color: white; }
.step-connector  { flex: 1; height: 2px; background: var(--color-border); }
.step-connector.done { background: var(--color-success); }

/* ─── REDUCED MOTION ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
