/* DAV DIGI app shell — sidebar + topbar + responsive grid + komponen.
   Dipakai di semua halaman web app. Brand orange #e8742c. */

:root {
  --brand: #e8742c;
  --brand-dark: #c95f1f;
  --brand-soft: #fdf1e7;
  --brand-text: #9a4516;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --hint: #9ca3af;
  --line: #eef0f3;
  --line-strong: #e5e7eb;
  --paper: #ffffff;
  --canvas: #fafafa;
  --canvas-2: #f5f6f8;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --ok-text: #065f46;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --warn-text: #92400e;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-text: #991b1b;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --info-text: #1e3a8a;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(17,24,39,.06);
  --shadow-md: 0 4px 16px rgba(17,24,39,.08);
  /* Override style.css legacy primary (Google blue) → brand orange */
  --primary: #e8742c;
  --primary-dark: #c95f1f;
}

/* Re-color legacy components from style.css and inline blocks to brand */
.tab-btn.active { color: var(--brand) !important; border-bottom-color: var(--brand) !important; }
.btn-create { background: var(--brand) !important; }
.btn-create:hover { background: var(--brand-dark) !important; }
.doc-number { color: var(--brand) !important; }
.tag-chip { background: var(--brand-soft) !important; color: var(--brand-text) !important; }
.s-approved { background: var(--brand-soft) !important; color: var(--brand-text) !important; }
.s-partial { background: var(--brand-soft) !important; color: var(--brand-text) !important; }
.bulk-bar { background: var(--brand-soft) !important; border-bottom-color: var(--brand) !important; }
.bulk-label { color: var(--brand-text) !important; }
.dash-tabs, .filter-bar { background: var(--paper) !important; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}

/* ── Grid layout ──────────────────────────────────────────────────────── */
/* P2-N: sidebar removed — owner wants simpler UI. Layout is single-column;
   navigation lives in the topbar (+ Buat Baru dropdown + tabs in the main
   area). Sidebar markup is still rendered (legacy compatibility) but hidden
   via display:none below. */
.shell-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar"
    "main";
  min-height: 100vh;
}
.shell-sidebar,
#shell-sidebar,
.shell-burger,
.shell-overlay,
#shell-overlay {
  display: none !important;
}

/* ── Topbar ───────────────────────────────────────────────────────────── */
.shell-topbar {
  grid-area: topbar;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.shell-burger {
  display: none;
  background: none;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 20px;
  padding: 0;
}
.shell-burger:hover { background: var(--canvas-2); }
.shell-crumbs {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-crumbs strong { color: var(--ink); font-weight: 500; }
.shell-search {
  flex: 1;
  max-width: 360px;
  margin-left: auto;
  position: relative;
}
.shell-search input {
  width: 100%;
  background: var(--canvas-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 7px 12px 7px 32px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
}
.shell-search input:focus { border-color: var(--brand); background: var(--paper); }
.shell-search::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .6;
  pointer-events: none;
}
.shell-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-brand {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: var(--r-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .15s;
}
.btn-brand:hover { background: var(--brand-dark); }
.btn-brand:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--canvas-2); }
.shell-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .04em;
  flex-shrink: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.shell-sidebar {
  grid-area: sidebar;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 14px 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.shell-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}
.shell-brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
}
.shell-brand .name { font-weight: 500; font-size: 14px; letter-spacing: .02em; color: var(--ink); }
.shell-brand .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.shell-nav-group { padding: 8px 0; }
.shell-nav-label {
  padding: 0 18px 4px;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--hint);
  font-weight: 600;
}
.shell-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  border-right: 3px solid transparent;
  transition: background .15s, color .15s;
}
.shell-nav-item:hover { background: var(--canvas-2); }
.shell-nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 500;
  border-right-color: var(--brand);
}
.shell-nav-item .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 15px;
}
.shell-nav-item.disabled { color: var(--hint); cursor: not-allowed; pointer-events: none; }
.shell-nav-item.disabled .tag-soon {
  font-size: 9px;
  background: var(--line-strong);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: auto;
  letter-spacing: .08em;
}

/* ── Main area ────────────────────────────────────────────────────────── */
.shell-main {
  grid-area: main;
  padding: 20px 24px 48px;
  background: var(--canvas);
  min-width: 0;
}
.shell-page-title { font-size: 18px; font-weight: 500; margin: 0 0 14px; letter-spacing: .01em; }

