/* ============================================================
   style.css — Global Foundation
   Daily Tracker — CSS Custom Properties + Core Components
   Design: Inter font, indigo accent, dark/light/system themes
   ============================================================ */

/* ─── Google Fonts Fallback Stack ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── CSS Custom Properties ────────────────────────────────────────────────── */
/* Dark Theme (default) */
:root,
[data-theme="dark"] {
  --bg:           #0f0f0f;
  --bg-card:      #1a1a1a;
  --bg-card-hover:#212121;
  --bg-input:     #1e1e1e;
  --border:       #2a2a2a;
  --border-focus: #3a3a3a;
  --text:         #f0f0f0;
  --text-muted:   #888888;
  --text-dim:     #555555;
  --accent:       #6366f1;   /* Overridden per-user via inline style */
  --accent-hover: #4f52d4;
  --accent-muted: rgba(99,102,241,0.15);
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --shadow:       0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.6);
  --radius:       16px;
  --radius-sm:    8px;
  --radius-pill:  100px;
  --sidebar-w:    240px;
  --sidebar-w-collapsed: 64px;
  --transition:   0.18s ease;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Light Theme */
[data-theme="light"] {
  --bg:           #f8f8f8;
  --bg-card:      #ffffff;
  --bg-card-hover:#f3f3f3;
  --bg-input:     #f0f0f0;
  --border:       #e4e4e4;
  --border-focus: #c8c8c8;
  --text:         #111111;
  --text-muted:   #666666;
  --text-dim:     #aaaaaa;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
}

