/* ==========================================================================
   PRIA BANGKIT - Self Improvement OS
   Mobile-First Master Stylesheet (Vanilla CSS)
   Desain Padat, Rapi, Ergonomis, & Ringan untuk Penggunaan Handphone
   ========================================================================== */

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

:root {
  /* Dark Theme (Default) */
  --bg-main: #0a0e17;
  --bg-card: rgba(18, 25, 43, 0.92);
  --bg-card-hover: rgba(28, 38, 64, 0.96);
  --bg-input: #12192b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #a855f7;
  --cyan: #06b6d4;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --transition-fast: 0.18s ease;
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.4;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 74px; /* Space for bottom mobile nav */
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(59, 130, 246, 0.04), transparent 30%),
    radial-gradient(circle at 90% 90%, rgba(16, 185, 129, 0.03), transparent 30%);
  background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

/* Mobile-First Container */
.container {
  width: 100%;
  max-width: 640px; /* Mobile optimal width */
  margin: 0 auto;
  padding: 8px 10px;
}

@media (min-width: 768px) {
  .container {
    max-width: 820px;
    padding: 14px 18px;
  }
}

/* ==========================================================================
   HEADER & TOP APP BAR (Ultra-Compact)
   ========================================================================== */
.app-header {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
  flex-shrink: 0;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="light"] .brand-title {
  background: linear-gradient(135deg, #0f172a, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: var(--transition-fast);
}
.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

/* User Level & XP Progress (Compact Single Row) */
.level-badge-container {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.level-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  gap: 6px;
}

.level-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fbbf24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.level-meta .text-xs {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.68rem;
}

.xp-progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.xp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Quick Highlights Stat Row (Strict 3-Column Compact Grid) */
.stat-pill-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  transition: var(--transition-fast);
}

.stat-icon {
  display: none; /* Hide large icons on mobile for maximal space */
}

.stat-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.stat-label {
  font-size: 0.64rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-value {
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Urge / Panic Button (Slim Urgency Banner) */
.panic-btn-wrapper {
  margin-top: 8px;
}
.btn-panic {
  width: 100%;
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.3);
  transition: transform 0.12s ease;
}
.btn-panic:active {
  transform: scale(0.98);
}

/* Motivational Quote Strip (Compact 1-2 Lines) */
.quote-compact-strip {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.quote-icon-sm {
  font-size: 0.75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.quote-text-wrap {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.3;
}
.quote-author-inline {
  font-weight: 700;
  font-style: normal;
  color: var(--text-dim);
  margin-left: 4px;
}

/* Tabs Navigation (Desktop / Tablet Only) */
.tabs-nav {
  display: none; /* Mobile first: bottom nav is primary */
}

@media (min-width: 768px) {
  .tabs-nav {
    display: flex;
    gap: 6px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    overflow-x: auto;
  }
  .tab-btn {
    flex: 1;
    padding: 7px 12px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-xs);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-fast);
    white-space: nowrap;
  }
  .tab-btn.active {
    background: var(--primary);
    color: #fff;
  }
  .mobile-nav {
    display: none !important;
  }
  body {
    padding-bottom: 24px;
  }
}

/* Mobile Bottom Navigation (Ergonomic, Fixed) */
.mobile-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 14, 23, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 4px 6px;
  z-index: 99;
  justify-content: space-around;
  height: 54px;
}
[data-theme="light"] .mobile-nav {
  background: rgba(255, 255, 255, 0.96);
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.58rem;
  letter-spacing: -0.01em;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 1px;
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-xs);
  transition: var(--transition-fast);
}
.mobile-nav-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.mobile-nav-btn i {
  font-size: 1rem;
}
.mobile-nav-btn.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

