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

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

:root {
  --navy: #1e3a5f;
  --navy-light: #2563eb;
  --emerald: #22c55e;
  --yellow: #eab308;
  --gray-bg: #f8fafc;
  --error: #ef4444;
  --warn: #f59e0b;
  --info: #3b82f6;
  --vh: 1vh;
}

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

/* ---- Page transitions ---- */
.page {
  display: none;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.page.active {
  display: block;
}

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

/* ---- Card ---- */
.card {
  background: #fff;
  border-radius: 1.35rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.04), 
              0 4px 12px -2px rgba(0, 0, 0, 0.02);
  padding: 1.5rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 38px -6px rgba(0, 0, 0, 0.07), 
              0 8px 16px -3px rgba(0, 0, 0, 0.03);
  border-color: rgba(56, 189, 248, 0.35);
}

/* ---- Buttons ---- */
.btn {
  padding: .65rem 1.3rem;
  border-radius: .85rem;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  border: none;
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover {
  transform: translateY(-2px);
}
.btn-primary { 
  background: linear-gradient(135deg, #10b981 0%, #2563eb 100%); 
  color: #fff; 
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.22);
}
.btn-primary:hover { 
  background: linear-gradient(135deg, #16a34a 0%, #1d4ed8 100%); 
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}
.btn-emerald { 
  background: var(--emerald); 
  color: #fff; 
}
.btn-emerald:hover { 
  background: #16a34a; 
}
.btn-outline { 
  background: transparent; 
  border: 1.5px solid #cbd5e1; 
  color: #475569; 
}
.btn-outline:hover { 
  background: #f8fafc; 
  border-color: #cbd5e1;
}
.btn-danger { 
  background: var(--error); 
  color: #fff; 
}
.btn-danger:hover { 
  background: #dc2626; 
}
.btn:disabled { 
  opacity: .5; 
  cursor: not-allowed; 
  transform: none !important;
}

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

/* ---- Modern Harmonious Sidebar ---- */
.sidebar {
  width: 275px;
  min-height: calc(100 * min(var(--vh, 1vh), 1vh));
  background: #ffffff !important;
  color: #1e293b;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1), background .3s, border .3s;
  overflow-y: auto;
  border-right: 1px solid #e2e8f0 !important;
  box-shadow: 4px 0 24px -2px rgba(0,0,0,0.03) !important;
}
.sidebar.collapsed {
  transform: translateX(-275px);
}
.sidebar-header {
  border-bottom: 1px solid #f1f5f9;
}
.sidebar-logo-box {
  width: 44px;
  height: 44px;
  border-radius: .85rem;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #2563eb;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(37,99,235,0.12);
}
.sidebar-app-name {
  color: #0f172a !important;
}
.sidebar-school-name {
  color: #64748b !important;
}

/* Sidebar User Card */
.sidebar-user-card {
  margin: .75rem .75rem .5rem;
  padding: .75rem;
  border-radius: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  transition: all .3s;
}
.sidebar-user-card .user-name {
  font-weight: 700;
  font-size: .85rem;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge {
  margin-top: .25rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15rem .5rem;
  border-radius: .375rem;
  font-size: .65rem;
  font-weight: 700;
}
.role-badge.admin {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.2);
}
.role-badge.wali {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.role-badge.student {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.dark .role-badge.admin {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.dark .role-badge.wali {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.dark .role-badge.student {
  background: rgba(245, 158, 11, 0.2);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Sidebar Items in Light Mode */
.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  cursor: pointer;
  border-radius: .85rem;
  margin: 0 .75rem .35rem;
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: .875rem;
  color: #475569;
  font-weight: 600;
  border: 1px solid transparent;
  position: relative;
}
.sidebar-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: .65rem;
  background: #f1f5f9;
  color: #64748b;
  transition: all .25s ease;
  flex-shrink: 0;
}
.sidebar-item:hover {
  background: #f1f5f9;
  color: #0f172a;
  transform: translateX(3px);
  border-color: #e2e8f0;
}
.sidebar-item:hover .sidebar-icon-wrap {
  background: #e2e8f0;
  color: #2563eb;
  transform: scale(1.05);
}
.sidebar-item.active {
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  border: 1px solid #bfdbfe;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  font-weight: 700;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: -0.75rem;
  top: 18%;
  bottom: 18%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: #2563eb;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.4);
}
.sidebar-item.active .sidebar-icon-wrap {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: .85rem 1rem;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
}
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  border-radius: .75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.theme-toggle-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: .75rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #ef4444;
  cursor: pointer;
  transition: all .2s;
}
.logout-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ---- Main area ---- */
.main-area {
  margin-left: 275px;
  transition: margin-left .3s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 100vh;
  background: radial-gradient(circle at 15% 15%, rgba(34, 197, 94, 0.06) 0%, rgba(255, 255, 255, 0) 50%),
              radial-gradient(circle at 85% 85%, rgba(37, 99, 235, 0.06) 0%, rgba(255, 255, 255, 0) 50%),
              #f8fafc;
}
.main-area.full {
  margin-left: 0;
}

/* ---- Top header ---- */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- Badge ---- */
.badge {
  padding: .25rem .75rem;
  border-radius: 9999px;
  font-size: .65rem;
  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(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 1.5rem;
  max-width: 700px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  animation: fadeIn .3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ---- Table ---- */
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  background: #f8fafc;
  padding: .875rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}
td {
  padding: .875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: .875rem;
  color: #334155;
}
tr:hover td {
  background: #f8fafc;
}
.compact-table th {
  padding: .35rem .4rem !important;
  font-size: .68rem !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  white-space: nowrap;
}
.compact-table td {
  padding: .35rem .4rem !important;
  font-size: .75rem !important;
}

/* ---- Score badge ---- */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 1.6rem;
  border-radius: .5rem;
  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-light); }
.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-light); 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-light);
  font-weight: 600;
}

