/* ==========================================================================
   SĀDH - UPSC Habit Tracker Design System
   "Small steps. Strong discipline."
   Crafted with care by NRW India (https://nrwone.in/)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Color Palette - Light Theme */
  --bg-page: #FAF7F2;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #F4F0E6;
  --bg-surface-subtle: #F0ECE0;
  
  --forest-900: #12241C;
  --forest-800: #1B382B; /* Primary Accent */
  --forest-700: #254A39;
  --forest-600: #335E4A;
  
  --sage-500: #577863;
  --sage-400: #769581;
  --sage-100: #EBF1EC;
  --sage-50: #F4F7F4;
  
  --gold-600: #A88134;
  --gold-500: #C5A059; /* Subtle Gold */
  --gold-100: #F7F2E6;
  --gold-50: #FCFAF5;
  
  --terracotta: #A64B3E; /* For overdue / warning */
  --terracotta-bg: #FBEFEF;
  --sky-blue: #3E6FA6;
  --sky-bg: #EFF5FB;

  /* Text Roles */
  --text-primary: #19241E;
  --text-secondary: #48594F;
  --text-muted: #798B81;
  --text-inverse: #FFFFFF;

  /* Hairline Borders */
  --border-light: rgba(27, 56, 43, 0.08);
  --border-subtle: rgba(27, 56, 43, 0.14);
  --border-focus: var(--forest-800);

  /* Shadows (Subtle, organic) */
  --shadow-sm: 0 1px 3px rgba(27, 56, 43, 0.04);
  --shadow-md: 0 4px 12px rgba(27, 56, 43, 0.06);
  --shadow-lg: 0 8px 24px rgba(27, 56, 43, 0.08);

  /* Dimensions & Radius */
  --sidebar-width: 256px;
  --bottom-nav-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Font Families */
  --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-page: #0E1410;
  --bg-surface: #151D18;
  --bg-surface-elevated: #1B261F;
  --bg-surface-subtle: #223028;

  --forest-900: #0B1611;
  --forest-800: #294E3D;
  --forest-700: #386751;
  --forest-600: #4B7F65;

  --sage-500: #7BA189;
  --sage-400: #97B7A2;
  --sage-100: #223228;
  --sage-50: #19241D;

  --gold-600: #C29E53;
  --gold-500: #D8B76E;
  --gold-100: #2A261B;
  --gold-50: #1F1C14;

  --terracotta: #D9695B;
  --terracotta-bg: #2B1816;
  --sky-blue: #6BA3DF;
  --sky-bg: #15222E;

  --text-primary: #EEF2EE;
  --text-secondary: #A3B5AA;
  --text-muted: #6E7F75;
  --text-inverse: #12241C;

  --border-light: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.14);
  --border-focus: var(--sage-400);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.2s ease;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 100%;
}

.app-content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Sidebar Components */
.sidebar-header {
  padding: 24px 20px 20px 20px;
  border-bottom: 1px solid var(--border-light);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--forest-800);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-500);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.sidebar-user-pill {
  margin: 16px 20px 0 20px;
  padding: 10px 12px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-pill-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--forest-800);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.user-names {
  line-height: 1.2;
}

.user-names .u-name {
  font-size: 0.82rem;
  font-weight: 600;
  display: block;
}

