/* Kilat — Warung Credit Reminder via WhatsApp
   Design tokens and responsive mobile shell from WarungPay Reminder.html */

@import url('./fonts/fonts.css');

:root {
  --bg: oklch(97% 0.012 75);
  --bg2: oklch(93% 0.014 75);
  --card: oklch(100% 0.004 75);
  --text: oklch(18% 0.02 60);
  --text2: oklch(42% 0.018 65);
  --text3: oklch(62% 0.014 65);
  --primary: oklch(52% 0.18 175);
  --primary-light: oklch(94% 0.06 175);
  --primary-dark: oklch(40% 0.18 175);
  --amber: oklch(68% 0.18 72);
  --amber-light: oklch(95% 0.06 80);
  --red: oklch(56% 0.22 25);
  --red-light: oklch(95% 0.06 25);
  --border: oklch(88% 0.014 75);
  --wa-green: #25D366;
  --wa-dark: #128C7E;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;
}

[data-theme="dark"] {
  --bg: oklch(12% 0.01 200);
  --bg2: oklch(16% 0.01 200);
  --card: oklch(17% 0.012 200);
  --text: oklch(92% 0.008 75);
  --text2: oklch(72% 0.01 75);
  --text3: oklch(55% 0.01 75);
  --primary-light: oklch(25% 0.06 175);
  --amber-light: oklch(26% 0.06 80);
  --red-light: oklch(26% 0.06 25);
  --border: oklch(25% 0.01 200);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

#app {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  background: var(--card);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

@media (min-width: 481px) {
  body {
    padding: 16px 0;
    align-items: center;
  }
  #app {
    min-height: min(860px, 95dvh);
    max-height: 95dvh;
    border-radius: 32px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.16), 0 0 0 1px var(--border);
    overflow: hidden;
  }
}

button,
input,
select,
textarea,
.tap-target,
.btn-primary,
.btn-secondary {
  font-family: var(--font);
  min-height: 44px;
}

button {
  cursor: pointer;
}

.screen-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Primary Header (Teal) */
.hero-header {
  background: var(--primary);
  color: #fff;
  padding: 20px 18px 18px;
}

.step-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.16);
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.2;
  color: #fff;
}

.hero-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 4px;
}

/* Top Bar for subscreens */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.back-btn {
  background: var(--bg2);
  border: none;
  border-radius: 10px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.field-input:focus {
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 15px;
  padding: 13px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 10px oklch(52% 0.18 175 / 0.3);
  transition: transform 0.1s, opacity 0.15s;
  text-decoration: none;
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-secondary {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-wa {
  background: var(--wa-dark);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 211, 102, 0.3);
}

/* Risk Badges */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}

.risk-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.risk-Tinggi {
  background: var(--red-light);
  color: var(--red);
}
.risk-Tinggi .risk-dot {
  background: var(--red);
}

.risk-Sedang {
  background: var(--amber-light);
  color: var(--amber);
}
.risk-Sedang .risk-dot {
  background: var(--amber);
}

.risk-Rendah,
.risk-Lunas {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.risk-Rendah .risk-dot,
.risk-Lunas .risk-dot {
  background: var(--primary);
}

/* Bottom Navigation */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 10px;
  gap: 3px;
  background: none;
  border: none;
  min-height: 54px;
  color: var(--text3);
}

.bottom-nav-btn.active {
  color: var(--primary);
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.bottom-nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
}

/* Modal / Bottom Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.sheet-panel {
  width: 100%;
  max-width: 430px;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90dvh;
  overflow-y: auto;
}

/* Photo note thumbnails + full-screen viewer (v2) */
.photo-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0;
  background: var(--bg2);
  overflow: hidden;
  flex-shrink: 0;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.photo-viewer img {
  max-width: 100%;
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  border-radius: 12px;
}

.photo-viewer-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 398px;
}

/* Statistik: weekly bars drawn with divs (v2) */
.stats-bars {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  align-items: end;
  height: 140px;
}

.stats-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  min-width: 0;
}

.stats-bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--bg2);
  border-radius: 6px;
  overflow: hidden;
}

.stats-bar-fill {
  width: 100%;
  background: var(--amber);
  border-radius: 6px 6px 0 0;
  transition: height 0.3s;
}

.stats-bar-fill.current {
  background: var(--primary);
}

.stats-bar-label {
  font-size: 9px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Undo Toast */
.undo-toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 398px;
  background: oklch(20% 0.02 200);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  z-index: 90;
}

.undo-toast-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #5eead4;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 13px;
  min-height: 44px;
}

/* Bottom nav pinned on every screen (long screens like Settings used to push it off-screen). */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#app {
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
}
.undo-toast {
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}