/* ---- Charts ---- */
.chart-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Table action buttons ---- */
.action-buttons {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}

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

/* ---- Gamified Grid & Cards ---- */
.gamified-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.habit-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}
.dark .habit-card {
  background: #1e293b;
  border-color: #334155;
}
.habit-card.expanded {
  border-color: var(--theme-color);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 0 0 3px rgba(0, 0, 0, 0.05);
}
.dark .habit-card.expanded {
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3), 0 0 0 3px rgba(255,255,255, 0.05);
}
.habit-card-header {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
}
.habit-icon-wrapper {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.habit-title {
  flex: 1;
  min-width: 0;
}
.habit-title h4 {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
  color: var(--navy);
}
.dark .habit-title h4 { color: #f1f5f9; }
.score-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.score-badge span {
  font-size: 0.85rem;
  margin-right: 0.125rem;
}
.expand-icon {
  width: 20px;
  height: 20px;
  color: #94a3b8;
  transition: transform 0.3s;
}
.habit-card.expanded .expand-icon {
  transform: rotate(180deg);
  color: var(--theme-color);
}
.habit-card-body {
  padding: 0 1.25rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.3s ease-in-out;
}
.habit-card.expanded .habit-card-body {
  padding: 0 1.25rem 1.25rem 1.25rem;
  max-height: 1200px;
  opacity: 1;
}

/* Animations */
@keyframes pop-anim {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.pop-anim {
  animation: pop-anim 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
@media (max-width: 768px) {
  .dashboard-grid, .grid-2col {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

/* ---- 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-light);
}
.checkbox-row.disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---- Dev cards ---- */
.dev-card {
  background: linear-gradient(135deg, var(--navy-light) 0%, var(--emerald) 100%);
  border-radius: 1.25rem;
  padding: 1.5rem;
  color: #fff;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.15);
}
.dev-card .dev-label { font-size: .75rem; opacity: .8; font-weight: 550; }
.dev-card .dev-value { font-size: 1.6rem; font-weight: 700; }

/* ---- Period selector ---- */
.period-selector {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}
.period-btn {
  padding: .4rem .9rem;
  border-radius: .75rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #475569;
  transition: all .25s ease;
}
.period-btn:hover {
  background: #f8fafc;
  color: #1e293b;
}
.period-btn.active {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* ---- Prevent horizontal overflow ---- */
html, body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---- Login background (single image + Ken Burns) ---- */
.login-bg-image {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  -webkit-animation: kenburns 25s ease-in-out infinite alternate;
  animation: kenburns 25s ease-in-out infinite alternate;
  will-change: transform;
}
@-webkit-keyframes kenburns {
  0%   { -webkit-transform: scale(1) translate(0, 0); transform: scale(1) translate(0, 0); }
  50%  { -webkit-transform: scale(1.08) translate(-1%, -1%); transform: scale(1.08) translate(-1%, -1%); }
  100% { -webkit-transform: scale(1.05) translate(1%, 0.5%); transform: scale(1.05) translate(1%, 0.5%); }
}
@keyframes kenburns {
  0%   { transform: scale(1) translate(0, 0); }
  50%  { transform: scale(1.08) translate(-1%, -1%); }
  100% { transform: scale(1.05) translate(1%, 0.5%); }
}

.login-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(30,58,95,.55) 0%, rgba(0,0,0,.45) 50%, rgba(16,185,129,.25) 100%);
  z-index: 1;
}

/* ---- Glassmorphism cross-browser ---- */
.glass-card {
  background: rgba(255,255,255,.15);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.2);
}

/* ---- Sidebar overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 39;
  -webkit-animation: fadeIn .3s ease;
  animation: fadeIn .3s ease;
}
.sidebar-overlay.show {
  display: block;
}

/* ---- Body scroll lock for modal ---- */
body.modal-open,
body.sidebar-open {
  overflow: hidden;
}

/* ---- Touch optimization ---- */
.btn, .sidebar-item, .bottom-nav-item, .cal-day, .period-btn, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---- Focus visible (keyboard navigation) ---- */
:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ---- Scrollbar styling ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    -webkit-animation-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    -webkit-animation-iteration-count: 1 !important;
    animation-iteration-count: 1 !important;
    -webkit-transition-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-275px); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-area { margin-left: 0 !important; }
  .bottom-nav { display: flex; padding-bottom: env(safe-area-inset-bottom, 0); padding-bottom: -webkit-env(safe-area-inset-bottom, 0); }
  .hide-mobile { display: none !important; }
  
  /* Penyesuaian padding & ukuran di HP */
  #mainContent { padding: .875rem; padding-bottom: 5.5rem; }
  .card { padding: .875rem; }
  .btn { padding: .5rem .875rem; font-size: .8rem; }
  .dev-card { padding: .875rem; }
  .dev-card .dev-value { font-size: 1.1rem; }
  .dev-card .dev-label { font-size: .65rem; }

  /* Tabel: scroll horizontal & pencegahan terpotong */
  .table-scroll-wrapper, div[style*="overflow-x:auto"], div[style*="overflow-x: auto"] { overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; margin: 0 -.875rem; padding: 0 .875rem; max-width: calc(100vw - 1.75rem); }
  table { width: 100%; display: table; }
  .table-scroll-wrapper table, div[style*="overflow-x:auto"] table, div[style*="overflow-x: auto"] table { min-width: 520px; }
  table th, table td { padding: .5rem .375rem; font-size: .75rem; white-space: nowrap; }
  
  /* Dev card grid: 2 kolom di mobile */
  .dev-stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: .75rem !important; }
  
  /* Week view: horizontal scroll */
  .week-view-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.875rem; padding: 0 .875rem; }
  .week-view-grid { min-width: 480px; }
  
  /* Stat cards: 1 kolom atau auto-fit di HP agar teks tidak terpotong */
  .stat-cards-grid { grid-template-columns: 1fr !important; gap: .75rem !important; }
  .stat-cards-grid .card { padding: .875rem; }
  .stat-cards-grid .progress-ring { width: 60px; height: 60px; }
  
  /* Live score summary */
  .live-score-grid { gap: .5rem !important; }
  .live-score-grid > div > div:first-child { font-size: .7rem; }
  .live-score-grid > div > div:last-child { font-size: 1.25rem; }
  
  /* Period selector: 2x2 grid di HP */
  .period-selector { display: grid !important; grid-template-columns: 1fr 1fr; gap: .375rem; }
  .period-btn { text-align: center; padding: .5rem .5rem; font-size: .75rem; }
  
  /* Period filter: proper wrapping & pencegahan overflow */
  .period-filter-row { gap: .6rem !important; flex-wrap: wrap !important; }
  .period-filter-row > div { flex: 1 1 140px !important; min-width: 140px !important; max-width: 100%; }
  .period-filter-row .input { width: 100% !important; box-sizing: border-box; }
  
  /* Profil grid: 1 kolom */
  .profile-grid { grid-template-columns: 1fr !important; }
  
  /* Header: compact mode */
  .top-header { padding: .5rem .75rem !important; }
  .top-header .badge { font-size: .6rem; padding: .2rem .5rem; }
  
  /* Habit form: max-width inputs full-width */
  .habit-section select.input,
  .habit-section input.input { max-width: 100% !important; }
  
  /* Calendar days: sedikit lebih kecil */
  .cal-day { width: 2.25rem; height: 2.25rem; font-size: .75rem; }
  
  /* Flex wrap helpers */
  .flex-wrap-mobile { flex-wrap: wrap !important; }
  .gap-sm-mobile { gap: .5rem !important; }
  
  /* Mencegah flex item (seperti tombol aksi di tabel) terlalu sempit */
  .action-buttons { flex-wrap: wrap; }
}