.user-names .u-stage {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 12px 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

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

.nav-item.active {
  background-color: var(--forest-800);
  color: #FFFFFF;
  font-weight: 600;
}

[data-theme="dark"] .nav-item.active {
  background-color: var(--forest-700);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--gold-100);
  color: var(--gold-600);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Top App Header */
.top-header {
  height: 64px;
  padding: 0 32px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.badge-gold {
  background-color: var(--gold-100);
  color: var(--gold-600);
  border: 1px solid rgba(197, 160, 89, 0.25);
}

.badge-sage {
  background-color: var(--sage-100);
  color: var(--sage-500);
  border: 1px solid rgba(87, 120, 99, 0.2);
}

.badge-terracotta {
  background-color: var(--terracotta-bg);
  color: var(--terracotta);
  border: 1px solid rgba(166, 75, 62, 0.2);
}

.badge-forest {
  background-color: var(--forest-800);
  color: #FFFFFF;
}

/* Standard Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-primary {
  background-color: var(--forest-800);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--forest-700);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Cards & Surfaces */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  border-color: var(--border-subtle);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Circular Progress Ring */
.progress-ring-container {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-circle-bg {
  stroke: var(--bg-surface-elevated);
}

.progress-ring-circle {
  stroke: var(--forest-800);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .progress-ring-circle {
  stroke: var(--sage-400);
}

.progress-ring-text {
  position: absolute;
  text-align: center;
}

.progress-ring-percent {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.progress-ring-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Habit List & Items */
.habits-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.habit-card:hover {
  border-color: var(--border-subtle);
  transform: translateY(-1px);
}

.habit-card.completed {
  background-color: var(--sage-50);
  border-color: rgba(87, 120, 99, 0.25);
}

[data-theme="dark"] .habit-card.completed {
  background-color: var(--bg-surface-elevated);
}

.habit-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.habit-checkbox {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: transparent;
  flex-shrink: 0;
}

.habit-card.completed .habit-checkbox {
  background: var(--forest-800);
  border-color: var(--forest-800);
  color: #FFFFFF;
  transform: scale(1.05);
}

[data-theme="dark"] .habit-card.completed .habit-checkbox {
  background: var(--sage-500);
  border-color: var(--sage-500);
}

.habit-info h4 {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.habit-card.completed .habit-info h4 {
  color: var(--text-muted);
  text-decoration: line-through;
}

.habit-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.habit-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--forest-800);
  box-shadow: 0 0 0 3px rgba(27, 56, 43, 0.1);
}

/* Pomodoro Timer Aesthetic */
.timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px;
  text-align: center;
}

.timer-modes {
  display: flex;
  background: var(--bg-surface-elevated);
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 4px;
  margin-bottom: 32px;
}

.timer-mode-btn {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.timer-mode-btn.active {
  background: var(--forest-800);
  color: #FFFFFF;
}

[data-theme="dark"] .timer-mode-btn.active {
  background: var(--sage-500);
}

.timer-display {
  font-family: var(--font-heading);
  font-size: 5.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
  margin: 16px 0 32px 0;
  font-variant-numeric: tabular-nums;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.timer-btn-primary {
  padding: 14px 44px;
  font-size: 1.1rem;
  border-radius: var(--radius-full);
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  z-index: 100;
  padding: 0 8px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.mobile-nav-items {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
}

.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  transition: color 0.15s ease;
  flex: 1;
  text-align: center;
}

.mobile-nav-link.active {
  color: var(--forest-800);
  font-weight: 700;
}

[data-theme="dark"] .mobile-nav-link.active {
  color: var(--sage-400);
}

.mobile-nav-link svg {
  width: 20px;
  height: 20px;
}

/* Mobile Drawer (More Menu) */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-drawer-overlay.open {
  display: block;
  opacity: 1;
}

.mobile-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 24px 20px calc(var(--bottom-nav-height) + 20px) 20px;
  z-index: 160;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.33, 1, 0.68, 1);
  max-height: 80vh;
  overflow-y: auto;
}

.mobile-drawer.open {
  transform: translateY(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.drawer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 8px;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.drawer-item svg {
  width: 22px;
  height: 22px;
  color: var(--forest-800);
}

[data-theme="dark"] .drawer-item svg {
  color: var(--sage-400);
}

/* Subtle Footer & Credit */
.app-footer {
  padding: 24px 32px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  margin-top: auto;
}

.app-footer a {
  color: var(--text-secondary);
  font-weight: 600;
  transition: color 0.15s ease;
}

.app-footer a:hover {
  color: var(--forest-800);
}

[data-theme="dark"] .app-footer a:hover {
  color: var(--sage-400);
}

/* PWA Install Banner */
.install-banner {
  background: linear-gradient(135deg, var(--forest-800) 0%, var(--forest-900) 100%);
  color: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.install-banner-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.install-banner-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  .app-sidebar {
    display: none;
  }
  .app-main {
    margin-left: 0;
  }
  .app-content {
    padding: 20px 16px calc(var(--bottom-nav-height) + 24px) 16px;
  }
  .top-header {
    padding: 0 16px;
  }
  .mobile-bottom-nav {
    display: block;
  }
  .app-footer {
    padding: 20px 16px calc(var(--bottom-nav-height) + 20px) 16px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* Micro-Celebration Canvas */
#celebration-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}
