/* ══════════════════════════════════════════════════════════════════════════
   Build Track — Playful Pastel Theme
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #FFF8F0;
  --bg-card: #ffffff;
  --bg-sidebar: #2d2d3f;
  --fg: #3d3d4e;
  --fg-muted: #8888a0;
  --fg-light: #b0b0c0;
  --accent: #ff79c6;
  --accent-light: #ffc0e0;
  --primary: #7c5cfc;
  --primary-light: #ede8ff;
  --success: #50c878;
  --success-light: #e0f5e8;
  --warning: #ffb347;
  --warning-light: #fff3e0;
  --danger: #ff6b6b;
  --danger-light: #ffe0e0;
  --border: #ede8e4;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: 220px;
  background: var(--bg-sidebar);
  color: #fff;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 2rem;
}

.logo-icon {
  font-size: 1.8rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-links {
  list-style: none;
  flex: 1;
}

.nav-links li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.nav-links li a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: translateX(4px);
}

.nav-links li.active a {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.nav-icon { font-size: 1.2rem; }

.nav-footer { margin-top: auto; }

.logout-btn {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* ── Main Content ────────────────────────────────────────────────────────── */

.content {
  flex: 1;
  margin-left: 220px;
  padding: 2rem;
  max-width: 1200px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--fg);
}

/* ── Stats Grid ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.3s ease;
  border: 1px solid var(--border);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.stat-icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-total .stat-icon { background: #ede8ff; }
.stat-month .stat-icon { background: #e0f5e8; }
.stat-onetime .stat-icon { background: #fff3e0; }
.stat-recurring .stat-icon { background: #e0f0ff; }
.stat-unpaid .stat-icon { background: #ffe0e0; }

.stat-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.02em;
}

/* ── Charts ──────────────────────────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--fg);
}

.chart-wide {
  margin-bottom: 2rem;
}

.chart-container {
  height: 260px;
  position: relative;
}

.chart-container-wide {
  height: 200px;
}

.chart-legend {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

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

.legend-emoji { font-size: 0.9rem; }
.legend-name { flex: 1; color: var(--fg-muted); }
.legend-value { font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: #6a4ae8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124,92,252,0.3);
}

.btn-secondary {
  background: var(--border);
  color: var(--fg);
}

.btn-secondary:hover {
  background: #ddd8d4;
}

.btn-full { width: 100%; justify-content: center; }

.btn-add {
  margin-bottom: 1rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.3rem;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
  opacity: 0.5;
}

.btn-icon:hover { opacity: 1; }

.btn-delete:hover { background: var(--danger-light); }

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  border: 2px dashed var(--accent-light);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-card h3 {
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-group-wide {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="month"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group select,
.login-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--fg);
  background: var(--bg);
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.login-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,92,252,0.15);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-top: 1.2rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.color-input {
  height: 40px;
  padding: 2px !important;
  cursor: pointer;
}

/* ── Table ────────────────────────────────────────────────────────────────── */

.table-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--bg);
}

th {
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  text-align: left;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

tr:last-child td { border-bottom: none; }

tr:hover { background: rgba(124,92,252,0.02); }
tr.row-editable { cursor: pointer; }
tr.row-editable:hover { background: rgba(124,92,252,0.06); }

.text-right { text-align: right; }

.item-name { font-weight: 600; }
.item-notes { font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.15rem; }

.amount { font-weight: 700; font-variant-numeric: tabular-nums; }

.date { color: var(--fg-muted); font-size: 0.85rem; white-space: nowrap; }

.vendor { color: var(--fg-muted); font-size: 0.85rem; }

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-paid {
  background: var(--success-light);
  color: #2d8a50;
}

.status-unpaid {
  background: var(--warning-light);
  color: #c47800;
}

/* ── Recurring ───────────────────────────────────────────────────────────── */

.recurring-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  transition: all 0.3s ease;
}

.recurring-card:hover {
  box-shadow: var(--shadow-hover);
}

.recurring-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.recurring-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.recurring-info h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.recurring-amount {
  font-weight: 700;
  color: var(--primary);
}

.recurring-vendor {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.recurring-notes {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.payment-grid h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.months-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

.month-cell {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.month-clickable { cursor: pointer; }

.month-clickable:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(124,92,252,0.15);
}

.month-paid {
  background: var(--success-light);
  border-color: var(--success);
}

.month-partial {
  background: var(--warning-light);
  border-color: var(--warning);
}

.month-name {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.month-status {
  font-size: 1.1rem;
  margin: 0.15rem 0;
}

.month-amount {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--fg);
}

/* ── Categories Grid ─────────────────────────────────────────────────────── */

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.category-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.category-card:hover {
  transform: translateX(4px);
}

.category-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.category-card-emoji { font-size: 1.4rem; }

.category-card-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.category-default-badge {
  font-size: 0.7rem;
  color: var(--fg-light);
  background: var(--bg);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */

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

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-card h3 {
  margin-bottom: 0.25rem;
}

.modal-subtitle {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.modal-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  justify-content: flex-end;
}

/* ── Login ────────────────────────────────────────────────────────────────── */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #FFF8F0 0%, #ede8ff 50%, #ffc0e0 100%);
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.1);
  text-align: center;
}

.login-icon {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: float 3s ease-in-out infinite;
}

.login-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--fg-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-input {
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1rem !important;
  padding: 0.8rem !important;
}

.alert {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
}

/* ── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--fg-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  animation: float 3s ease-in-out infinite;
}

.empty-state h3 {
  margin-bottom: 0.4rem;
  color: var(--fg);
}

.empty-state p {
  font-size: 0.9rem;
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */

.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-sidebar);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 4rem;
  }

  .mobile-nav-toggle {
    display: block;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .months-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .categories-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .months-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Utility Animations ──────────────────────────────────────────────────── */

[x-cloak] { display: none !important; }

.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}