/* ---- Extra small screens (≤360px) ---- */
@media (max-width: 360px) {
  #mainContent { padding: .625rem; padding-bottom: 5.5rem; }
  .card { padding: .75rem; }
  .dev-card .dev-value { font-size: 1rem; }
  .dev-card .dev-label { font-size: .6rem; }
  .stat-cards-grid { grid-template-columns: 1fr !important; }
  .stat-cards-grid .card { padding: .5rem; }
  .period-btn { font-size: .7rem; padding: .375rem .375rem; }
  .cal-day { width: 2rem; height: 2rem; font-size: .7rem; }
  .bottom-nav-item { font-size: .6rem; }
  .live-score-grid > div > div:last-child { font-size: 1rem; }
}

/* ---- Medium-small screens (≤480px) ---- */
@media (max-width: 480px) {
  /* Login card: lebih compact */
  #loginPage .card { padding: 1.25rem; }
  #loginPage h1 { font-size: 22px !important; }
  #loginPage .btn { font-size: .8rem; }

  /* Filter inputs: stack vertikal */
  .filter-bar { flex-direction: column !important; }
  .filter-bar > * { width: 100% !important; max-width: 100% !important; }

  /* Tab bar: scrollable */
  .settings-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .settings-tabs > button { min-width: max-content; font-size: .7rem; padding: .5rem .625rem; }

  /* Modal: lebih compact */
  .modal-box { padding: 1rem; max-height: 85vh; }
  .modal-box .btn { font-size: .75rem; padding: .5rem .75rem; }
  .stat-cards-grid { grid-template-columns: 1fr !important; }
}

