@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background: #f1f5f9; color: #1e293b; }

/* ===== DESIGN TOKENS ===== */
:root {
  --brand: #1e3a8a;
  --brand-light: #3b82f6;
  --brand-50: #eff6ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.1);
}

/* ===== LAYOUT ===== */
.app-bg { background: #f1f5f9; }
.main-content { transition: margin-left .3s cubic-bezier(.4,0,.2,1); }
.main-content.sidebar-expanded { margin-left: 16rem; }
.main-content.sidebar-collapsed { margin-left: 4rem; }
@media (max-width: 767px) { .main-content { margin-left: 0 !important; } }

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card-sm { padding: 1rem; }
.card-hover { transition: box-shadow .2s, transform .2s; }
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

/* Legacy aliases */
.glass-effect { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.shadow-modern { box-shadow: var(--shadow); }
.shadow-warm { box-shadow: var(--shadow); }

/* ===== NAVBAR ===== */
.coffee-gradient { background: var(--brand); }
.navbar-btn {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .375rem .75rem; border-radius: .5rem; font-size: .8125rem; font-weight: 500;
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.15);
  transition: background .15s, border-color .15s; white-space: nowrap; cursor: pointer;
}
.navbar-btn:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.3); }
.navbar-btn-accent { background: #f59e0b; color: #1c1917; border-color: #f59e0b; }
.navbar-btn-accent:hover { background: #fbbf24; }

/* Sidebar container positioning */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: visible;
}

/* ===== SIDEBAR ===== */
.sidebar {
  transition: width .3s cubic-bezier(.4,0,.2,1);
  z-index: 40;
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 60%, #1d4ed8 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); width: 280px !important; transition: transform .3s cubic-bezier(.4,0,.2,1); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; opacity: 0; visibility: hidden; transition: all .3s ease; }
  .sidebar-overlay.active { opacity: 1; visibility: visible; }
}
@media (min-width: 768px) {
  .sidebar.collapsed { width: 4rem; }
  .sidebar.expanded { width: 16rem; }
}

/* Sidebar item */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .75rem;
  border-radius: .625rem;
  cursor: pointer;
  transition: background .2s, color .2s;
  position: relative;
  color: rgba(255,255,255,.7);
  overflow: hidden;
  margin: 1px 0;
}
.sidebar-item:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

/* Active state — left pill indicator via pseudo-element, no overflow */
.sidebar-item.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #fff;
}

.sidebar-item svg { flex-shrink: 0; width: 1.25rem; height: 1.25rem; transition: transform .2s; }
.sidebar-item:hover svg { transform: scale(1.1); }
.sidebar-item span {
  font-size: .875rem; font-weight: 500; white-space: nowrap;
  overflow: hidden; opacity: 1; transition: opacity .2s;
}

