/* Font lokal */
@font-face { font-family: "Manrope"; src: url("/src/fonts/manrope-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/src/fonts/dm-sans-latin-wght-normal.woff2") format("woff2"); font-weight: 100 1000; font-style: normal; font-display: swap; }

:root {
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Alias agar pages.css memakai token yang sama dengan site.css */
  --text: var(--ink);
  --text-soft: var(--muted);
  --border: var(--line);
  --blue-pale: #e8f1ff;
  --page-bg: #f3f7fb;
  --surface: #f3f7fb;   /* dipakai pages.css sebagai latar abu muda di dalam kartu */
}

/* Ikon */
.ic { display: inline-flex; width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: 0 0 auto; }
.ic-svg { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.metric-icon .ic { width: 16px; height: 16px; }
.icon-button .ic, .menu-button .ic { width: 18px; height: 18px; }
.text-button .ic, .node-determining-tag .ic, td .ic { width: 14px; height: 14px; flex: 0 0 14px; }
td .ic { color: var(--blue); }
.chain-step-icon .ic { width: 18px; height: 18px; color: var(--blue); }
.feature-icon .ic, .flow-icon .ic { width: 24px; height: 24px; }
.menu-button { display: none; place-items: center; }

/* Satu gaya kartu untuk semua halaman */
.panel, .panel-full, .metric-card, .node-card, .reading-card, .mf-card, .rules-card,
.settings-card, .fan-visual-card, .fan-chain-card, .sim-inputs, .sim-results, .history-chart-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 5px 18px rgba(70, 107, 146, .04);
}

/* Sidebar: lebar penuh atau rel ikon */
:root { --sidebar-w: 252px; }
.dashboard-shell, .p2-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  transition: grid-template-columns .2s ease;
}
.sidebar {
  width: var(--sidebar-w);
  transition: width .2s ease, transform .25s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
}
.dashboard-main, .p2-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}


@media (max-width: 980px) {
  .dashboard-shell, .p2-shell { display: block; }
  .sidebar {
    width: 252px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 18px 0 45px rgba(43,70,100,.15);
    z-index: 50;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(15,34,57,.3);
    backdrop-filter: blur(2px);
    display: none;
  }
  .sidebar-backdrop.visible, .sidebar-backdrop.show { display: block; }
  .dashboard-main, .p2-main { margin-left: 0; width: 100%; }
  .menu-button { display: grid; place-items: center; }
}