/* ---- Phone landscape mode ---- */
@media (orientation: landscape) and (max-height: 500px) {
  #loginPage { padding: 1rem 0; }
  #loginPage .card { padding: 1rem; max-width: 480px; }
  #loginPage h1 { font-size: 20px !important; margin-bottom: .5rem; }
  #loginPage [style*="margin-bottom:1.5rem"] { margin-bottom: .75rem !important; }
  .sidebar { width: 220px; }
  .sidebar.collapsed { transform: translateX(-220px); }
  .main-area { margin-left: 220px; }
  .main-area.full { margin-left: 0; }
  .bottom-nav { padding: .25rem 0; }
  .bottom-nav-item { font-size: .6rem; }
}

/* ---- Print styles ---- */
@media print {
  body { background: #fff !important; color: #000 !important; }
  .sidebar, .bottom-nav, .top-header, .toast-container,
  .modal-overlay, #loginPage, .btn { display: none !important; }
  .main-area { margin-left: 0 !important; }
  #mainContent { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd; break-inside: avoid; }
  table { font-size: 10pt; }
  a { text-decoration: none; color: inherit; }
}

/* ============================================
   SICAKEP BERSAHABAT — Landing Page Styles
   ============================================ */

html {
  scroll-behavior: smooth;
}

/* Smooth Transition for Theme Toggles */
body, nav, footer, .card, .btn, .sidebar, header, input, select, textarea {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Glassmorphism Classes */
.glass-nav {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ========================================================
   COMPREHENSIVE DARK MODE OVERRIDES & TEXT CLASH FIXES
   ======================================================== */

.dark body, html.dark {
  background-color: #0f172a !important; /* slate-900 */
  color: #f1f5f9 !important;
}

.dark .top-header {
  background-color: #1e293b !important; /* slate-800 */
  border-bottom-color: #334155 !important;
}

.dark .top-header h2 {
  color: #38bdf8 !important; /* sky-400 */
}

/* Fix inline navy or dark colors on text in dark mode */
.dark [style*="color:var(--navy)"],
.dark [style*="color: var(--navy)"],
.dark [style*="color:#1e3a5f"],
.dark [style*="color: #1e3a5f"],
.dark [style*="color:#0f172a"],
.dark [style*="color: #0f172a"],
.dark [style*="color:#1e293b"],
.dark [style*="color: #1e293b"],
.dark [style*="color:#334155"],
.dark [style*="color: #334155"] {
  color: #38bdf8 !important; /* sky blue */
}

/* Fix inline slate gray text colors */
.dark [style*="color:#475569"],
.dark [style*="color: #475569"],
.dark [style*="color:#64748b"],
.dark [style*="color: #64748b"] {
  color: #94a3b8 !important;
}

/* Fix inline white backgrounds in containers, panels, settings tabs */
.dark [style*="background:#fff"],
.dark [style*="background: #fff"],
.dark [style*="background:#ffffff"],
.dark [style*="background: #ffffff"],
.dark [style*="background:white"],
.dark [style*="background: white"],
.dark [style*="background-color:#fff"],
.dark [style*="background-color: #fff"],
.dark [style*="background:#f8fafc"],
.dark [style*="background: #f8fafc"] {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

/* Fix tabs containers and buttons in dark mode */
.dark .settings-tabs-container {
  background-color: #0f172a !important;
  border-color: #334155 !important;
}
.dark .settings-tabs-container button:not([style*="background:var(--navy)"]):not([style*="background: var(--navy)"]) {
  color: #94a3b8 !important;
}

/* Fix tables in dark mode */
.dark table th {
  background-color: #0f172a !important;
  color: #cbd5e1 !important;
  border-bottom-color: #334155 !important;
}
.dark table td {
  border-bottom-color: #334155 !important;
  color: #e2e8f0 !important;
}
.dark tr:hover td {
  background-color: rgba(51, 65, 85, 0.5) !important;
}

/* Fix form inputs, selects, textareas */
.dark .input, .dark input, .dark select, .dark textarea {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #fff !important;
}
.dark select option {
  background-color: #0f172a !important;
  color: #fff !important;
}
.dark .input:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15) !important;
}

/* Fix cards and modals */
.dark .card {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}
.dark .modal-box {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
  border: 1px solid #334155 !important;
}

/* Fix sidebar, main area and top header */
.dark .sidebar {
  background-color: #0f172a !important;
  border-right: 1px solid #334155 !important;
  color: #f8fafc;
}
.dark .sidebar-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
.dark .sidebar-logo-box {
  background: linear-gradient(135deg, rgba(255,255,255,.15), rgba(255,255,255,.05));
  border-color: rgba(255,255,255,.15);
  color: #fff;
}
.dark .sidebar-app-name {
  color: #fff !important;
}
.dark .sidebar-school-name {
  color: #94a3b8 !important;
}
.dark .sidebar-user-card {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}
.dark .sidebar-user-card .user-name {
  color: #fff;
}
.dark .sidebar-item {
  color: #94a3b8;
}
.dark .sidebar-icon-wrap {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
}
.dark .sidebar-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.08);
}
.dark .sidebar-item:hover .sidebar-icon-wrap {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.dark .sidebar-item.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(99, 102, 241, 0.3) 100%);
  border: 1px solid rgba(96, 165, 250, 0.4);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
  color: #fff;
}
.dark .sidebar-item.active .sidebar-icon-wrap {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
}
.dark .sidebar-footer {
  border-top-color: rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.95);
}
.dark .theme-toggle-btn {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
}
.dark .theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.dark .logout-btn {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.dark .logout-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}
.dark .main-area {
  background: radial-gradient(circle at 15% 15%, rgba(34, 197, 94, 0.08) 0%, rgba(15, 23, 42, 0) 50%),
              radial-gradient(circle at 85% 85%, rgba(56, 189, 248, 0.08) 0%, rgba(15, 23, 42, 0) 50%),
              #0f172a !important;
}
.dark .top-header {
  background: rgba(15, 23, 42, 0.85) !important;
  border-bottom: 1px solid #334155 !important;
}

