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

/* ═══════════════════════════════════════════════
   DESIGN TOKENS — Dark Theme (default)
═══════════════════════════════════════════════ */
:root {
  /* Accent palette — Indigo (default) */
  --accent-h: 239;
  --accent-s: 84%;
  --accent-l: 67%;
  --accent:        hsl(var(--accent-h), var(--accent-s), var(--accent-l));
  --accent-dim:    hsl(var(--accent-h), var(--accent-s), 30%);
  --accent-glow:   hsl(var(--accent-h), var(--accent-s), var(--accent-l), 0.25);
  --accent-subtle: hsl(var(--accent-h), var(--accent-s), var(--accent-l), 0.08);

  /* Backgrounds */
  --bg-root:    #07070f;
  --bg-surface: #0e0e1a;
  --bg-card:    rgba(255,255,255,0.034);
  --bg-hover:   rgba(255,255,255,0.06);
  --bg-input:   rgba(255,255,255,0.05);
  --bg-sidebar: rgba(10,10,20,0.95);

  /* Borders */
  --border:       rgba(255,255,255,0.08);
  --border-focus: var(--accent);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #8b92a8;
  --text-muted:     #4a5168;
  --text-inverse:   #0e0e1a;

  /* Status colors */
  --green:  #10b981;
  --yellow: #f59e0b;
  --red:    #ef4444;
  --blue:   #3b82f6;
  --purple: #8b5cf6;
  --orange: #f97316;

  --green-dim:  rgba(16,185,129,0.15);
  --yellow-dim: rgba(245,158,11,0.15);
  --red-dim:    rgba(239,68,68,0.15);
  --blue-dim:   rgba(59,130,246,0.15);

  /* Priority colors */
  --priority-high:     #ef4444;
  --priority-standard: #6366f1;

  /* Sizing */
  --sidebar-w:  240px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 24px var(--accent-glow);

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-std:  0.25s ease;
  --t-slow: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light theme overrides */
[data-theme="light"] {
  --bg-root:    #f0f2f8;
  --bg-surface: #ffffff;
  --bg-card:    rgba(255,255,255,0.85);
  --bg-hover:   rgba(0,0,0,0.04);
  --bg-input:   rgba(0,0,0,0.04);
  --bg-sidebar: rgba(248,249,255,0.98);
  --border:       rgba(0,0,0,0.09);
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow:    0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.15);
}

/* Accent palette presets */
[data-accent="cyan"]    { --accent-h: 189; --accent-s: 94%; --accent-l: 43%; }
[data-accent="emerald"] { --accent-h: 158; --accent-s: 64%; --accent-l: 52%; }
[data-accent="amber"]   { --accent-h:  43; --accent-s: 96%; --accent-l: 56%; }
[data-accent="rose"]    { --accent-h: 347; --accent-s: 77%; --accent-l: 60%; }
[data-accent="violet"]  { --accent-h: 263; --accent-s: 70%; --accent-l: 60%; }
[data-accent="indigo"]  { --accent-h: 239; --accent-s: 84%; --accent-l: 67%; }

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--t-std), color var(--t-std);
}

/* ═══════════════════════════════════════════════
   LAYOUT — Shell
═══════════════════════════════════════════════ */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform var(--t-std);
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-glow);
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
  flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
}

.nav-item.active .nav-badge {
  background: var(--accent);
  color: var(--text-inverse);
}

/* Projects list in sidebar */
.sidebar-projects {
  padding: 4px 0;
}

.sidebar-project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  margin-bottom: 1px;
}

.sidebar-project-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-project-item.active { background: var(--accent-subtle); color: var(--accent); }

.sidebar-project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-project-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ─── Main content ─── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* prevent wide content (e.g. zoomed Gantt canvas) from stretching the whole page instead of scrolling internally */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-std);
}

/* Sidebar collapsed states for desktop */
body.sidebar-collapsed #sidebar {
  transform: translateX(-100%);
}
body.sidebar-collapsed #main {
  margin-left: 0;
}

/* ─── Topbar ─── */
#topbar {
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Page content ─── */
#content {
  flex: 1;
  min-width: 0; /* same flex min-content fix as #main, applied at this level too */
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

/* ═══════════════════════════════════════════════
   TYPOGRAPHY
═══════════════════════════════════════════════ */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
h3 { font-size: 14px; font-weight: 600; }
h4 { font-size: 13px; font-weight: 600; }

.text-sm  { font-size: 12px; }
.text-xs  { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.font-mono { font-family: 'Courier New', monospace; }

/* ═══════════════════════════════════════════════
   GRID UTILS
═══════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px)  {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px)  {
  :root { --sidebar-w: 0px; }
  #sidebar { 
    transform: translateX(-100%); 
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open #sidebar { 
    transform: translateX(0); 
  }
  body.sidebar-open #sidebar-overlay {
    display: block !important;
  }
  #main { margin-left: 0 !important; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  #content { padding: 16px; }
}

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

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

/* ═══════════════════════════════════════════════
   FORM ELEMENTS
═══════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

textarea { resize: vertical; min-height: 80px; }

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  padding: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--accent-glow);
  transition: box-shadow var(--t-fast);
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px var(--accent-glow);
}
input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
input[type="range"]:disabled::-webkit-slider-thumb {
  background: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* ═══════════════════════════════════════════════
   LOADING STATES
═══════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ═══════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-ring {
  0%   { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.animate-in { animation: fadeIn 0.3s ease forwards; }
.animate-slide { animation: slideIn 0.25s ease forwards; }
.animate-scale { animation: scaleIn 0.2s ease forwards; }

/* Page transition */
.page-enter { animation: fadeIn 0.3s ease forwards; }

/* ═══════════════════════════════════════════════
   EMPTY STATES
═══════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 8px;
}

.empty-state h3 {
  color: var(--text-secondary);
  font-size: 16px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 300px;
}

/* ═══════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