/* ─── Reset + Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family:      var(--font);
  background-color: var(--bg);
  color:            var(--text);
  line-height:      1.6;
  min-height:       100vh;
  display:          flex;
  overflow-x:       hidden;
  transition:       background-color var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img, svg { display: block; max-width: 100%; }

/* ─── Layout: Sidebar + Main ────────────────────────────────────────────────── */
.sidebar {
  position:   fixed;
  top:        0; left: 0; bottom: 0;
  width:      var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display:    flex;
  flex-direction: column;
  z-index:    100;
  transition: width var(--transition);
  overflow:   hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .stat-label,
.sidebar.collapsed .stat-value,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-badge {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .sidebar-stats {
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
}

.main-content {
  margin-left:  var(--sidebar-w);
  flex:         1;
  min-height:   100vh;
  padding:      32px;
  transition:   margin-left var(--transition);
  max-width:    calc(100vw - var(--sidebar-w));
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-w-collapsed);
  max-width:   calc(100vw - var(--sidebar-w-collapsed));
}

/* ─── Sidebar Header ────────────────────────────────────────────────────────── */
.sidebar-header {
  display:     flex;
  align-items: center;
  justify-content: space-between;
  padding:     20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display:     flex;
  align-items: center;
  gap:         10px;
  color:       var(--text);
  font-weight: 700;
  font-size:   1.1rem;
  white-space: nowrap;
}

.logo-icon {
  color:      var(--accent);
  font-size:  1.3rem;
  flex-shrink: 0;
}

.sidebar-collapse-btn {
  background: none;
  border:     none;
  color:      var(--text-muted);
  cursor:     pointer;
  padding:    6px;
  border-radius: var(--radius-sm);
  display:    flex;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover { color: var(--text); background: var(--border); }

/* ─── Sidebar Stats (Streak + Wins) ─────────────────────────────────────────── */
.sidebar-stats {
  display:   flex;
  gap:       8px;
  padding:   16px;
  flex-shrink: 0;
}

.stat-pill {
  flex:        1;
  display:     flex;
  align-items: center;
  gap:         6px;
  background:  var(--bg-input);
  border:      1px solid var(--border);
  border-radius: var(--radius-pill);
  padding:     8px 12px;
  font-size:   0.8rem;
  white-space: nowrap;
  overflow:    hidden;
}

.stat-pill.streak-pill.active { border-color: var(--warning); }
.stat-value { font-weight: 700; font-size: 0.95rem; }
.stat-label { color: var(--text-muted); }

/* ─── Sidebar Navigation ────────────────────────────────────────────────────── */
.sidebar-nav {
  flex:    1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap:     2px;
}

.nav-item {
  display:     flex;
  align-items: center;
  gap:         12px;
  padding:     10px 12px;
  border-radius: var(--radius-sm);
  color:       var(--text-muted);
  font-size:   0.9rem;
  font-weight: 500;
  transition:  background var(--transition), color var(--transition);
  white-space: nowrap;
  position:    relative;
}

.nav-item:hover  { background: var(--bg-input); color: var(--text); }
.nav-item.active { background: var(--accent-muted); color: var(--accent); }
.nav-item svg    { flex-shrink: 0; width: 18px; height: 18px; }

.nav-divider {
  height:     1px;
  background: var(--border);
  margin:     8px 0;
}

.nav-badge {
  margin-left: auto;
  background:  var(--accent);
  color:       #fff;
  font-size:   0.7rem;
  font-weight: 700;
  padding:     2px 7px;
  border-radius: var(--radius-pill);
  min-width:   20px;
  text-align:  center;
}

/* ─── Sidebar Footer (User) ─────────────────────────────────────────────────── */
.sidebar-footer {
  display:     flex;
  align-items: center;
  gap:         8px;
  padding:     16px;
  border-top:  1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  flex:        1;
  display:     flex;
  align-items: center;
  gap:         10px;
  color:       var(--text);
  overflow:    hidden;
  min-width:   0;
}

.user-avatar {
  width:       36px;
  height:      36px;
  border-radius: 50%;
  background:  var(--accent);
  color:       #fff;
  display:     flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size:   0.9rem;
  flex-shrink: 0;
}

.user-info {
  display:    flex;
  flex-direction: column;
  overflow:   hidden;
  min-width:  0;
}

.user-name {
  font-size:   0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size:  0.72rem;
  color:      var(--text-muted);
}

.logout-btn {
  color:    var(--text-muted);
  padding:  8px;
  border-radius: var(--radius-sm);
  display:  flex;
  transition: color var(--transition);
  flex-shrink: 0;
}

.logout-btn:hover { color: var(--danger); }

/* ─── Page Header ────────────────────────────────────────────────────────────── */
.page-header {
  display:     flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap:   wrap;
  gap:         12px;
}

.page-title {
  font-size:   1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size:  0.9rem;
  color:      var(--text-muted);
  margin-top: 4px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display:     inline-flex;
  align-items: center;
  gap:         8px;
  padding:     10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size:   0.88rem;
  font-weight: 600;
  cursor:      pointer;
  border:      none;
  transition:  background var(--transition), color var(--transition),
               transform 0.1s ease, box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }
.btn svg    { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color:      #fff;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-ghost {
  background: transparent;
  color:      var(--text-muted);
  border:     1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color:      #fff;
}
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success {
  background: var(--success);
  color:      #fff;
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon {
  padding:       8px;
  background:    transparent;
  border:        none;
  color:         var(--text-muted);
  border-radius: var(--radius-sm);
  cursor:        pointer;
  display:       flex;
  transition:    background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-input); color: var(--text); }
.btn-icon svg   { width: 16px; height: 16px; }

/* ─── Form Elements ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

label {
  display:     block;
  font-size:   0.83rem;
  font-weight: 600;
  color:       var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="time"],
input[type="date"],
select,
textarea {
  width:        100%;
  padding:      11px 14px;
  background:   var(--bg-input);
  border:       1px solid var(--border);
  border-radius: var(--radius-sm);
  color:        var(--text);
  font-family:  var(--font);
  font-size:    0.9rem;
  outline:      none;
  transition:   border-color var(--transition), box-shadow var(--transition);
}

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

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

/* ─── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       24px;
}

.card-sm { padding: 16px; border-radius: var(--radius-sm); }

/* ─── Toast Notifications ────────────────────────────────────────────────────── */
.toast-container {
  position:  fixed;
  bottom:    24px;
  right:     24px;
  z-index:   9999;
  display:   flex;
  flex-direction: column;
  gap:       8px;
  pointer-events: none;
}

.toast {
  padding:       12px 18px;
  border-radius: var(--radius-sm);
  font-size:     0.88rem;
  font-weight:   500;
  color:         #fff;
  box-shadow:    var(--shadow-lg);
  opacity:       0;
  transform:     translateY(8px);
  transition:    opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
  max-width:     320px;
}

.toast.show       { opacity: 1; transform: translateY(0); }
.toast-success    { background: var(--success); }
.toast-error      { background: var(--danger); }
.toast-warning    { background: var(--warning); color: #1a1a1a; }
.toast-info       { background: var(--accent); }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position:       fixed;
  inset:          0;
  background:     rgba(0,0,0,0.7);
  z-index:        1000;
  display:        flex;
  align-items:    center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-box {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       28px;
  max-width:     420px;
  width:         90%;
  box-shadow:    var(--shadow-lg);
}

.modal-message {
  font-size:     0.95rem;
  margin-bottom: 20px;
  line-height:   1.6;
}

.modal-actions {
  display:         flex;
  gap:             10px;
  justify-content: flex-end;
}

/* ─── Badge ──────────────────────────────────────────────────────────────────── */
.badge {
  display:       inline-flex;
  align-items:   center;
  padding:       3px 9px;
  border-radius: var(--radius-pill);
  font-size:     0.72rem;
  font-weight:   600;
  letter-spacing: 0.03em;
}

.badge-high    { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-low     { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-success { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }

/* ─── Schedule Chip ──────────────────────────────────────────────────────────── */
.schedule-chip {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  padding:       3px 10px;
  border-radius: var(--radius-pill);
  font-size:     0.75rem;
  font-weight:   500;
  background:    var(--bg-input);
  border:        1px solid var(--border);
  color:         var(--text-muted);
  white-space:   nowrap;
}

/* ─── Divider ────────────────────────────────────────────────────────────────── */
.divider {
  height:     1px;
  background: var(--border);
  margin:     24px 0;
}

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-sm      { font-size: 0.83rem; }
.text-xs      { font-size: 0.75rem; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.w-full       { width: 100%; }

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding:    48px 24px;
  color:      var(--text-muted);
}

.empty-state-icon {
  font-size:     2.5rem;
  margin-bottom: 12px;
  opacity:       0.5;
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 260px;
  margin:    0 auto;
}

/* ─── 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(--border-focus); }

/* ─── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); }     to { opacity: 1; transform: scale(1); } }
@keyframes pulse   { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.animate-fade-in  { animation: fadeIn  0.2s ease forwards; }
.animate-scale-in { animation: scaleIn 0.2s ease forwards; }
