/* =========================
   ABC Logistics Prototype v2
   Inspired by screenshots: Province performance, TTK Hold, Video Gallery, TTK detail + documentation photos
   ========================= */

:root{
  --bg: #0b0f14;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(255,255,255,.09);
  --stroke: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --muted2: rgba(255,255,255,.45);

  --primary: #5b6bff;
  --primary2: #22c55e;
  --warn: #fbbf24;
  --danger: #fb7185;

  --radius: 18px;
  --radius2: 24px;
  --shadow: 0 12px 30px rgba(0,0,0,.35);

  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --sidebar-w: 290px;
  --content-max: 1200px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"]{
  --bg: #f6f7fb;
  --panel: rgba(0,0,0,.04);
  --panel2: rgba(0,0,0,.06);
  --stroke: rgba(0,0,0,.10);
  --text: rgba(10,20,30,.92);
  --muted: rgba(10,20,30,.62);
  --muted2: rgba(10,20,30,.44);
  --shadow: 0 12px 30px rgba(0,0,0,.12);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% 0%, rgba(91,107,255,.22), transparent 50%),
    radial-gradient(900px 500px at 90% 10%, rgba(34,197,94,.14), transparent 55%),
    var(--bg);
  color: var(--text);
}

a{ color: inherit; text-decoration: none; }
button, input, select{ font: inherit; color: inherit; }
small,.small{ font-size: 12px; }
.muted{ color: var(--muted); }
.mono{ font-family: var(--mono); }

.skip-link{
  position:absolute; left:-999px; top:auto; width:1px; height:1px; overflow:hidden;
}
.skip-link:focus{ left: 16px; top: 16px; width:auto; height:auto; padding:10px 12px; background: var(--panel2); border:1px solid var(--stroke); border-radius: 12px; z-index: 9999; }

.app{ display:flex; min-height:100%; }

.sidebar{
  width: var(--sidebar-w);
  padding: 18px 14px;
  border-right: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
}
.sidebar__brand{
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--panel);
}
.logo{
  width: 44px; height: 44px;
  display:grid; place-items:center;
  border-radius: 14px;
  background: rgba(91,107,255,.20);
  border: 1px solid rgba(91,107,255,.25);
}
.brand__title{ font-weight: 800; letter-spacing: .2px; }
.brand__sub{ color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav{ margin-top: 16px; display:flex; flex-direction: column; gap: 8px; }
.nav__item{
  display:flex; align-items:center; gap: 10px;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: .16s ease;
  background: transparent;
}
.nav__icon{ width: 20px; display:inline-grid; place-items:center; opacity: .9; }
.nav__item:hover{ background: var(--panel); border-color: var(--stroke); color: var(--text); }
.nav__item.is-active{
  background: linear-gradient(180deg, rgba(91,107,255,.22), rgba(91,107,255,.08));
  border-color: rgba(91,107,255,.35);
  color: var(--text);
}

.sidebar__footer{
  margin-top: 18px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--panel);
}

.shell{ flex:1; min-width:0; display:flex; flex-direction: column; }

.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
}

.topbar__title{ min-width: 0; }
.h3{ font-size: 18px; font-weight: 820; letter-spacing: .2px; margin: 0 0 2px; }
.h4{ font-size: 16px; font-weight: 800; margin: 0; }

.topbar__actions{ display:flex; align-items:center; gap: 10px; }

.icon-btn{
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  transition: .16s ease;
}
.icon-btn:hover{ transform: translateY(-1px); background: var(--panel2); }
.icon-btn:active{ transform: translateY(0); }

.chip{
  border: 1px solid rgba(34,197,94,.35);
  background: rgba(34,197,94,.14);
  border-radius: 999px;
  padding: 10px 12px;
  cursor:pointer;
  display:flex; align-items:center; gap: 8px;
  font-weight: 700;
}
.chip:hover{ background: rgba(34,197,94,.18); }

.badge{
  display:inline-grid; place-items:center;
  font-size: 11px; font-weight: 900;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(251,113,133,.24);
  border: 1px solid rgba(251,113,133,.35);
  margin-left: 6px;
}

.content{ padding: 18px; padding-bottom: calc(18px + var(--safe-bottom)); }
.content > section{ max-width: var(--content-max); margin: 0 auto; }

.grid{ display:grid; gap: 12px; }
.grid--2{ grid-template-columns: 1fr 1fr; }
.grid--3{ grid-template-columns: repeat(3, 1fr); }
.grid--4{ grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px){
  .grid--4{ grid-template-columns: repeat(2, 1fr); }
  .grid--3{ grid-template-columns: 1fr; }
  .grid--2{ grid-template-columns: 1fr; }
}

