/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:          #f5f7fa;
  --bg-card:     #ffffff;
  --bg-sidebar:  #ffffff;
  --bg-input:    #f0f2f5;
  --text:        #1a1d23;
  --text-muted:  #6b7280;
  --border:      #e5e7eb;
  --primary:     #4f46e5;
  --primary-h:   #4338ca;
  --primary-lt:  #eef2ff;
  --success:     #10b981;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --radius:      10px;
  --radius-sm:   6px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --transition:  .2s ease;
}

[data-theme="dark"] {
  --bg:          #0f1117;
  --bg-card:     #1a1d27;
  --bg-sidebar:  #13151f;
  --bg-input:    #252836;
  --text:        #e8eaf0;
  --text-muted:  #9ca3af;
  --border:      #2d3148;
  --primary:     #6366f1;
  --primary-h:   #818cf8;
  --primary-lt:  #1e1b4b;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
p  { color: var(--text-muted); }

/* ── Layout Utilities ──────────────────────────────────────── */
.container    { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: .5rem; }
.gap-2  { gap: 1rem; }
.gap-3  { gap: 1.5rem; }
.mt-1   { margin-top: .5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }
.mb-2   { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-sm { font-size: .875rem; }
.text-muted { color: var(--text-muted); }

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  font-family: var(--font);
  transition: all var(--transition);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }

.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }

.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-input); color: var(--text); }

.btn-sm { padding: .35rem .8rem; font-size: .8rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-google {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
.btn-google:hover { border-color: #ea4335; }
.btn-google img { width: 18px; height: 18px; }

/* ── Form Controls ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label { font-size: .875rem; font-weight: 500; color: var(--text); }

input, select, textarea {
  width: 100%;
  padding: .65rem .9rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Header / Navbar ───────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition);
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.navbar-brand span { color: var(--primary); }
.navbar-actions { display: flex; align-items: center; gap: .75rem; }

/* ── Dark Mode Toggle ──────────────────────────────────────── */
.theme-toggle {
  width: 44px;
  height: 24px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
[data-theme="dark"] .theme-toggle { background: var(--primary-lt); border-color: var(--primary); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(20px); background: var(--primary); }

/* ── Avatar ────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .875rem;
  box-shadow: var(--shadow-md);
  max-width: 320px;
  animation: slideIn .2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ── Badge ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-primary   { background: var(--primary-lt); color: var(--primary); }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-muted     { background: var(--bg-input); color: var(--text-muted); }
[data-theme="dark"] .badge-success { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-danger  { background: #7f1d1d; color: #fca5a5; }
[data-theme="dark"] .badge-warning { background: #78350f; color: #fcd34d; }

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-header h2 { font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* ── Typing Dots ───────────────────────────────────────────── */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: .5rem 0; }
.typing-dots span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  .container { padding: 0 1rem; }
  .navbar-inner { padding: .75rem 1rem; }
}
@media (max-width: 480px) {
  .btn-lg { padding: .65rem 1.25rem; font-size: .9rem; }
}