/* Fix Tailwind text utilities inside dark containers */
.dark .text-slate-900, .dark .text-slate-800, .dark .text-gray-900, .dark .text-gray-800, .dark .text-black {
  color: #f8fafc !important;
}
.dark .text-slate-700, .dark .text-gray-700 {
  color: #e2e8f0 !important;
}
.dark .text-slate-600, .dark .text-gray-600 {
  color: #cbd5e1 !important;
}

/* Fix landing page / card white utilities in dark mode */
.dark .bg-white {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}
.dark .bg-slate-50, .dark .bg-gray-50 {
  background-color: #0f172a !important;
  color: #f1f5f9 !important;
}
.dark .bg-slate-100 {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}

/* Lucide animation for float keyframe */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-15px); }
}

.animate-float {
  animation: float 6s ease-in-out infinite;
}

.animate-float-delayed {
  animation: float 6s ease-in-out infinite 3s;
}

/* Custom shadow/borders for card highlights */
.dark .border-slate-100 {
  border-color: #334155 !important;
}
.dark .bg-slate-50\/50 {
  background-color: rgba(15, 23, 42, 0.4) !important;
}
.dark .bg-slate-50\/20 {
  background-color: rgba(15, 23, 42, 0.2) !important;
}

/* ---- File Inputs ---- */
input[type="file"].input {
  cursor: pointer;
  line-height: 1;
}
input[type="file"].input::file-selector-button {
  background: var(--navy-light);
  border: none;
  border-radius: 0.375rem;
  color: white;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
}
input[type="file"].input::file-selector-button:hover {
  background: var(--navy);
}

