/* BPLog Styles — Mobile-first PWA */
:root {
  --primary: #0d7377;
  --primary-dark: #095c5f;
  --danger: #c0392b;
  --warning: #f39c12;
  --success: #27ae60;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --border: #dee2e6;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --text: #c9d1d9;
  --muted: #8b949e;
  --border: #30363d;
  --shadow: 0 2px 8px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  overflow-x: hidden;
}

/* Layout */
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-wrap: wrap;
}
header .left { display:flex; align-items:center; gap:8px; flex:1 1 auto; min-width:0; }
header .title { font-weight: 700; font-size: 16px; color: var(--primary); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
header .title .version-badge { font-size: 9px; padding: 2px 5px; }
header .nav { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex:1 1 auto; }
header button.nav-btn {
  background: transparent; border: none; color: var(--muted); font-size: 11px; padding: 5px 7px; border-radius: 8px;
}
header button.nav-btn.active { background: #e6f4f4; color: var(--primary); font-weight: 600; }
[data-theme="dark"] header button.nav-btn.active { background: #0d2f2f; }

.header-meta { display:flex; align-items:center; gap:6px; }
.version-badge {
  font-size: 10px; font-weight: 600; color: var(--muted); background: var(--bg); border: 1px solid var(--border); padding: 3px 6px; border-radius: 999px; white-space: nowrap;
}
.version-badge.update { color: #b45309; background: #fef3c7; border-color: #fde68a; }
.version-badge.ok { color: #15803d; background: #dcfce7; border-color: #bbf7d0; }
[data-theme="dark"] .version-badge.update { color: #fbbf24; background: #422006; border-color: #713f12; }
[data-theme="dark"] .version-badge.ok { color: #4ade80; background: #052e16; border-color: #14532d; }

.offline-badge {
  font-size: 10px; font-weight: 700; color: #fff; background: var(--danger); padding: 3px 7px; border-radius: 999px; white-space: nowrap; display: none;
}
.offline-badge.active { display: inline-block; }

.user-dropdown {
  font-size: 12px; font-weight: 600; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}

main { flex: 1; padding: 16px; }
.screen { display: none; animation: fade .2s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius); padding: 12px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 44px; min-width: 44px; transition: transform .05s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 8px; }

/* Landing card */
.landing-card {
  background: linear-gradient(135deg, #e0f7fa 0%, #ffffff 100%);
  border: 1px solid #b2ebf2; border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
[data-theme="dark"] .landing-card {
  background: linear-gradient(135deg, #0d2f2f 0%, #161b22 100%);
  border-color: #14532d;
}
.landing-card h3 { margin: 0 0 6px; font-size: 15px; }
.landing-card p { margin: 0 0 8px; font-size: 13px; color: var(--text); }
.landing-card .btn { font-size: 13px; padding: 8px 12px; }

/* User selector */
.user-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.user-chip {
  flex: 0 0 auto; min-width: 90px; text-align: center; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--border); cursor: pointer;
}
.user-chip.active { border-color: var(--primary); box-shadow: 0 0 0 2px #c6e8e8; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; margin: 0 auto 6px; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.btn-delete-user {
  position: absolute; top: -4px; right: -4px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none; font-size: 12px; line-height: 1; cursor: pointer;
}

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 15px; background: var(--surface); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }

/* Home actions */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.action-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 12px; text-align: center; cursor: pointer;
}
.action-card .icon { font-size: 28px; margin-bottom: 6px; }
.action-card .label { font-weight: 700; font-size: 14px; }
.action-card .hint { font-size: 12px; color: var(--muted); }

/* Log header */
.log-header {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px;
}
.log-header strong { font-size: 14px; }
.log-header span { font-size: 12px; color: var(--muted); }

/* Entries */
.entry-row {
  display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; margin-bottom: 10px; cursor: pointer;
}
.entry-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--border); flex: 0 0 auto; }
.entry-body { flex: 1; min-width: 0; }
.entry-meta { font-size: 12px; color: var(--muted); }
.entry-values { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.badge {
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--border); color: var(--text);
}
.badge-normal { background: #d4edda; color: #155724; }
.badge-elevated { background: #fff3cd; color: #856404; }
.badge-stage1 { background: #ffeeba; color: #856404; }
.badge-stage2 { background: #f8d7da; color: #721c24; }
.badge-crisis { background: #721c24; color: #fff; }

/* Tags */
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 4px 8px; border-radius: 999px; background: #e9ecef; color: #495057;
}
[data-theme="dark"] .tag-chip { background: #30363d; color: #c9d1d9; }
.tag-chip button { background: transparent; border: none; font-size: 14px; line-height: 1; padding: 0; color: inherit; cursor: pointer; }

/* Filters */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar input, .filter-bar select { flex: 1; min-width: 140px; }

/* OCR preview */
.preview-wrap { text-align: center; margin: 12px 0; }
.preview-wrap img { max-width: 100%; border-radius: var(--radius); background: var(--border); }

/* Charts */
.chart-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; margin-bottom: 12px; }

/* Image manager */
.img-item { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.img-item input[type=checkbox] { width: 20px; height: 20px; }
.img-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--border); }

/* Modals / overlays */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.overlay.active { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius); max-width: 520px; width: 100%;
  max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* Empty states */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Utility */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-muted { color: var(--muted); font-size: 13px; }

/* Disclaimer */
.disclaimer-text { font-size: 13px; line-height: 1.5; color: var(--text); }
.disclaimer-text strong { color: var(--danger); }

/* Print view */
@media print {
  header, .no-print { display: none !important; }
  .screen { display: block !important; }
}


/* Accessibility — Category Color Pickers */
.color-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; padding: 6px; background: #f8f9fa; border-radius: 6px; }
.color-row label { font-size: 13px; min-width: 70px; font-weight: 600; }
.color-row input[type="color"] { width: 40px; height: 28px; border: none; padding: 0; cursor: pointer; }
.color-preview { padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }


/* Window Management — Minimize / Close */
.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-minimize {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 8px;
  margin-left: 8px;
}
.btn-minimize:hover {
  background: var(--bg);
  color: var(--text);
}

.card.collapsed > *:not(.card-title) {
  display: none !important;
}

.btn-screen-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.btn-screen-close:hover {
  background: var(--bg);
  color: var(--danger);
}

.screen {
  position: relative;
}

/* ---- Debug Console Drawer ---- */
.debug-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 140px;
  background: var(--surface);
  border-top: 2px solid var(--primary);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  font-family: monospace;
  font-size: 12px;
}
.debug-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
}
.debug-title { flex: 1; font-weight: 600; }
.debug-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.debug-btn:active { background: rgba(255,255,255,0.35); }
.debug-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  color: var(--text);
  line-height: 1.5;
}
.debug-body .log-entry { margin-bottom: 4px; word-break: break-word; }
.debug-body .log-time { opacity: 0.6; margin-right: 6px; }
.debug-body .log-error { color: var(--danger); }
.debug-body .log-warn { color: var(--warning); }
.debug-body .log-info { color: var(--primary); }
.debug-toggle {
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 10001;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
