/* ============================================================
   Ezechiel Material - demo UI
   Aesthetic: dark "data terminal", hairline borders, acid-lime
   brand accent, semantic colours reserved for risk/stock states.
   ============================================================ */

:root {
  --bg: #0a0c0f;
  --surface: #121519;
  --surface-2: #171b21;
  --surface-3: #1d222a;
  --line: #262b34;
  --line-soft: #1b2026;

  --text: #e8eaed;
  --text-dim: #99a1ac;
  --text-faint: #626b76;

  --brand: #c6f24e;       /* acid lime - brand only, non-semantic */
  --brand-ink: #0a0c0f;
  --brand-soft: rgba(198, 242, 78, 0.12);

  --slate: #5b7089;       /* purchase series (neutral) */
  --emerald: #34d399;     /* lancar / aman */
  --amber: #fbbf24;       /* lambat / waspada */
  --rose: #fb7185;        /* macet / kritis */

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 24px -16px rgba(0, 0, 0, 0.8);

  --font-display: 'Clash Display', system-ui, sans-serif;
  --font-sans: 'Satoshi', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* atmospheric depth: subtle radial glow + grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60rem 40rem at 78% -10%, rgba(198, 242, 78, 0.06), transparent 60%),
    radial-gradient(50rem 36rem at 8% 110%, rgba(91, 112, 137, 0.10), transparent 55%);
  pointer-events: none;
  z-index: 0;
}
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(10, 12, 15, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 9px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-sub { font-size: 0.72rem; color: var(--text-faint); white-space: nowrap; }
.demo-chip {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--brand);
  border: 1px solid rgba(198, 242, 78, 0.35);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  margin-left: 0.3rem;
  flex-shrink: 0;
}
.appbar-right { display: flex; align-items: center; gap: 1rem; }
.clock { text-align: right; display: flex; flex-direction: column; }
.clock-label { font-size: 0.66rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
.clock-date { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-dim); }

/* ---------- Tabs ---------- */
.tabs {
  position: sticky;
  top: 67px;
  z-index: 19;
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1.25rem 0;
  background: rgba(10, 12, 15, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 0.75rem 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--brand); }
.tab-ico { color: var(--brand); font-size: 0.8rem; opacity: 0.9; }
.tab:not(.is-active) .tab-ico { color: var(--text-faint); }

/* ---------- Layout ---------- */
.content { position: relative; z-index: 2; max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.panel { display: none; animation: fade 0.25s ease; }
.panel.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin: 0;
}
.panel-desc { margin: 0.25rem 0 0; color: var(--text-dim); font-size: 0.92rem; max-width: 52ch; }

/* segmented control (period) */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.2rem; gap: 0.15rem; }
.seg-btn {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--text-dim); font-family: var(--font-sans); font-weight: 500; font-size: 0.82rem;
  padding: 0.4rem 0.8rem; border-radius: 7px; transition: all 0.15s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { background: var(--brand); color: var(--brand-ink); }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; margin: 0; letter-spacing: -0.01em; }
.card-note { font-size: 0.74rem; color: var(--text-faint); }