/* ==========================================================================
   CARDS & COMPONENTS (Mobile Padat)
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}
.card-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Date Selector Bar (Compact) */
.date-selector-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 8px;
}
.date-title-box {
  text-align: center;
}
.date-title-main {
  font-size: 0.82rem;
  font-weight: 700;
}
.date-title-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Timers (Side-by-Side Compact) */
.timer-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}
.timer-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 8px;
  text-align: center;
}
.timer-title-sm {
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timer-digits {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: monospace;
  margin: 3px 0;
  color: var(--primary);
  line-height: 1.1;
}
.timer-controls {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.timer-controls .btn {
  padding: 3px 8px;
  font-size: 0.68rem;
}

/* Cigarette Counter Tracker (Compact Inline) */
.rokok-tracker {
  background: rgba(239, 68, 68, 0.04);
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.rokok-counter-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 6px 0;
}
.btn-counter {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rokok-count-display {
  font-size: 1.6rem;
  font-weight: 800;
  min-width: 44px;
  text-align: center;
  line-height: 1;
}
.rokok-status-pill {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Water Hydration Tracker (8 Glasses Clean Single Row) */
.water-tracker {
  background: rgba(6, 182, 212, 0.04);
  border: 1px solid rgba(6, 182, 212, 0.18);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.water-glasses-row {
  display: flex;
  gap: 4px;
  justify-content: space-between;
  margin-top: 6px;
}
.glass-btn {
  flex: 1;
  height: 34px;
  border-radius: 6px;
  border: 1px dashed rgba(6, 182, 212, 0.3);
  background: transparent;
  color: rgba(6, 182, 212, 0.4);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}
.glass-btn.filled {
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.35), #06b6d4);
  border-color: #06b6d4;
  color: white;
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.3);
}

/* Habit Checklist (Padat & Rapi) */
.habit-group {
  margin-bottom: 10px;
}
.habit-group-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
  padding-left: 2px;
}

.habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 7px 9px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.habit-item.completed {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.25);
}

.habit-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.habit-checkbox {
  width: 19px;
  height: 19px;
  border-radius: 5px;
  border: 1.5px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  background: transparent;
  color: transparent;
  font-size: 10px;
  flex-shrink: 0;
}
.habit-item.completed .habit-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.habit-text-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.habit-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.habit-item.completed .habit-name {
  color: var(--text-muted);
}
.habit-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.habit-badge {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 6px;
}
.habit-item.completed .habit-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 8px;
}
.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.form-control {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  outline: none;
}
.form-control:focus {
  border-color: var(--border-focus);
}
textarea.form-control {
  min-height: 54px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background: rgba(255, 255, 255, 0.06); color: var(--text-main); }
.btn-danger { background: var(--danger); color: white; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: var(--radius-full);
}
.badge-primary { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-outline { border: 1px solid var(--border-color); color: var(--text-muted); }

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
table.custom-table {
  width: 100%;
  border-collapse: collapse;
}
table.custom-table th {
  padding: 6px 8px;
  font-size: 0.68rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}
table.custom-table td {
  padding: 7px 8px;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-fast);
}
.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.modal-content {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 16px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
}

/* 4-7-8 Breathing Circle Animation (Compact) */
.breath-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 12px 0;
}
.breath-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.4), rgba(16, 185, 129, 0.2));
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  animation: breathe 19s infinite ease-in-out;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); border-color: #3b82f6; }
  21% { transform: scale(1.3); border-color: #10b981; }
  58% { transform: scale(1.3); border-color: #f59e0b; }
  100% { transform: scale(1); border-color: #3b82f6; }
}

/* Toast Messages */
#toastContainer {
  position: fixed;
  bottom: 60px;
  right: 12px;
  left: 12px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}
.toast-item.success { border-left: 3px solid var(--success); }
.toast-item.error { border-left: 3px solid var(--danger); }
.toast-item.info { border-left: 3px solid var(--primary); }

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-warning { color: var(--warning); }
.text-purple { color: var(--purple); }
.text-cyan { color: var(--cyan); }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 6px; }
