/* ==========================================================
   BoneCare RSUD Haji : gaya tampilan
   Konsep: light-box radiologi (biru-es pucat) + tinta biru tua.
   Elemen utama: penggaris usia tulang (ruler gauge).
   ========================================================== */

:root {
  --ink: #0d2a3a;
  --ink-2: #2f4b5c;
  --muted: #637c8a;
  --line: #d5e1e8;
  --box: #f2f7fa;
  --paper: #ffffff;
  --teal: #0b8a7a;
  --teal-soft: #dff3ef;
  --amber: #b9780a;
  --amber-soft: #fdf0d4;
  --red: #b83a2e;
  --red-soft: #fbe3df;
  --sidebar: #0d2a3a;
  --radius: 10px;
  --font-head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--box);
  line-height: 1.55;
  font-size: 15px;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p + p { margin-top: .6rem; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ---------- Login ---------- */
.login {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.login-hero {
  background: var(--sidebar);
  color: #e6f1f5;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero h1 { font-size: 2.4rem; max-width: 14ch; color: #fff; }
.login-hero p { max-width: 38ch; color: #a9c4d0; margin-top: 1rem; }
.hero-ruler { margin-top: 2rem; }
.login-hero .brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-head); font-weight: 700; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: var(--teal);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.login-form-wrap { display: grid; place-items: center; padding: 2rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { margin-bottom: .3rem; }
.login-card .sub { color: var(--muted); margin-bottom: 1.2rem; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: #e3edf2; border-radius: 8px; padding: 3px; margin-bottom: 1.2rem; }
.seg button { border: 0; background: transparent; padding: .55rem; border-radius: 6px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(13,42,58,.15); }

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.field input, .field select {
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper);
}
.field input:focus, .field select:focus { border-color: var(--teal); }
.field .hint { font-size: .8rem; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1.1rem; border-radius: 8px; border: 1px solid transparent;
  background: var(--teal); color: #fff; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #087264; }
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--box); }
.btn.block { width: 100%; }
.btn.small { padding: .4rem .75rem; font-size: .85rem; }
.error-text { color: var(--red); font-size: .85rem; margin-bottom: .7rem; min-height: 1.2em; }
.demo-note { margin-top: 1.2rem; font-size: .82rem; color: var(--muted); background: var(--paper); border: 1px dashed var(--line); padding: .7rem .8rem; border-radius: 8px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar {
  background: var(--sidebar); color: #cfe0e8; padding: 1.4rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-head); font-weight: 700; color: #fff; padding: 0 .4rem; }
.sidebar .brand small { display: block; font-family: var(--font-body); font-weight: 400; color: #8fb0be; font-size: .72rem; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav button {
  text-align: left; background: transparent; border: 0; color: inherit; padding: .65rem .8rem;
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: .6rem;
}
.nav button:hover { background: rgba(255,255,255,.07); }
.nav button[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav .badge { margin-left: auto; background: var(--amber); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45rem; }
.sidebar-foot { margin-top: auto; font-size: .82rem; color: #9ab7c4; border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; }
.sidebar-foot strong { display: block; color: #fff; }
.sidebar-foot button { margin-top: .6rem; background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 6px; padding: .3rem .7rem; cursor: pointer; }

main { padding: 2rem 2.4rem 3rem; max-width: 980px; width: 100%; }
.page-head { margin-bottom: 1.4rem; }
.page-head p { color: var(--muted); margin-top: .3rem; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; }
.panel + .panel { margin-top: 1rem; }
.disclaimer {
  font-size: .85rem; color: var(--ink-2); background: var(--teal-soft);
  border-left: 4px solid var(--teal); padding: .7rem .9rem; border-radius: 6px; margin-top: 1rem;
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed #9db8c5; border-radius: var(--radius); background: var(--box);
  min-height: 150px; display: grid; place-items: center; text-align: center; padding: 1rem; cursor: pointer;
  color: var(--muted);
}
.dropzone:hover, .dropzone.drag { border-color: var(--teal); background: var(--teal-soft); }
.dropzone img { max-height: 220px; max-width: 100%; border-radius: 6px; background: #000; }
.dropzone input { display: none; }

/* ---------- Result + ruler ---------- */
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.patient-meta { color: var(--muted); font-size: .88rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 1.1rem 0; }
.stat { background: var(--paper); padding: .8rem 1rem; }
.stat span { display: block; font-size: .8rem; color: var(--muted); }
.stat strong { font-family: var(--font-head); font-size: 1.35rem; }

.status { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .8rem; border-radius: 999px; font-weight: 600; font-size: .88rem; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status.normal { background: var(--teal-soft); color: #066356; }
.status.watch { background: var(--amber-soft); color: #7d5006; }
.status.alert { background: var(--red-soft); color: #8e2a20; }
.status.pending { background: #e7edf1; color: var(--ink-2); }

.ruler { margin: 1.6rem 0 .6rem; padding-top: 2.2rem; }
.ruler-track {
  position: relative; height: 26px; border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, #9fb5c1 0 1px, transparent 1px calc(100% / 18)) bottom/100% 10px no-repeat,
    #e8f0f4;
  border: 1px solid var(--line);
}
.ruler-band { position: absolute; top: 0; bottom: 0; background: rgba(11,138,122,.22); border-left: 2px solid var(--teal); border-right: 2px solid var(--teal); }
.pin { position: absolute; top: -2.1rem; transform: translateX(-50%); text-align: center; font-size: .75rem; white-space: nowrap; font-weight: 600; }
.pin::after { content: ""; display: block; width: 2px; height: 1.65rem; margin: 2px auto 0; background: currentColor; }
.pin.chrono { color: var(--ink); }
.pin.bone.normal { color: var(--teal); }
.pin.bone.watch { color: var(--amber); }
.pin.bone.alert { color: var(--red); }
.ruler-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: .3rem; }
.ruler-legend { font-size: .8rem; color: var(--muted); margin-top: .5rem; }

.message-box { margin-top: .8rem; }
.verify-note { margin-top: .8rem; font-size: .88rem; color: var(--ink-2); }

/* ---------- Table / list ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty strong { display: block; color: var(--ink); margin-bottom: .3rem; font-family: var(--font-head); font-size: 1.05rem; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(13,42,58,.55); display: grid; place-items: center; padding: 1rem; z-index: 20; }
.modal { background: var(--paper); border-radius: 12px; padding: 1.5rem; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: min(640px, calc(100vh - 220px)); padding: 0; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .7rem; background: var(--box); }
.bubble { max-width: 78%; padding: .65rem .9rem; border-radius: 12px; font-size: .93rem; }
.bubble.bot { background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 3px; align-self: flex-start; }
.bubble.me { background: var(--ink); color: #fff; border-bottom-right-radius: 3px; align-self: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .7rem 1.2rem 0; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: .3rem .8rem; font-size: .82rem; cursor: pointer; }
.chip:hover { border-color: var(--teal); color: var(--teal); }
.chat-form { display: flex; gap: .6rem; padding: .8rem 1.2rem 1rem; }
.chat-form input { flex: 1; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px; }
.chat-foot { font-size: .75rem; color: var(--muted); padding: 0 1.2rem .8rem; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 8px; transition: .25s; pointer-events: none; z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 1.6rem; min-height: 280px; }
  .login-hero h1 { font-size: 1.8rem; }
  .shell { grid-template-columns: 1fr; padding-bottom: 64px; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 15;
    flex-direction: row; padding: .3rem; gap: 0; justify-content: space-around;
  }
  .sidebar .brand, .sidebar-foot > :not(button) { display: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .sidebar-foot button { margin: 0; padding: .5rem; }
  .nav { flex-direction: row; }
  .nav button { padding: .5rem .6rem; font-size: .8rem; flex-direction: column; gap: .15rem; text-align: center; }
  main { padding: 1.2rem 1rem 2rem; }
  .row { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Penyesuaian penggaris ---------- */
.ruler { padding: 4.2rem 3.6rem 0; margin: .4rem 0 1rem; }
.pin.below { top: -3.7rem; }
.pin.below::after { height: 3.2rem; }
.login-hero .ruler { padding-left: 3.4rem; padding-right: 3.4rem; }
.login-hero .ruler-track { background-color: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
.login-hero .pin.chrono { color: #fff; }
.login-hero .ruler-scale { color: #8fb0be; }
.hint { font-size: .8rem; color: var(--muted); }

/* ---------- Tinggi layar penuh ---------- */
#app { min-height: 100%; }
.login { min-height: 100vh; }
.login-hero h1 { max-width: 16ch; }
