/* ============================================
   SICAKEP BERSAHABAT — Styles
   ============================================ */

* {
  font-family: 'DM Sans', sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --navy: #1e3a5f;
  --emerald: #10b981;
  --yellow: #fbbf24;
  --gray-bg: #f1f5f9;
  --error: #ef4444;
  --warn: #f59e0b;
  --info: #3b82f6;
  --vh: 1vh;
}

body {
  background: var(--gray-bg);
  color: #1e293b;
}

/* ---- Page transitions ---- */
.page {
  display: none;
  animation: fadeIn 0.3s ease;
}
.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Card ---- */
.card {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,.07),
              0 2px 4px -2px rgba(0,0,0,.05);
  padding: 1.5rem;
}

/* ---- Buttons ---- */
.btn {
  padding: .625rem 1.25rem;
  border-radius: .75rem;
  font-weight: 600;
  font-size: .875rem;
  cursor: pointer;
  border: none;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #15304f; }
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-emerald:hover { background: #059669; }
.btn-outline { background: transparent; border: 1.5px solid #cbd5e1; color: #475569; }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Input ---- */
.input {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid #e2e8f0;
  border-radius: .75rem;
  font-size: .875rem;
  transition: border-color .2s;
  background: #fff;
}
.input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30,58,95,.1);
}

/* ---- Sidebar ---- */
.sidebar {
  width: 260px;
  min-height: calc(100 * min(var(--vh, 1vh), 1vh));
  background: var(--navy);
  color: #fff;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  transition: transform .3s;
  overflow-y: auto;
}
.sidebar.collapsed {
  transform: translateX(-260px);
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  cursor: pointer;
  border-radius: .75rem;
  margin: 0 .75rem .25rem;
  transition: background .2s;
  font-size: .875rem;
}
.sidebar-item:hover,
.sidebar-item.active {
  background: rgba(255,255,255,.12);
}
.sidebar-item.active {
  background: rgba(255,255,255,.2);
  font-weight: 600;
}

/* ---- Main area ---- */
.main-area {
  margin-left: 260px;
  transition: margin-left .3s;
}
.main-area.full {
  margin-left: 0;
}

/* ---- Top header ---- */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- Badge ---- */
.badge {
  padding: .25rem .75rem;
  border-radius: 9999px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  padding: .875rem 1.25rem;
  border-radius: .75rem;
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  animation: slideInRight .3s ease;
  box-shadow: 0 8px 16px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  gap: .5rem;
  max-width: 360px;
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 1rem;
  max-width: 700px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: fadeIn .3s ease;
}

/* ---- Table ---- */
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  background: #f8fafc;
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}
td {
  padding: .75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: .875rem;
}
tr:hover td {
  background: #f8fafc;
}

/* ---- Score badge ---- */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 1.5rem;
  border-radius: .375rem;
  font-weight: 700;
  font-size: .75rem;
  padding: 0 .375rem;
}

/* ---- Calendar ---- */
.cal-day {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: .5rem;
  cursor: pointer;
  font-size: .8rem;
  position: relative;
  transition: all .15s;
}
.cal-day:hover { background: #e2e8f0; }
.cal-day.today { border: 2px solid var(--navy); }
.cal-day.has-entry::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--emerald);
}
.cal-day.selected { background: var(--navy); color: #fff; }
.cal-day.locked { opacity: .4; cursor: not-allowed; }

/* ---- Bottom nav (mobile) ---- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  z-index: 40;
  padding: .5rem 0;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  font-size: .65rem;
  color: #94a3b8;
  cursor: pointer;
  padding: .25rem 0;
}
.bottom-nav-item.active {
  color: var(--navy);
  font-weight: 600;
}

/* ---- Inline confirm ---- */
.inline-confirm {
  display: none;
  gap: .5rem;
  align-items: center;
}

/* ---- Streak flame animation ---- */
.streak-flame {
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

/* ---- Habit sections ---- */
.habit-section {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: .75rem;
  padding: 1rem;
  margin-bottom: .75rem;
}
.habit-section h4 {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.habit-section .score-display {
  font-size: .8rem;
  font-weight: 700;
  color: var(--navy);
  margin-left: auto;
  background: #eff6ff;
  padding: .25rem .5rem;
  border-radius: .375rem;
}

/* ---- Checkbox rows ---- */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem 0;
  font-size: .85rem;
}
.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--navy);
}
.checkbox-row.disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---- Dev cards ---- */
.dev-card {
  background: linear-gradient(135deg, #1e3a5f, #2d5a8e);
  border-radius: 1rem;
  padding: 1.5rem;
  color: #fff;
}
.dev-card .dev-label { font-size: .75rem; opacity: .7; }
.dev-card .dev-value { font-size: 1.5rem; font-weight: 700; }

/* ---- Period selector ---- */
.period-selector {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}
.period-btn {
  padding: .375rem .75rem;
  border-radius: .5rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #475569;
  transition: all .15s;
}
.period-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-area { margin-left: 0 !important; }
  .bottom-nav { display: flex; }
  .hide-mobile { display: none !important; }
}
