/* ============================================================
   Capably — style.css
   Palette: Dark Slate + Teal (light & dark mode)
   ============================================================ */

/* ===== Light mode variables (default) ===== */
:root {
  /* Brand */
  --primary:       #1e2d3d;
  --primary-light: #0d9488;
  --primary-dark:  #152232;
  --accent:        #0d9488;
  --accent-hover:  #0f766e;

  /* Semantic */
  --success: #059669;
  --danger:  #dc2626;
  --warning: #d97706;
  --info:    #2563eb;

  /* Surfaces */
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;
  --border:    #dde3ea;

  /* Text */
  --text:       #1a1d23;
  --text-muted: #6b7280;

  /* Sidebar */
  --sidebar-bg:      #1e2d3d;
  --sidebar-nav-bg:  #243447;
  --sidebar-active:  rgba(13,148,136,0.18);
  --sidebar-hover:   rgba(255,255,255,0.07);
  --sidebar-accent:  #0d9488;

  /* Shadows */
  --shadow:    0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.11);

  /* Radii */
  --radius:    10px;
  --radius-lg: 16px;

  /* Font */
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ===== Dark mode overrides ===== */
[data-theme="dark"] {
  --bg:        #0f1923;
  --surface:   #1a2535;
  --surface-2: #223044;
  --border:    #2e4060;

  --text:       #e2e8f0;
  --text-muted: #8fa3b8;

  --primary:       #0d9488;
  --primary-light: #14b8a6;
  --primary-dark:  #0f766e;

  --sidebar-bg:      #0f1923;
  --sidebar-nav-bg:  #152232;
  --sidebar-active:  rgba(13,148,136,0.22);
  --sidebar-hover:   rgba(255,255,255,0.06);
  --sidebar-accent:  #14b8a6;

  --shadow:    0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; transition: color-scheme 0.2s; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--sidebar-accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo h1 {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: white;
}
.sidebar-logo span { font-size: 11px; opacity: 0.6; display: block; }

.sidebar-nav {
  flex: 1;
  padding: 14px 0;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  padding: 10px 20px 4px;
  margin-top: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active {
  background: var(--sidebar-active);
  color: white;
  border-left-color: var(--sidebar-accent);
}
.nav-item .icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item i    { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }

/* Card icon style used in sidebar nav with FA icons */
.card-icon { color: var(--primary-light); margin-right: 2px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info { margin-bottom: 10px; }
.user-info .name { font-size: 13px; font-weight: 600; color: white; }
.user-info .role {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  text-transform: capitalize;
}
.btn-logout {
  width: 100%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.8);
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.16); color: white; }

/* ===== Main Content ===== */
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: background 0.25s;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background 0.25s, border-color 0.25s;
}
.topbar h2 { font-size: 20px; font-weight: 700; color: var(--text); }
.topbar .date { font-size: 13px; color: var(--text-muted); }