/* Collapsed state */
.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: .75rem;
  gap: 0;
}
.sidebar.collapsed .sidebar-item span { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-label { opacity: 0; width: 0; overflow: hidden; }

/* Tooltip — show on collapsed hover, hide on expanded */
.tooltip {
  visibility: hidden; opacity: 0;
  position: absolute; left: calc(100% + .625rem); top: 50%;
  transform: translateY(-50%);
  background: rgba(15,23,42,.92); color: #fff;
  padding: .375rem .75rem; border-radius: .5rem; font-size: .8125rem; white-space: nowrap;
  transition: opacity .15s; z-index: 1000; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.tooltip::before {
  content: '';
  position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent; border-right-color: rgba(15,23,42,.92);
}
/* Show tooltip only when collapsed */
.sidebar.collapsed .sidebar-item:hover .tooltip { visibility: visible; opacity: 1; }
/* Never show tooltip when expanded */
.sidebar.expanded .tooltip { display: none !important; }

/* Mobile: always show labels */
@media (max-width: 767px) {
  .sidebar-item { justify-content: flex-start !important; padding: .625rem .75rem !important; gap: .75rem !important; }
  .sidebar-item span { opacity: 1 !important; width: auto !important; }
  .sidebar-label { opacity: 1 !important; width: auto !important; }
  .tooltip { display: none !important; }
}

/* Group labels */
.sidebar-group-label { overflow: hidden; transition: opacity .2s; }
.sidebar.collapsed .sidebar-group-label { opacity: 0; height: 0; margin: 0; padding: 0; }

/* Sidebar handle — attached to sidebar edge, not fixed */
.sidebar-handle {
  position: absolute; right: -12px; top: 50%; transform: translateY(-50%);
  background: #1d4ed8; color: #fff; width: 12px; height: 48px;
  border-top-right-radius: 6px; border-bottom-right-radius: 6px;
  cursor: pointer; z-index: 45; box-shadow: 2px 0 8px rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, width .2s;
}
.sidebar-handle:hover { background: #2563eb; width: 14px; }
.sidebar.expanded .sidebar-handle { display: none; }

/* ===== BUTTONS ===== */
.btn-base {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  font-weight: 500; border-radius: .625rem; transition: all .15s; cursor: pointer;
  padding: .5rem 1rem; font-size: .875rem; border: none; line-height: 1.25;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid var(--border); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; box-shadow: 0 4px 12px rgba(5,150,105,.3); }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* Size variants */
.btn-sm { padding: .3125rem .625rem; font-size: .8125rem; border-radius: .5rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; border-radius: .75rem; }
.btn-icon { padding: .5rem; border-radius: .5rem; }

/* ===== INPUTS ===== */
.input-modern {
  width: 100%; padding: .625rem .875rem; font-size: .9375rem;
  border: 1.5px solid var(--border); border-radius: .625rem;
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.input-modern:focus { outline: none; border-color: var(--brand-light); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.input-modern::placeholder { color: #94a3b8; }
.input-error { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.1); }

/* Floating label inputs */
.field-wrap { position: relative; }
.field-wrap input, .field-wrap select, .field-wrap textarea {
  width: 100%; padding: 1.375rem .875rem .5rem;
  border: 1.5px solid var(--border); border-radius: .625rem;
  background: var(--surface); font-size: .9375rem; color: var(--text);
  transition: border-color .15s, box-shadow .15s; line-height: 1.5;
}
.field-wrap input:focus, .field-wrap select:focus, .field-wrap textarea:focus {
  outline: none; border-color: var(--brand-light); box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.field-wrap label {
  position: absolute; left: .875rem; top: .875rem; font-size: .9375rem; color: #94a3b8;
  pointer-events: none; transition: all .15s; font-weight: 400;
}
.field-wrap input:focus ~ label,
.field-wrap input:not(:placeholder-shown) ~ label,
.field-wrap select:focus ~ label,
.field-wrap textarea:focus ~ label,
.field-wrap textarea:not(:placeholder-shown) ~ label {
  top: .3125rem; font-size: .75rem; color: var(--brand-light); font-weight: 500;
}

/* ===== TABS ===== */
.tab-header { border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab-header-inner { display: flex; gap: .25rem; padding: 0 1.5rem; }
.tab {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .625rem 1rem; font-size: .875rem; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
  transition: color .15s, border-color .15s; background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--brand-light); }
.tab.tab-active { color: var(--brand-light); border-bottom-color: var(--brand-light); }
.tab-icon { width: 1rem; height: 1rem; }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.25rem; height: 1.25rem; padding: 0 .25rem;
  background: var(--brand-light); color: #fff; border-radius: 9999px; font-size: .6875rem; font-weight: 600;
}
.tab-content { display: none; padding: 1.25rem 1.5rem 1.5rem; }
.tab-content.active { display: block; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.page-header-icon {
  width: 2.5rem; height: 2.5rem; border-radius: .625rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.page-header-icon svg { width: 1.25rem; height: 1.25rem; color: #fff; }

/* ===== STAT CARDS ===== */
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.stat-icon {
  width: 3rem; height: 3rem; border-radius: .75rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 1.5rem; height: 1.5rem; }
.stat-label { font-size: .8125rem; color: var(--text-muted); font-weight: 500; margin-bottom: .125rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }

/* ===== LIST ITEMS ===== */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; border: 1px solid var(--border); border-radius: .625rem;
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.list-item:hover { border-color: #bfdbfe; box-shadow: 0 0 0 3px rgba(59,130,246,.06); }
.list-item-title { font-weight: 500; font-size: .9375rem; color: var(--text); }
.list-item-sub { font-size: .8125rem; color: var(--text-muted); margin-top: .125rem; }
.list-item-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* ===== SECTION HEADER ===== */
.section-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: .75rem; }
.section-label {
  display: inline-flex; align-items: center; gap: .375rem;
  font-size: .8125rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem;
}

/* ===== FORM SECTION ===== */
.form-section {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.form-section-title {
  font-size: .9375rem; font-weight: 600; color: var(--text); margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.form-section-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 700; color: #fff;
}

/* ===== PROGRESS ===== */
.progress-step {
  display: flex; align-items: center; justify-content: space-between;
  padding: .625rem .75rem; border-radius: .5rem; transition: background .15s;
}
.progress-step:hover { background: var(--surface-2); }
.progress-dot {
  width: 1.5rem; height: 1.5rem; border-radius: 9999px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .6875rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0;
  transition: all .2s;
}
.progress-dot.done { background: #059669; border-color: #059669; color: #fff; }

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 5rem; right: 1rem; z-index: 10000;
  min-width: 280px; max-width: 380px; padding: .875rem 1.125rem;
  border-radius: .75rem; color: #fff; font-weight: 500; font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); transform: translateX(420px);
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s; opacity: 0;
  display: flex; align-items: center; gap: .625rem;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { background: #059669; }
.toast.error { background: #ef4444; }
.toast.info { background: #2563eb; }
.toast.warning { background: #d97706; }

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn .25s ease; }
.slide-up { animation: slideUp .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== TOUR ===== */
.tour-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 9999; opacity: 0; visibility: hidden; transition: all .3s ease; }
.tour-overlay.active { opacity: 1; visibility: visible; }
.tour-spotlight { position: absolute; border-radius: 8px; box-shadow: 0 0 0 4px rgba(255,255,255,.8), 0 0 0 9999px rgba(0,0,0,.8); transition: all .3s ease; pointer-events: none; }
.tour-popover { position: absolute; background: #fff; border-radius: .75rem; padding: 1.5rem; max-width: 320px; box-shadow: 0 20px 40px -12px rgba(0,0,0,.25); z-index: 10000; transform: scale(.8) translateY(10px); opacity: 0; transition: all .3s cubic-bezier(.4,0,.2,1); }
.tour-popover.active { transform: scale(1) translateY(0); opacity: 1; }
.tour-popover::before { content: ''; position: absolute; width: 0; height: 0; border-style: solid; }
.tour-popover.top::before { bottom: -8px; left: 50%; transform: translateX(-50%); border-width: 8px 8px 0; border-color: #fff transparent transparent; }
.tour-popover.bottom::before { top: -8px; left: 50%; transform: translateX(-50%); border-width: 0 8px 8px; border-color: transparent transparent #fff; }
.tour-progress { position: fixed; top: 50%; right: 1.25rem; transform: translateY(-50%); background: #fff; border-radius: .75rem; padding: 1rem; box-shadow: 0 10px 25px -5px rgba(0,0,0,.25); z-index: 10001; }
.tour-step { width: 8px; height: 8px; border-radius: 50%; background: #e5e7eb; margin: 4px 0; transition: all .3s; }
.tour-step.active { background: #f59e0b; transform: scale(1.5); }
.tour-step.completed { background: #059669; }

/* ===== WELCOME MODAL ===== */
.welcome-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 9998; opacity: 0; visibility: hidden; transition: all .3s ease; }
.welcome-modal.active { opacity: 1; visibility: visible; }
.welcome-content { background: #fff; border-radius: 1rem; padding: 2rem; max-width: 500px; width: 90%; text-align: center; transform: scale(.9) translateY(20px); transition: all .3s cubic-bezier(.4,0,.2,1); }
.welcome-modal.active .welcome-content { transform: scale(1) translateY(0); }

/* ===== BEGINNER MODE ===== */
.beginner-mode .input-modern, .beginner-mode .field-wrap input { font-size: 1.05rem; }
.beginner-mode .btn-base { padding: .75rem 1.25rem; font-size: 1rem; }
.beginner-mode .tooltip { visibility: visible; opacity: 1; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== SPINNER ===== */
.spinner { border: 2px solid #e2e8f0; border-top-color: var(--brand-light); border-radius: 50%; width: 1.25rem; height: 1.25rem; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESULT BOXES ===== */
.result-box { border-radius: .75rem; padding: 1rem 1.25rem; }
.result-box-blue { background: #eff6ff; border: 1px solid #bfdbfe; }
.result-box-green { background: #f0fdf4; border: 1px solid #bbf7d0; }
.result-box-orange { background: #fff7ed; border: 1px solid #fed7aa; }
.result-box-purple { background: #faf5ff; border: 1px solid #e9d5ff; }
.result-box-title { font-size: .875rem; font-weight: 600; margin-bottom: .5rem; }
.result-box-blue .result-box-title { color: #1d4ed8; }
.result-box-green .result-box-title { color: #047857; }
.result-box-orange .result-box-title { color: #c2410c; }
.result-box-purple .result-box-title { color: #7c3aed; }

/* ===== MOBILE GRID ===== */
.mobile-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 1024px) { .mobile-grid.lg-two-cols { grid-template-columns: 1fr 1fr; } }
