/* ============================================================
   MBH SOP Center — Design System
   Apple-style · Mobile First · MBH Care Identity
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #1a56db;
  --blue-700: #1e40af;
  --blue-900: #1e3a5f;

  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;

  --white: #ffffff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;

  /* Semantic */
  --bg:          var(--white);
  --bg-secondary: var(--gray-50);
  --bg-card:     var(--white);
  --text:        var(--gray-900);
  --text-sub:    var(--gray-500);
  --text-muted:  var(--gray-400);
  --border:      var(--gray-200);
  --accent:      var(--blue-600);
  --accent-light: var(--blue-50);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radius */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.04);

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Nav */
  --nav-h: 60px;
  --topbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Dark Mode ──────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0f172a;
    --bg-secondary: #1e293b;
    --bg-card:      #1e293b;
    --text:         #f1f5f9;
    --text-sub:     #94a3b8;
    --text-muted:   #64748b;
    --border:       #334155;
    --accent:       #60a5fa;
    --accent-light: rgba(96,165,250,.12);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
  }
}

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

html {
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea { font: inherit; }

/* ── App Shell ──────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page { display: none; flex-direction: column; min-height: 100dvh; }
.page.active { display: flex; }

/* Main content area (below topbar, above bottom nav) */
.page-body {
  flex: 1;
  padding-top: var(--topbar-h);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page-body.no-nav { padding-bottom: var(--space-6); }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(var(--white-rgb, 255,255,255), .88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: 100;
}

@media (prefers-color-scheme: dark) {
  .topbar { background: rgba(15,23,42,.88); }
}

.topbar-back {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 20px;
  transition: background .15s;
  flex-shrink: 0;
}
.topbar-back:active { background: var(--accent-light); }

.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font-display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-action {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 18px;
  transition: background .15s;
}
.topbar-action:active { background: var(--accent-light); }

/* ── Bottom Nav ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

@media (prefers-color-scheme: dark) {
  .bottom-nav { background: rgba(15,23,42,.92); }
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-top: 6px;
  color: var(--text-muted);
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--accent); }

.nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.nav-item.active .nav-icon { transform: scale(1.15); }

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .2px;
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-padded { padding: var(--space-4); }

/* ── Category Cards ─────────────────────────────────────── */
.kategori-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  padding: var(--space-4);
}

.kategori-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.kategori-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity .18s;
}

.kategori-card:active::before { opacity: .06; }
.kategori-card:active { transform: scale(.97); }

.kategori-emoji { font-size: 32px; line-height: 1; }

.kategori-nama {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.kategori-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── SOP List ───────────────────────────────────────────── */
.sop-list { display: flex; flex-direction: column; gap: 0; }

.sop-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: inherit;
}

.sop-item:last-child { border-bottom: none; }
.sop-item:active { background: var(--bg-secondary); }