/* Lencana status kuning */
.data-badge.warn { color: #956500; border-color: #f1e1b0; background: #fff8e1; }
.data-badge.warn i { background: #e7a21a; }

/* Penanda status berupa titik berwarna, bukan simbol */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Toast per jenis */
.toast > span .ic { width: 18px; height: 18px; }
.toast.toast-success > span { color: #16866f; background: #e5f8f2; }
.toast.toast-warn > span { color: #956500; background: #fff5dc; }
.toast.toast-error > span { color: #bd4054; background: #ffedf0; }

.fan-stage { display: grid; place-items: center; }
.fan-stage canvas { width: 176px; height: 176px; max-width: 100%; }
.pwm-readout { text-align: center; }
.pwm-readout span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.pwm-readout strong { display: block; margin-top: 4px; font: 800 44px/1 "Manrope"; letter-spacing: -.05em; }
.fan-visual-card.unavailable .pwm-readout strong, .decision-card.unavailable .pwm-readout strong { color: #94a3b8; }
.decision-note { min-height: 16px; margin: 0; text-align: center; color: #956500; font-size: 11px; line-height: 1.4; }
.chain-values { font-size: .8rem; color: var(--text-soft); margin-top: 2px; display: block; }

.mf-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.mf-box { background: var(--surface); padding: 1rem; border-radius: 10px; }
.mf-box strong { display: block; font-size: .85rem; margin-bottom: .5rem; color: var(--blue); }
.mf-box ul { margin: 0; padding-left: 1.2rem; font-size: .75rem; line-height: 1.6; }


/* Perbaikan Tahap 5b */
.ic > .ic-svg { width: 100%; height: 100%; vertical-align: top; }
.chain-step-icon { flex: 0 0 auto; display: inline-flex; }
.chain-step-icon .ic-svg { width: 20px; height: 20px; color: var(--blue); }
.chain-step-body { min-width: 0; }
.chain-step-body strong, .chain-values { overflow-wrap: anywhere; }
.decision-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rules-card, .panel-full, .settings-card { overflow-x: auto; }
.p2-topbar-right { flex-wrap: wrap; justify-content: flex-end; min-width: 0; }

/* Admin: banner mode manual, kontrol manual, halaman login */
[hidden] { display: none !important; }
.mode-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 24px; background: #fff4d8; border-bottom: 1px solid #f1dfae; color: #7a5200; font-size: 12px; }
.mode-banner strong { font: 800 12px "Manrope"; letter-spacing: .08em; }
.admin-controls { margin-top: 12px; display: grid; gap: 10px; }
.manual-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--text-soft); }
.manual-label strong { color: var(--text); font-weight: 800; }
#manual-slider { width: 100%; accent-color: var(--blue); }
.manual-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.control-safety-card p.admin-hint { margin: .6rem 0 0; font-size: .78rem; }
.admin-hint a { color: var(--blue); font-weight: 700; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); padding: 24px; display: grid; gap: 14px; }
.login-card h1 { margin: 0; font: 800 20px "Manrope"; letter-spacing: -.02em; }
.login-card label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: #536880; }
.login-card input { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; color: var(--ink); background: #fff; }
.login-card input:focus { outline: 2px solid #bcd6f2; border-color: var(--blue); }
.login-error { min-height: 16px; margin: 0; color: #bd4054; font-size: 12px; }
.login-back { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; }


/* Sidebar dashboard */
.sidebar-head { min-height: 44px; padding: 0 2px 0 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-brand { min-width: 0; padding: 0; }
.brand-logo-sidebar { height: 28px; }
.brand-logo-mark { display: none; height: 30px; }
.rail-toggle { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #4b6078; cursor: pointer; }
.rail-toggle:hover { color: var(--blue); border-color: #bcd6f2; background: var(--surface-soft); }
.rail-toggle .ic, .rail-toggle svg { width: 18px; height: 18px; flex: 0 0 18px; }

.sidebar-zone { margin: 18px 0 8px; padding: 12px 14px; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.sidebar-zone > span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-zone strong { margin-top: 4px; display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.sidebar-zone strong i { width: 8px; height: 8px; border-radius: 50%; background: #14b8a6; box-shadow: 0 0 0 3px #d7f7f3; }
.sidebar-zone small { color: var(--muted); font-size: 12px; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 18px 12px 6px; color: #7d90a8; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.nav-label:first-child { margin-top: 10px; }
.side-nav a { min-height: 42px; padding: 0 12px; border-radius: 10px; display: flex; align-items: center; gap: 12px; color: #4b6078; font-size: 14px; font-weight: 600; line-height: 1; transition: background .15s, color .15s; }
.side-nav a:hover { color: var(--blue); background: #f2f7ff; }
.side-nav a.active { color: var(--blue); background: #eaf3ff; font-weight: 700; }
.side-nav svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-nav a:first-of-type svg { fill: currentColor; stroke: none; }
.side-nav em { min-width: 22px; height: 22px; margin-left: auto; display: grid; place-items: center; border-radius: 7px; color: var(--blue); background: #dbeafe; font-size: 11px; font-weight: 700; font-style: normal; }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.sidebar-footer a { min-height: 40px; padding: 0 12px; border-radius: 10px; display: flex; align-items: center; gap: 12px; color: #4b6078; font-size: 13px; font-weight: 600; transition: background .15s, color .15s, border-color .15s; }
.sidebar-footer a:hover { color: var(--blue); background: #f2f7ff; }
.sidebar-footer .side-admin { border: 1px solid var(--line); background: #fff; }
.sidebar-footer .side-admin:hover { border-color: #bcd6f2; }
.sidebar-footer .ic, .sidebar-footer svg { width: 18px; height: 18px; flex: 0 0 18px; }

@media (min-width: 981px) {
  body.sidebar-collapsed { --sidebar-w: 72px; }
  body.sidebar-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
  body.sidebar-collapsed .sidebar-head { flex-direction: column; justify-content: center; gap: 12px; padding: 0; }
  body.sidebar-collapsed .brand-logo-sidebar { display: none; }
  body.sidebar-collapsed .brand-logo-mark { display: block; }
  body.sidebar-collapsed .sidebar-zone,
  body.sidebar-collapsed .side-nav a > span,
  body.sidebar-collapsed .side-nav a > em,
  body.sidebar-collapsed .sidebar-footer .lbl { display: none; }
  body.sidebar-collapsed .side-nav a,
  body.sidebar-collapsed .sidebar-footer a { justify-content: center; padding: 0; }
  body.sidebar-collapsed .nav-label { height: 1px; margin: 12px 10px; padding: 0; font-size: 0; background: var(--line); }
  body.sidebar-collapsed .side-nav { margin-top: 16px; }
}
