/* ============================================================
   DESIGN SYSTEM — Timesheet Pro
   ============================================================ */

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

:root {
  /* Colors */
  --bg-primary:    #0f1117;
  --bg-secondary:  #161b27;
  --bg-card:       #1e2434;
  --bg-hover:      #252d3d;
  --bg-input:      #1a2035;

  --border:        #2a3347;
  --border-light:  #334155;

  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;

  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-glow:   rgba(99,102,241,0.25);
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --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 32px rgba(0,0,0,0.6);
  --shadow-glow:   0 0 20px var(--accent-glow);

  --transition:    all 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: all 0.35s cubic-bezier(0.4,0,0.2,1);

  --sidebar-w:     260px;
  --topbar-h:      60px;
}

/* ---- Light theme ---- */
[data-theme="light"] {
  --bg-primary:    #f0f4f8;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-hover:      #e8eef5;
  --bg-input:      #f8fafc;

  --border:        #dde3ed;
  --border-light:  #c8d3e0;

  --text-primary:  #0f172a;
  --text-secondary:#4a5568;
  --text-muted:    #718096;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow:        0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
  --accent-glow:   rgba(99,102,241,0.18);
}

/* ---- Theme transition (smooth switching) ---- */
body, .topbar, .card, .modal, .modal-overlay,
.dropdown-menu, .form-input, .form-select,
.form-textarea, .toast, .stat-card, .badge,
.btn-secondary, .projects-sidebar, .calendar-area,
.calendar-cell, .sidebar-header {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.12s ease, box-shadow 0.25s ease;
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Typography ---- */
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: 0.95rem; font-weight: 600; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; border: none; transition: var(--transition);
  text-decoration: none; white-space: nowrap; user-select: none;
}
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-glow); }
.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-success {
  background: var(--success); color: #fff;
}
.btn-success:hover { background: #059669; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: inherit; font-size: 0.9rem; padding: 9px 12px;
  transition: var(--transition); width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); display: flex; align-items: center;
  justify-content: center; z-index: 1000; padding: 20px;
  opacity: 0; visibility: hidden; transition: var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px;
  max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px); transition: var(--transition);
}
.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-close {
  background: var(--bg-hover); border: none; color: var(--text-secondary);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; transition: var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---- Avatar ---- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 0.7rem; font-weight: 600;
}
.badge-admin  { background: rgba(99,102,241,0.2);  color: var(--accent); }
.badge-member { background: rgba(148,163,184,0.15); color: var(--text-secondary); }
.badge-danger { background: rgba(239,68,68,0.15);  color: var(--danger); }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h); background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  gap: 16px;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.1rem; text-decoration: none; color: inherit;
}
.topbar-brand .logo-icon {
  width: 32px; height: 32px; background: var(--accent);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 1rem;
}
.topbar-nav { display: flex; align-items: center; gap: 4px; margin-left: 24px; }
.topbar-nav a {
  padding: 6px 14px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500; transition: var(--transition);
}
.topbar-nav a:hover { color: var(--text-primary); background: var(--bg-hover); }
.topbar-nav a.active { color: var(--text-primary); background: var(--bg-card); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.topbar-user-name { font-size: 0.875rem; font-weight: 500; }

/* ---- Page layout ---- */
.page-content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}

/* ---- Toast ---- */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow-lg); min-width: 260px;
  animation: toast-in 0.3s ease forwards;
  font-size: 0.875rem;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes toast-in {
  from { opacity:0; transform: translateX(20px); }
  to   { opacity:1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity:1; }
  to   { opacity:0; transform: translateX(20px); }
}

/* ---- Utility ---- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-secondary); font-size: 0.875rem; }
.text-sm { font-size: 0.8rem; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---- Stat card ---- */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 2rem; font-weight: 800; }
.stat-sub { font-size: 0.78rem; color: var(--text-secondary); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: 8px;
}

/* ---- Chip ---- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px;
  font-size: 0.72rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.chip:hover { opacity: 0.8; filter: brightness(1.15); }

/* ---- Dropdown ---- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  min-width: 160px; box-shadow: var(--shadow-lg);
  z-index: 200; opacity: 0; visibility: hidden;
  transform: translateY(-6px); transition: var(--transition);
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 0.875rem; cursor: pointer; color: var(--text-primary);
  transition: var(--transition); text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.1); }

/* ---- Theme toggle button ---- */
.theme-toggle {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 10px;
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  color: var(--text-secondary); transition: var(--transition);
  white-space: nowrap;
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Color swatches ---- */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.color-swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: var(--transition);
}
.color-swatch.selected, .color-swatch:hover {
  border-color: #fff; transform: scale(1.15);
}

/* ---- Checkbox ---- */
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 0.9rem;
}
.checkbox-label input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}

/* ---- Page titles ---- */
.page-title    { font-size: 1.6rem; font-weight: 800; }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Misc ---- */
.opacity-50 { opacity: 0.5; }