.card{
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card--soft{
  box-shadow: none;
  background: linear-gradient(180deg, var(--panel), rgba(255,255,255,.02));
}
.kpi{
  display:flex; justify-content: space-between; gap: 10px;
  align-items: flex-start;
  cursor: pointer;
  transition: .16s ease;
}
.kpi:hover{ transform: translateY(-1px); background: var(--panel2); }
.kpi__label{ color: var(--muted); font-weight: 700; }
.kpi__value{ font-size: 26px; font-weight: 900; letter-spacing: .2px; }
.kpi__sub{ color: var(--muted2); font-size: 12px; margin-top: 4px; }

.pill{
  display:flex; align-items:center; gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.02);
}
.dot{ width:10px; height:10px; border-radius: 999px; background: var(--muted2); }
.dot--ok{ background: rgba(34,197,94,.85); box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.dot--warn{ background: rgba(251,191,36,.9); box-shadow: 0 0 0 3px rgba(251,191,36,.12); }
.dot--danger{ background: rgba(251,113,133,.85); box-shadow: 0 0 0 3px rgba(251,113,133,.12); }

.toolbar{
  display:flex;
  align-items:flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar__right{ margin-left:auto; display:flex; gap:10px; flex-wrap:wrap; }
.field{ display:flex; flex-direction: column; gap: 6px; min-width: 170px; }
.field__label{ font-size: 12px; color: var(--muted); font-weight: 750; }
.field__hint{ font-size: 12px; color: var(--muted2); }

.input{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.03);
  outline: none;
}
.input:focus{
  border-color: rgba(91,107,255,.55);
  box-shadow: 0 0 0 4px rgba(91,107,255,.12);
}

.btn{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  cursor:pointer;
  font-weight: 800;
  transition: .16s ease;
}
.btn:hover{ transform: translateY(-1px); background: var(--panel2); }
.btn--primary{
  border-color: rgba(91,107,255,.45);
  background: rgba(91,107,255,.18);
}
.btn--primary:hover{ background: rgba(91,107,255,.22); }

.hr{ height: 1px; background: var(--stroke); border: none; margin: 10px 0; }

/* Tabs like "Delivered / On Transport / Export" */
.tabs{ display:flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.tab{
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.02);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 850;
  cursor:pointer;
  transition: .16s ease;
}
.tab:hover{ background: rgba(255,255,255,.04); }
.tab.is-active{
  border-color: rgba(91,107,255,.35);
  background: rgba(91,107,255,.14);
}

/* Table */
.table{
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--panel);
}
.table th, .table td{
  padding: 12px 12px;
  border-bottom: 1px solid var(--stroke);
  text-align: left;
  vertical-align: top;
}
.table th{
  font-size: 12px;
  color: var(--muted);
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.table tr:hover td{ background: rgba(255,255,255,.03); }
.table .td-actions{ text-align:right; white-space: nowrap; }
.checkbox{ width: 18px; height: 18px; accent-color: var(--primary); cursor:pointer; }

.link{ text-decoration: underline; text-underline-offset: 3px; }

.status{
  display:inline-flex; align-items:center; gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  font-weight: 850;
  font-size: 12px;
}
.status--delivered{ background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.28); }
.status--transport{ background: rgba(251,191,36,.14); border-color: rgba(251,191,36,.28); }
.status--hold{ background: rgba(251,113,133,.14); border-color: rgba(251,113,133,.28); }

/* Province performance cards */
.prov-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 760px){
  .prov-grid{ grid-template-columns: 1fr; }
}
.prov-card{
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap: 10px;
  cursor: pointer;
  transition: .16s ease;
}
.prov-card:hover{ transform: translateY(-1px); background: var(--panel2); }
.prov-name{ font-weight: 850; }
.prov-count{ font-weight: 950; color: rgba(34,197,94,.92); }
.prov-sub{ color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Action cards (quick actions modal) */
.action-card{
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: 18px;
  padding: 12px;
  display:flex;
  align-items:center;
  gap: 12px;
  cursor:pointer;
  text-align:left;
  transition: .16s ease;
}
.action-card:hover{ transform: translateY(-1px); background: var(--panel2); }
.action-ico{
  width: 44px; height: 44px;
  display:grid; place-items:center;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.02);
  font-size: 18px;
}
.action-title{ font-weight: 900; }

/* Mobile nav + responsive */
.mobile-only{ display:none; }
@media (max-width: 1024px){
  .sidebar{ display:none; }
  .mobile-only{ display:inline-flex; }
  .content{ padding-bottom: calc(92px + var(--safe-bottom)); }
}

.bottom-nav{
  position: sticky;
  bottom: 0;
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 10px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.04));
  backdrop-filter: blur(10px);
  z-index: 40;
}
.bottom-nav a{
  display:flex; flex-direction: column;
  align-items:center; justify-content:center;
  gap: 4px;
  border-radius: 14px;
  padding: 8px 6px;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 850;
  font-size: 12px;
}
.bottom-nav a span{ font-size: 11px; font-weight: 800; }
.bottom-nav a.is-active{
  color: var(--text);
  background: rgba(91,107,255,.14);
  border-color: rgba(91,107,255,.30);
}