/* Topbar right side — date + dark mode toggle */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Dark mode toggle button */
.dm-toggle {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.dm-toggle:hover {
  background: var(--primary-light);
  color: white;
  border-color: var(--primary-light);
}

.page { padding: 28px 32px; display: none; }
.page.active { display: block; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-light);
  transition: background 0.25s, box-shadow 0.25s;
}
.stat-card.accent  { border-left-color: var(--accent); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.purple  { border-left-color: #7c3aed; }
.stat-card.warning { border-left-color: var(--warning); }

.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .icon { font-size: 17px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===== Chart containers ===== */
.chart-container { position: relative; height: 280px; }
.chart-container.tall { height: 360px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }

thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  transition: background 0.25s;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.25s;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* Sortable column headers */
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { background: var(--surface-2); color: var(--primary-light); }
.sortable-th .fa-sort-up,
.sortable-th .fa-sort-down { color: var(--primary-light); }
.sortable-th .fa-sort { color: var(--border); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-teal   { background: #ccfbf1; color: #0f766e; }

[data-theme="dark"] .badge-blue   { background: #1e3a6e; color: #93c5fd; }
[data-theme="dark"] .badge-green  { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-yellow { background: #4a2f0a; color: #fcd34d; }
[data-theme="dark"] .badge-purple { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .badge-red    { background: #4c0519; color: #fca5a5; }
[data-theme="dark"] .badge-gray   { background: #1f2937; color: #9ca3af; }
[data-theme="dark"] .badge-teal   { background: #0f3d38; color: #5eead4; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 13px; font-weight: 600; color: var(--text); }

input, select, textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.25s, color 0.25s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.15);
}
textarea { resize: vertical; min-height: 80px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-light); }

/* In dark mode, --primary becomes teal so btn-primary still works */
[data-theme="dark"] .btn-primary { background: var(--primary-light); }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-dark); }

.btn-teal {
  background: var(--accent);
  color: white;
}
.btn-teal:hover { background: var(--accent-hover); }

.btn-outline {
  background: transparent;
  color: var(--primary-light);
  border: 1px solid var(--primary-light);
}
.btn-outline:hover { background: var(--primary-light); color: white; }

[data-theme="dark"] .btn-outline {
  color: #5eead4;
  border-color: #5eead4;
}
[data-theme="dark"] .btn-outline:hover {
  background: var(--primary-light);
  color: white;
}

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #243447 60%, #0d9488 100%);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}

.login-card .logo { text-align: center; margin-bottom: 32px; }
.login-card .logo-icon-lg {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
}
.login-card h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-card p  { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.login-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}
.login-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
  transition: all 0.15s;
}
.login-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.login-form .form-group { margin-bottom: 16px; }
.btn-login { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 8px; }

.login-toggle { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.login-toggle a { color: var(--primary-light); cursor: pointer; text-decoration: none; }

/* ===== Messages ===== */
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.success-msg {
  background: #d1fae5;
  color: #065f46;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
[data-theme="dark"] .error-msg   { background: #4c0519; color: #fca5a5; }
[data-theme="dark"] .success-msg { background: #064e3b; color: #6ee7b7; }

/* ===== Progress bars ===== */
.progress-bar-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.progress-label { font-size: 12px; color: var(--text-muted); min-width: 40px; text-align: right; }

/* ===== Year bar pills ===== */
.year-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.year-pill {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.year-pill:hover { border-color: var(--primary-light); color: var(--primary-light); }
.year-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
[data-theme="dark"] .year-pill.active {
  background: var(--primary-light);
  border-color: var(--primary-light);
}

/* ===== Month pill ===== */
.month-pill {
  display: inline-block;
  padding: 3px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
[data-theme="dark"] .month-pill { background: var(--primary-light); }

/* ===== Leaderboard ===== */
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.leaderboard-item:last-child { border-bottom: none; }
.rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.rank-1 { background: #fef3c7; color: #92400e; }
.rank-2 { background: #f1f5f9; color: #475569; }
.rank-3 { background: #fce7f3; color: #9d174d; }
.rank-n { background: var(--surface-2); color: var(--text-muted); }
.leaderboard-name  { flex: 1; font-size: 14px; font-weight: 600; }
.leaderboard-hours { font-size: 14px; font-weight: 700; color: var(--primary-light); }
.leaderboard-bar   { width: 80px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--text);
  color: var(--surface);
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 320px;
}
.toast.show    { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); color: white; }
.toast.error   { background: var(--danger);  color: white; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar select, .filter-bar input { min-width: 140px; }

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p    { font-size: 15px; }
.empty-state i    { font-size: 40px; display: block; margin-bottom: 12px; opacity: 0.5; }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; display: block; }

/* ===== Tag editor (settings) ===== */
.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: grab;
  transition: border-color 0.12s;
}
.tag-item.drag-over  { border-color: var(--primary-light); }
.tag-item.dragging   { opacity: 0.4; }
.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
}
.tag-remove:hover { color: var(--danger); }

/* ===== Score ring (reports) ===== */
.score-ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.score-ring-wrap .ring-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== 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); }

/* ===== Print ===== */
@media print {
  .sidebar, .topbar, .btn, button, .filter-bar, .year-bar, .dm-toggle { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page { padding: 0 !important; }
  .page.active { display: block !important; }
  body { background: white !important; color: black !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-240px); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .topbar { padding: 14px 16px; }
}