.sop-emoji {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.sop-info { flex: 1; min-width: 0; }

.sop-judul {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sop-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sop-chevron {
  color: var(--text-muted);
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-blue   { background: var(--blue-50); color: var(--blue-700); }
.badge-green  { background: #ecfdf5; color: #065f46; }
.badge-yellow { background: #fffbeb; color: #92400e; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }

@media (prefers-color-scheme: dark) {
  .badge-blue   { background: rgba(96,165,250,.15); color: #93c5fd; }
  .badge-green  { background: rgba(16,185,129,.15); color: #6ee7b7; }
  .badge-yellow { background: rgba(245,158,11,.15); color: #fcd34d; }
  .badge-gray   { background: rgba(255,255,255,.08); color: var(--text-sub); }
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px var(--space-5);
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 600;
  transition: opacity .15s, transform .15s;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { opacity: .82; transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--white); }
.btn-secondary { background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-full { width: 100%; }
.btn-sm { padding: 8px var(--space-4); font-size: 13px; }

/* ── Form ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-label { font-size: 14px; font-weight: 600; color: var(--text); }

.form-input {
  width: 100%;
  padding: 13px var(--space-4);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-input::placeholder { color: var(--text-muted); }

/* ── Search ─────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  padding: var(--space-3) var(--space-4);
}

.search-input {
  width: 100%;
  padding: 11px var(--space-4) 11px 40px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
  background: var(--bg);
}

.search-icon {
  position: absolute;
  left: calc(var(--space-4) + 12px);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

/* ── SOP Reader ─────────────────────────────────────────── */
.sop-reader {
  padding: var(--space-5) var(--space-4);
  max-width: 680px;
  margin: 0 auto;
}

.sop-header { margin-bottom: var(--space-6); }

.sop-reader-emoji {
  font-size: 48px;
  margin-bottom: var(--space-3);
}

.sop-reader-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: var(--space-3);
}

.sop-reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.sop-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-5) 0;
}

/* Rich text content from Google Docs */
.sop-content { font-size: 15px; line-height: 1.75; color: var(--text); }
.sop-content h1 { font-size: 20px; font-weight: 700; margin: var(--space-6) 0 var(--space-3); }
.sop-content h2 { font-size: 17px; font-weight: 700; margin: var(--space-5) 0 var(--space-2); }
.sop-content h3 { font-size: 15px; font-weight: 700; margin: var(--space-4) 0 var(--space-2); }
.sop-content p  { margin-bottom: var(--space-4); }
.sop-content ul, .sop-content ol { padding-left: var(--space-5); margin-bottom: var(--space-4); }
.sop-content li { margin-bottom: var(--space-1); }
.sop-content strong { font-weight: 700; }
.sop-content em { font-style: italic; }
.sop-content table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-4); font-size: 14px; }
.sop-content th, .sop-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.sop-content th { background: var(--bg-secondary); font-weight: 600; }
.sop-content br { display: block; margin-bottom: var(--space-2); }

/* Reader navigation */
.sop-nav {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-top: var(--space-4);
}
.sop-nav .btn { flex: 1; font-size: 14px; }

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.login-hero {
  background: linear-gradient(160deg, var(--blue-900) 0%, var(--blue-600) 100%);
  padding: 60px var(--space-6) var(--space-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-logo {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.15);
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  margin-bottom: var(--space-4);
  backdrop-filter: blur(10px);
}

.login-brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.login-tagline {
  font-size: 14px;
  color: rgba(255,255,255,.7);
}

.login-form-wrap {
  flex: 1;
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

.login-form-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-1);
}

/* ── Section Header ─────────────────────────────────────── */
.section-header {
  padding: var(--space-4) var(--space-4) var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* ── Alert / Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  left: var(--space-4);
  right: var(--space-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 12px var(--space-4);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transform: translateY(8px);
  opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  pointer-events: all;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--success); }
.toast-danger  { background: var(--danger); }

/* ── Loading ────────────────────────────────────────────── */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-10);
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  gap: var(--space-3);
}

.empty-icon { font-size: 48px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text); }
.empty-desc  { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal-sheet {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--space-5) var(--space-5) calc(var(--space-5) + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,1,.23,1);
  max-height: 90dvh;
  overflow-y: auto;
}

.modal-overlay.open .modal-sheet { transform: translateY(0); }

.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: var(--r-full);
  margin: 0 auto var(--space-4);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: var(--space-4);
}

/* ── Admin Sidebar (tablet+) ────────────────────────────── */
@media (min-width: 768px) {
  .admin-layout {
    display: flex;
    min-height: 100dvh;
  }

  .admin-sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    padding: var(--space-6) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 50;
    overflow-y: auto;
  }

  .admin-main {
    margin-left: 240px;
    flex: 1;
    padding: var(--space-6);
  }

  .bottom-nav { display: none; }
  .page-body { padding-top: var(--space-4); padding-bottom: var(--space-6); }
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  margin-bottom: var(--space-4);
}

.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--white);
}

.sidebar-logo-text { font-weight: 700; font-size: 14px; line-height: 1.2; }
.sidebar-logo-sub  { font-size: 11px; color: var(--text-muted); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-item:hover { background: var(--bg-secondary); }
.sidebar-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sidebar-item .s-icon { font-size: 18px; }

/* ── Misc ───────────────────────────────────────────────── */
.divider { height: 8px; background: var(--bg-secondary); }

.fav-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), background .15s;
  -webkit-tap-highlight-color: transparent;
}
.fav-btn:active { transform: scale(.85); }
.fav-btn.active { color: #ef4444; }

.progress-read {
  height: 3px;
  background: var(--accent);
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: width .2s;
}

/* ── Animasi masuk halaman ──────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeSlideUp .3s cubic-bezier(.32,1,.23,1) forwards;
}

/* ── Disable teks selection di konten non-artikel ───────── */
.no-select { user-select: none; -webkit-user-select: none; }

/* Disable right click notice */
.disable-rc::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
}

/* ── Scrollbar custom (desktop) ─────────────────────────── */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
}