/* ── Cards / panels ───────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
}
.card-lg {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.card h3, .card-lg h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.card-lg .muted-side { font-size: 11px; color: var(--muted); font-weight: 400; }

/* ── Hero metric ──────────────────────────────────────────────────────── */
.hero {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 14px;
}
.hero .label { font-size: 10px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-weight: 500; }
.hero .value { font-size: 28px; font-weight: 500; margin-top: 4px; color: var(--ink); letter-spacing: .005em; }
.hero .sub { font-size: 12px; margin-top: 3px; color: var(--ok); }
.hero .sub.down { color: var(--danger); }
.hero svg.spark { width: 180px; height: 48px; flex-shrink: 0; }

/* ── KPI strip ────────────────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
}
.kpi .l { font-size: 11px; color: var(--muted); }
.kpi .v { font-size: 18px; font-weight: 500; margin-top: 4px; color: var(--ink); }
.kpi .delta { font-size: 11px; margin-top: 3px; color: var(--muted); }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }
.kpi.brand { background: var(--brand-soft); border-color: transparent; }
.kpi.brand .l, .kpi.brand .delta { color: var(--brand-text); }
.kpi.brand .v { color: var(--brand-text); }

/* ── Status pill ──────────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.pill-ok      { background: var(--ok-soft);     color: var(--ok-text); }
.pill-warn    { background: var(--warn-soft);   color: var(--warn-text); }
.pill-danger  { background: var(--danger-soft); color: var(--danger-text); }
.pill-info    { background: var(--info-soft);   color: var(--info-text); }
.pill-muted   { background: var(--line);        color: var(--muted); }
.pill-brand   { background: var(--brand-soft);  color: var(--brand-text); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--line); background: var(--paper); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead { background: var(--canvas-2); }
table.tbl th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: var(--canvas); }
table.tbl td.num, table.tbl th.num { text-align: right; white-space: nowrap; }

/* ── List row (lighter than tbl) ──────────────────────────────────────── */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.list-row:last-child { border-bottom: 0; }
.list-row .who { font-weight: 500; color: var(--ink); }
.list-row .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.list-row .right { text-align: right; flex-shrink: 0; }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  font-size: 13px;
}
.empty .ico { font-size: 28px; opacity: .5; margin-bottom: 8px; }

/* ── Skeleton ─────────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--canvas-2) 0%, #eaecef 50%, var(--canvas-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.2s ease-in-out infinite;
  border-radius: 4px;
  display: inline-block;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Forms (consistent input styling) ─────────────────────────────────── */
.shell-main input[type="text"],
.shell-main input[type="search"],
.shell-main input[type="number"],
.shell-main input[type="date"],
.shell-main input[type="password"],
.shell-main select,
.shell-main textarea {
  font-family: inherit;
}
.shell-main input[type="search"]:focus,
.shell-main input[type="text"]:focus,
.shell-main select:focus { outline: 2px solid var(--brand-soft); outline-offset: 0; border-color: var(--brand) !important; }

/* ── Drawer overlay for mobile ────────────────────────────────────────── */
.shell-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,24,39,.45);
  z-index: 25;
}
.shell-overlay.open { display: block; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .hero { flex-direction: column; align-items: stretch; }
  .hero svg.spark { width: 100%; }
}

@media (max-width: 768px) {
  .shell-grid {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  .shell-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .2s ease-out;
    box-shadow: var(--shadow-md);
  }
  .shell-sidebar.open { transform: translateX(0); }
  .shell-burger { display: inline-flex; align-items: center; justify-content: center; }
  .shell-search { display: none; }
  .shell-main { padding: 14px 14px 60px; }
  .shell-actions .btn-brand .btn-full { display: none; }

  /* Table → card stack pada mobile */
  .tbl-wrap.stack-mobile { border: 0; background: transparent; }
  .tbl-wrap.stack-mobile table.tbl thead { display: none; }
  .tbl-wrap.stack-mobile table.tbl tbody tr {
    display: block;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r);
    margin-bottom: 10px;
    padding: 4px 0;
  }
  .tbl-wrap.stack-mobile table.tbl tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 8px 14px;
    font-size: 13px;
  }
  .tbl-wrap.stack-mobile table.tbl tbody tr td:last-child { border-bottom: 0; }
  .tbl-wrap.stack-mobile table.tbl tbody tr td::before {
    content: attr(data-label);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .1em;
    text-transform: uppercase;
    font-weight: 600;
  }
  .tbl-wrap.stack-mobile table.tbl tbody tr td.num { text-align: right; }
}

@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hero .value { font-size: 22px; }
  .shell-topbar { padding: 0 12px; gap: 10px; }
}