/* ---- Floating Points & Celebration Toast ---- */
@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(0.8); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translate(-50%, -150px) scale(1.3); opacity: 0; }
}
.floating-points {
  position: absolute;
  font-weight: 900;
  font-size: 2.2rem;
  color: #10b981;
  pointer-events: none;
  animation: floatUp 2.5s cubic-bezier(0.25, 1, 0.50, 1) forwards;
  z-index: 99999;
  text-shadow: 0 4px 8px rgba(0,0,0,0.25), 0 0 2px rgba(255,255,255,0.8);
}
.celebration-toast {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1.5px solid #10b981;
  padding: 0.75rem 1.25rem;
  border-radius: 1rem;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  transform: translateY(20px) scale(0.9);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
}
.dark .celebration-toast {
  background: rgba(30, 41, 59, 0.95);
  border-color: #10b981;
}
.celebration-toast.active {
  transform: translateY(0) scale(1);
  opacity: 1;
}
@media (max-width: 640px) {
  .celebration-toast {
    bottom: 5.5rem;
    right: 50%;
    transform: translate(50%, 20px) scale(0.9);
  }
  .celebration-toast.active {
    transform: translate(50%, 0) scale(1);
  }
}

/* Custom Responsive Grid Classes */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) {
  .grid-2-col {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