.grid-2, .grid-3 { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
/* min-width:0 stops grid/flex items from refusing to shrink below their
   content (canvas/table) min-size - the classic grid blowout that lets a
   chart canvas overflow its container. canvas cap is the belt-and-suspenders. */
.grid-2 > *, .grid-3 > *, .card, .kpi { min-width: 0; }
.chart-wrap { min-width: 0; }
.chart-wrap canvas { max-width: 100% !important; }
@media (min-width: 880px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 2fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
}

/* ---------- KPI ---------- */
.kpi-grid { display: grid; gap: 0.85rem; grid-template-columns: 1fr; margin-bottom: 1.1rem; }
@media (min-width: 560px) { .kpi-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 980px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-grid-3 { margin-bottom: 1rem; }
@media (min-width: 980px) { .kpi-grid-3 { grid-template-columns: repeat(3, 1fr); } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--brand)); opacity: 0.8;
}
.kpi-label { font-size: 0.74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.kpi-value { font-family: var(--font-mono); font-weight: 500; font-size: 1.4rem; margin-top: 0.35rem; letter-spacing: -0.02em; }
.kpi-meta { font-size: 0.76rem; margin-top: 0.4rem; display: flex; align-items: center; gap: 0.3rem; color: var(--text-dim); }
.delta-up { color: var(--emerald); }
.delta-down { color: var(--rose); }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.chart-tall { height: 320px; }
.legend { display: flex; gap: 0.9rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text-dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-brand { background: var(--brand); }
.dot-slate { background: var(--slate); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.25rem; }
.table-scroll-y { max-height: 320px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td { white-space: nowrap; padding: 0.62rem 0.7rem; text-align: left; }
.data-table th {
  position: sticky; top: 0;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); font-weight: 600;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1;
}
.data-table td { border-bottom: 1px solid var(--line-soft); color: var(--text-dim); }
.data-table .num { text-align: right; font-family: var(--font-mono); }
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .prod-name { color: var(--text); font-weight: 500; }
.data-table .prod-cat { color: var(--text-faint); font-size: 0.72rem; }
.row-click { cursor: pointer; }
.row-selected { background: var(--brand-soft) !important; }

/* badges (single expression - solid dot + text, no triple-match pastel) */
.badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.76rem; font-weight: 500; white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-aman, .badge-lancar { color: var(--emerald); }
.badge-waspada, .badge-lambat { color: var(--amber); }
.badge-kritis, .badge-macet { color: var(--rose); }
.trend { font-family: var(--font-mono); font-size: 0.8rem; }
.trend-naik { color: var(--emerald); }
.trend-turun { color: var(--rose); }
.trend-stabil { color: var(--text-dim); }

.acc-bar { display: inline-flex; align-items: center; gap: 0.5rem; }
.acc-track { width: 46px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.acc-fill { height: 100%; background: var(--brand); border-radius: 3px; }

/* ---------- Alerts ---------- */
.alert-strip { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.alert {
  display: flex; align-items: flex-start; gap: 0.7rem;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; font-size: 0.86rem;
}
.alert.alert-danger { border-left-color: var(--rose); }
.alert-ico { color: var(--amber); font-size: 0.95rem; line-height: 1.4; }
.alert-danger .alert-ico { color: var(--rose); }
.alert b { color: var(--text); font-weight: 600; }
.alert-empty { color: var(--text-faint); font-size: 0.84rem; border-left-color: var(--emerald); }
.alert-empty .alert-ico { color: var(--emerald); }

/* ---------- Chatbot ---------- */
.chat-shell { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 880px) { .chat-shell { grid-template-columns: minmax(0, 420px) 1fr; } }

.chat-phone {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  height: 600px; max-height: 78vh;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.chat-topbar {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.75rem 0.95rem; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
}
.chat-peer { display: flex; flex-direction: column; }
.chat-peer-name { font-weight: 600; font-size: 0.92rem; }
.chat-peer-status { font-size: 0.72rem; color: var(--text-faint); display: inline-flex; align-items: center; gap: 0.35rem; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 1rem 0.95rem;
  display: flex; flex-direction: column; gap: 0.6rem;
  background:
    linear-gradient(rgba(10,12,15,0.4), rgba(10,12,15,0.4)),
    repeating-linear-gradient(45deg, var(--surface) 0 14px, var(--surface-2) 14px 28px);
}
.msg { max-width: 82%; padding: 0.55rem 0.75rem; border-radius: 12px; font-size: 0.88rem; line-height: 1.45; white-space: pre-line; word-break: break-word; animation: pop 0.18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-bot { align-self: flex-start; background: var(--surface-3); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg-user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 3px; font-weight: 500; }
.msg-time { display: block; font-size: 0.62rem; color: var(--text-faint); margin-top: 0.25rem; }
.msg-user .msg-time { color: rgba(10,12,15,0.55); text-align: right; }

.chat-card {
  align-self: flex-start; max-width: 82%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.65rem 0.75rem; font-size: 0.84rem;
}
.chat-card + .chat-card { margin-top: -0.35rem; }
.cc-name { font-weight: 600; color: var(--text); }
.cc-price { font-family: var(--font-mono); color: var(--brand); font-size: 0.9rem; margin-top: 0.15rem; }
.cc-meta { color: var(--text-faint); font-size: 0.74rem; margin-top: 0.25rem; }
.cc-stock { font-size: 0.74rem; margin-top: 0.3rem; }

.chat-handover {
  align-self: center; font-size: 0.74rem; color: var(--amber);
  border: 1px dashed rgba(251,191,36,0.4); border-radius: 20px; padding: 0.3rem 0.8rem;
}
.typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 0.6rem 0.8rem; background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.quick-replies { display: flex; gap: 0.4rem; padding: 0.6rem 0.95rem 0; overflow-x: auto; scrollbar-width: none; }
.quick-replies::-webkit-scrollbar { display: none; }
.qr {
  flex-shrink: 0; appearance: none; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim);
  font-family: var(--font-sans); font-size: 0.78rem; padding: 0.35rem 0.7rem; border-radius: 16px;
  transition: all 0.15s ease; white-space: nowrap;
}
.qr:hover { border-color: var(--brand); color: var(--text); }

.chat-input { display: flex; gap: 0.5rem; padding: 0.75rem 0.95rem; border-top: 1px solid var(--line); }
.chat-input input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--line); border-radius: 22px;
  padding: 0.6rem 0.95rem; color: var(--text); font-family: var(--font-sans); font-size: 0.88rem;
  outline: none; transition: border-color 0.15s ease;
}
.chat-input input:focus { border-color: var(--brand); }
.chat-send {
  width: 42px; height: 42px; flex-shrink: 0; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); border-radius: 50%; font-size: 1rem;
  display: grid; place-items: center; transition: transform 0.12s ease;
}
.chat-send:active { transform: scale(0.92); }

.chat-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.side-title { font-family: var(--font-display); font-weight: 600; font-size: 0.92rem; margin: 0 0 0.4rem; }
.side-title + .side-text + .side-title { margin-top: 1.1rem; }
.side-text { color: var(--text-dim); font-size: 0.86rem; margin: 0 0 0.5rem; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.side-list li { font-family: var(--font-mono); font-size: 0.78rem; color: var(--brand); padding-left: 0.9rem; position: relative; }
.side-list li::before { content: '›'; position: absolute; left: 0; color: var(--text-faint); }

/* ---------- Footer ---------- */
.foot {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 1.5rem 1rem 2rem; color: var(--text-faint); font-size: 0.78rem;
  border-top: 1px solid var(--line-soft);
}
.foot-sep { opacity: 0.5; }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.sk-line { height: 12px; margin: 6px 0; }

@media (min-width: 640px) {
  .content { padding-top: 2rem; }
}
@media (max-width: 560px) {
  .panel-title { font-size: 1.35rem; }
  .brand-sub { display: none; }
  .chart-wrap { height: 240px; }
}
