/* ============================================================
   VakilOS — Modern Dark Design System
   ============================================================ */

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --brand:       #6366f1;
  --brand-light: #818cf8;
  --brand-dim:   rgba(99,102,241,0.15);
  --surface-900: #0a0a0f;
  --surface-800: #111118;
  --surface-750: #16161f;
  --surface-700: #1c1c28;
  --surface-600: #242433;
  --surface-500: #2e2e42;
  --surface-400: #3d3d55;
  --border:      rgba(255,255,255,0.07);
  --border-hover:rgba(255,255,255,0.12);
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Light theme overrides */
html:not(.dark) {
  --surface-900: #f8fafc;
  --surface-800: #ffffff;
  --surface-750: #f8fafc;
  --surface-700: #f1f5f9;
  --surface-600: #e2e8f0;
  --surface-500: #cbd5e1;
  --surface-400: #94a3b8;
  --border:       rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.15);
  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;
}

body {
  background: var(--surface-900);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  background: var(--surface-800);
  border-right: 1px solid var(--border);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.logo-icon {
  background: linear-gradient(135deg, var(--brand) 0%, #8b5cf6 100%);
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 12px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.nav-item:hover {
  background: var(--surface-700);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--brand-dim);
  color: var(--brand-light);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--brand);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  background: var(--surface-600);
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all 0.15s;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { background: var(--brand-dim); color: var(--brand-light); }
.nav-icon-ai { background: rgba(139,92,246,0.15); color: #a78bfa; }
.nav-icon-fire { background: rgba(249,115,22,0.15); color: #fb923c; }

.nav-badge {
  margin-left: auto;
  background: var(--brand);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.nav-badge-red { background: #ef4444; }

.nav-pill {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(139,92,246,0.2);
  color: #a78bfa;
}
.nav-pill-fire { background: rgba(249,115,22,0.15); color: #fb923c; }

.sidebar-footer {
  background: var(--surface-700);
  border: 1px solid var(--border);
}

.avatar-ring {
  background: linear-gradient(135deg, var(--brand) 0%, #8b5cf6 100%);
  box-shadow: 0 0 0 2px var(--surface-800), 0 0 0 3px rgba(99,102,241,0.4);
}

/* Mobile sidebar */
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background: rgba(17,17,24,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

html:not(.dark) .topbar {
  background: rgba(248,250,252,0.85);
}

.search-bar {
  background: var(--surface-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.search-bar:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}

.topbar-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface-700);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.topbar-btn:hover { background: var(--surface-600); color: var(--text-primary); border-color: var(--border-hover); }

.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid var(--surface-800);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-hover); }

.stat-card {
  background: var(--surface-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(99,102,241,0.04));
  pointer-events: none;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99,102,241,0.3);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(99,102,241,0.1);
}

/* ── Stat Icon Boxes ──────────────────────────────────────── */
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-blue   { background: rgba(99,102,241,0.15);  color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
.badge-green  { background: rgba(16,185,129,0.12);  color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.badge-red    { background: rgba(239,68,68,0.12);   color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-yellow { background: rgba(245,158,11,0.12);  color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }
.badge-purple { background: rgba(139,92,246,0.15);  color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }
.badge-gray   { background: rgba(100,116,139,0.15); color: #94a3b8; border: 1px solid rgba(100,116,139,0.2); }
.badge-orange { background: rgba(249,115,22,0.12);  color: #fb923c; border: 1px solid rgba(249,115,22,0.2); }

/* Light mode badges */
html:not(.dark) .badge-blue   { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
html:not(.dark) .badge-green  { background: #ecfdf5; color: #059669; border-color: #a7f3d0; }
html:not(.dark) .badge-red    { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
html:not(.dark) .badge-yellow { background: #fffbeb; color: #d97706; border-color: #fde68a; }
html:not(.dark) .badge-purple { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
html:not(.dark) .badge-gray   { background: #f8fafc; color: #64748b; border-color: #e2e8f0; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background: var(--brand);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: #4f46e5;
  box-shadow: 0 4px 16px rgba(99,102,241,0.45);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-700);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all 0.15s;
}
.btn-secondary:hover {
  background: var(--surface-600);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--surface-700); color: var(--text-primary); }

/* ── Table ────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.data-table td:first-child { color: var(--text-primary); }
.data-table tr:hover td { background: var(--surface-750); }
.data-table tr:last-child td { border-bottom: none; }

/* ── Progress ─────────────────────────────────────────────── */
.progress-bar {
  height: 5px;
  background: var(--surface-600);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

/* ── AI Chat ──────────────────────────────────────────────── */
.ai-message {
  padding: 12px 15px;
  border-radius: 12px;
  max-width: 88%;
  font-size: 13.5px;
  line-height: 1.65;
}
.ai-message.bot {
  background: var(--surface-700);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.ai-message.user {
  background: linear-gradient(135deg, var(--brand) 0%, #8b5cf6 100%);
  color: white;
  border-bottom-right-radius: 4px;
  margin-left: auto;
  box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}

/* ── Timeline ─────────────────────────────────────────────── */
.timeline-item {
  position: relative;
  padding-left: 30px;
  padding-bottom: 22px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 9px; top: 22px; bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  position: absolute;
  left: 0; top: 4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--surface-800);
  box-shadow: 0 0 0 1px var(--border);
}

/* ── AI FAB ───────────────────────────────────────────────── */
.ai-fab {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--brand) 0%, #8b5cf6 100%);
  box-shadow: 0 8px 32px rgba(99,102,241,0.5), 0 0 0 1px rgba(99,102,241,0.3);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ai-fab:hover {
  box-shadow: 0 12px 40px rgba(99,102,241,0.65), 0 0 0 1px rgba(99,102,241,0.4);
  transform: translateY(-2px) scale(1.05);
}

/* ── Input / Select ───────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
select.input { cursor: pointer; }
textarea.input { resize: none; }

/* ── Divider ──────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Glow Accents ─────────────────────────────────────────── */
.glow-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.05) 100%);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.glow-card-orange {
  background: linear-gradient(135deg, rgba(249,115,22,0.08) 0%, rgba(239,68,68,0.05) 100%);
  border: 1px solid rgba(249,115,22,0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
}

/* ── Hearing Card ─────────────────────────────────────────── */
.hearing-card {
  background: var(--surface-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}
.hearing-card:hover { border-color: var(--border-hover); background: var(--surface-750); }
.hearing-card.urgent { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.04); }

/* ── Calendar Strip ───────────────────────────────────────── */
.cal-day {
  flex-shrink: 0;
  width: 52px;
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.cal-day:hover { background: var(--surface-700); border-color: var(--border); }
.cal-day.today {
  background: var(--brand);
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}

/* ── Court Simulator ──────────────────────────────────────── */
.judge-avatar {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--brand) 0%, #8b5cf6 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.speaking {
  animation: speakPulse 1.2s ease-in-out infinite;
}
@keyframes speakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4), 0 4px 20px rgba(99,102,241,0.4); }
  50%       { box-shadow: 0 0 0 12px rgba(99,102,241,0), 0 4px 20px rgba(99,102,241,0.4); }
}

/* ── Typing Dots ──────────────────────────────────────────── */
.typing-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--text-muted);
  border-radius: 50%;
  margin: 0 2px;
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp 0.22s ease forwards; }

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-700) 25%, var(--surface-600) 50%, var(--surface-700) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-500); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-400); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--surface-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: fadeUp 0.2s ease;
}

/* ── Knowledge Graph ──────────────────────────────────────── */
#kg-canvas { border-radius: var(--radius-lg); display: block; }

/* ── Page Title ───────────────────────────────────────────── */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Tag chips ────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99,102,241,0.12);
  color: #818cf8;
  border: 1px solid rgba(99,102,241,0.2);
}

/* ── Light mode card overrides ────────────────────────────── */
html:not(.dark) .card,
html:not(.dark) .stat-card,
html:not(.dark) .hearing-card,
html:not(.dark) .modal-box {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
html:not(.dark) .card:hover { border-color: #cbd5e1; }
html:not(.dark) .stat-card:hover { border-color: #a5b4fc; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
html:not(.dark) .glow-card { background: #eef2ff; border-color: #c7d2fe; }
html:not(.dark) .glow-card-orange { background: #fff7ed; border-color: #fed7aa; }
html:not(.dark) .input { background: #ffffff; border-color: #e2e8f0; color: #0f172a; }
html:not(.dark) .input::placeholder { color: #94a3b8; }
html:not(.dark) .input:focus { border-color: #6366f1; }
html:not(.dark) .btn-secondary { background: #f1f5f9; color: #334155; border-color: #e2e8f0; }
html:not(.dark) .btn-secondary:hover { background: #e2e8f0; color: #0f172a; }
html:not(.dark) .data-table th { color: #64748b; border-color: #e2e8f0; }
html:not(.dark) .data-table td { border-color: #f1f5f9; color: #334155; }
html:not(.dark) .data-table td:first-child { color: #0f172a; }
html:not(.dark) .data-table tr:hover td { background: #f8fafc; }
html:not(.dark) .ai-message.bot { background: #f1f5f9; border-color: #e2e8f0; color: #0f172a; }
html:not(.dark) .topbar-btn { background: #f1f5f9; border-color: #e2e8f0; color: #64748b; }
html:not(.dark) .topbar-btn:hover { background: #e2e8f0; color: #0f172a; }
html:not(.dark) .sidebar { background: #ffffff; border-color: #e2e8f0; }
html:not(.dark) .sidebar-footer { background: #f8fafc; border-color: #e2e8f0; }
html:not(.dark) .nav-item { color: #64748b; }
html:not(.dark) .nav-item:hover { background: #f1f5f9; color: #0f172a; }
html:not(.dark) .nav-item.active { background: #eef2ff; color: #4f46e5; }
html:not(.dark) .nav-icon { background: #f1f5f9; color: #64748b; }
html:not(.dark) .nav-item:hover .nav-icon,
html:not(.dark) .nav-item.active .nav-icon { background: #eef2ff; color: #4f46e5; }
html:not(.dark) .search-bar { background: #f1f5f9; border-color: #e2e8f0; }
html:not(.dark) .search-bar input { color: #0f172a; }
html:not(.dark) .search-bar input::placeholder { color: #94a3b8; }
html:not(.dark) .cal-day { color: #334155; }
html:not(.dark) .cal-day:hover { background: #f1f5f9; }
html:not(.dark) .hearing-card { background: #ffffff; border-color: #e2e8f0; }
html:not(.dark) .hearing-card:hover { background: #f8fafc; }
html:not(.dark) .hearing-card.urgent { background: #fef2f2; border-color: #fecaca; }
html:not(.dark) .progress-bar { background: #e2e8f0; }
html:not(.dark) .tag { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
html:not(.dark) body { background: #f8fafc; color: #0f172a; }
html:not(.dark) .modal-backdrop { background: rgba(15,23,42,0.5); }
html:not(.dark) .topbar { background: rgba(255,255,255,0.85); border-color: #e2e8f0; }
html:not(.dark) .page-title { color: #0f172a; }
html:not(.dark) .page-subtitle { color: #64748b; }
html:not(.dark) .nav-section-label { color: #94a3b8; }
html:not(.dark) .nav-badge { background: #4f46e5; }
html:not(.dark) .nav-pill { background: rgba(139,92,246,0.15); color: #7c3aed; }