/* Drawer */
.drawer-backdrop{ position: fixed; inset:0; background: rgba(0,0,0,.45); z-index: 80; }
.drawer{
  position: fixed; inset: 0 auto 0 0;
  width: min(86vw, 360px);
  background: var(--bg);
  border-right: 1px solid var(--stroke);
  transform: translateX(-102%);
  transition: transform .2s ease;
  z-index: 90;
  padding: 16px 14px;
  display:flex; flex-direction: column; gap: 12px;
}
.drawer.is-open{ transform: translateX(0); }
.drawer__head{ display:flex; align-items:center; justify-content: space-between; gap: 10px; }
.drawer__foot{ margin-top: auto; }

/* Modal */
.modal{ width: min(760px, 94vw); border: none; padding: 0; background: transparent; }
.modal::backdrop{ background: rgba(0,0,0,.55); }
.modal__card{
  border-radius: var(--radius2);
  border: 1px solid var(--stroke);
  background: var(--bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal__head, .modal__foot{
  display:flex; align-items:center; justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--stroke);
}
.modal__foot{ border-bottom: none; border-top: 1px solid var(--stroke); }
.modal__body{ padding: 14px; display:grid; gap: 10px; }

/* Sheet */
.sheet-backdrop{ position: fixed; inset:0; background: rgba(0,0,0,.45); z-index: 80; }
.sheet{
  position: fixed; inset: 0 0 0 auto;
  width: min(560px, 96vw);
  background: var(--bg);
  border-left: 1px solid var(--stroke);
  transform: translateX(102%);
  transition: transform .2s ease;
  z-index: 90;
  display:flex; flex-direction: column;
}
.sheet.is-open{ transform: translateX(0); }
.sheet__head, .sheet__foot{
  padding: 14px 14px;
  border-bottom: 1px solid var(--stroke);
  display:flex; align-items:flex-start; justify-content: space-between;
  gap: 10px;
}
.sheet__foot{
  margin-top:auto;
  border-top: 1px solid var(--stroke);
  border-bottom:none;
  align-items:center;
}
.sheet__body{ padding: 14px; overflow: auto; display:grid; gap: 12px; }

.kv{
  display:grid; grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  background: var(--panel);
}
.kv .k{ color: var(--muted); font-size: 12px; font-weight: 800; }
.kv .v{ font-weight: 800; }
.kv a{ text-decoration: underline; text-underline-offset: 3px; }

.gallery{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 520px){
  .gallery{ grid-template-columns: 1fr; }
}
.media-card{
  border: 1px solid var(--stroke);
  background: var(--panel);
  border-radius: var(--radius);
  overflow:hidden;
  cursor:pointer;
  transition: .16s ease;
}
.media-card:hover{ transform: translateY(-1px); background: var(--panel2); }
.thumb{
  height: 120px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(91,107,255,.18), rgba(34,197,94,.12));
  border-bottom: 1px solid var(--stroke);
}
.thumb span{ font-size: 34px; opacity: .9; }
.media-meta{ padding: 10px; display:grid; gap: 4px; }
.media-title{ font-weight: 900; }
.media-sub{ color: var(--muted); font-size: 12px; }

.timeline{
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
  display:grid;
  gap: 10px;
}
.tl-item{ display:flex; gap: 10px; }
.tl-bullet{
  width: 12px; height: 12px;
  border-radius: 999px;
  margin-top: 4px;
  background: rgba(91,107,255,.7);
  box-shadow: 0 0 0 3px rgba(91,107,255,.12);
}
.tl-title{ font-weight: 900; }
.tl-time{ color: var(--muted); font-size: 12px; }

/* FAB */
.fab{
  position: fixed;
  right: 16px;
  bottom: calc(16px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid rgba(91,107,255,.55);
  background: rgba(91,107,255,.20);
  display:grid;
  place-items:center;
  font-size: 18px;
  font-weight: 900;
  cursor:pointer;
  z-index: 70;
  box-shadow: var(--shadow);
}
.fab:hover{ transform: translateY(-1px); background: rgba(91,107,255,.24); }
@media (max-width: 1024px){
  .fab{ bottom: calc(92px + 16px + var(--safe-bottom)); }
}

/* Toasts */
.toasts{
  position: fixed;
  right: 14px;
  bottom: calc(14px + var(--safe-bottom));
  display:grid;
  gap: 10px;
  z-index: 120;
}
.toast{
  width: min(360px, calc(100vw - 28px));
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--bg);
  box-shadow: var(--shadow);
  display:flex;
  gap: 10px;
  align-items:flex-start;
}
.toast__icon{
  width: 28px; height: 28px;
  display:grid; place-items:center;
  border-radius: 12px;
  background: var(--panel);
  border:1px solid var(--stroke);
}
.toast__title{ font-weight: 900; margin-bottom: 2px; }
.toast__msg{ color: var(--muted); font-size: 12px; }
.toast__x{ margin-left:auto; border:none; background:transparent; cursor:pointer; opacity:.8; }

/* Responsive table -> cards */
@media (max-width: 760px){
  .table{ border:none; background: transparent; }
  .table thead{ display:none; }
  .table tr{
    display:block;
    border: 1px solid var(--stroke);
    background: var(--panel);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow:hidden;
  }
  .table td{
    display:flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--stroke);
  }
  .table td::before{
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .4px;
  }
  .table .td-actions{ justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; }
}
