/* ============================================================
   custom.css  |  Packing Monitor v2 — TPC Light Theme
   ============================================================ */
:root {
  --bg:       #F0F3F7;
  --surface:  #FFFFFF;
  --border:   #DDE3EC;
  --tpc:      #C41020;
  --tpc-lt:   #FDF2F3;
  --text:     #1A2332;
  --mid:      #5A6878;
  --dim:      #94A3B8;
  --ok:       #1B7A4A;
  --warn:     #C07000;
  --blue:     #1455B3;
  --purple:   #6B3FA0;
  --shadow:   0 1px 4px rgba(0,0,0,.06);
  --shadow-md:0 4px 16px rgba(0,0,0,.09);
  --mono:     'DM Mono','Courier New',monospace;
  --sidebar-w:240px;
}

/* ── Base ─────────────────────────────────────────────── */
*  { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui,-apple-system,'Segoe UI',sans-serif;
  font-size: 13.5px;
  margin: 0;
}
.font-monospace { font-family: var(--mono) !important; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #C8D0DC; border-radius: 3px; }

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 12px rgba(0,0,0,.07);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  /* Red accent stripe */
  border-left: 3px solid var(--tpc);
  transition: transform .25s;
}
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 999;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--tpc);
  letter-spacing: .5px;
  line-height: 1.3;
}
.brand-sub { font-size: 9px; color: var(--dim); }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.nav-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 10px;
  margin-bottom: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 14px;
  border-radius: 7px;
  margin-bottom: 2px;
  color: var(--mid);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.nav-item:hover { background: #F7F9FC; color: var(--text); }
.nav-item.active {
  background: var(--tpc-lt);
  color: var(--tpc);
  font-weight: 600;
  border-left-color: var(--tpc);
}
.nav-badge {
  background: #DC2626;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
}
.nav-item.active .nav-badge { background: var(--tpc); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #FAFBFC;
  font-size: 11px;
}
.status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--mid);
}
.status-tags { font-size: 9px; color: var(--dim); font-family: var(--mono); margin-top: 8px; }

/* ── Main Wrap & Topbar ───────────────────────────────── */
#main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s;
}
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
}
.topbar-clock {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
}
.shift-badge {
  background: var(--tpc) !important;
  color: #fff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
}
.btn-icon {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--mid);
  border-radius: 6px;
  display: flex;
  align-items: center;
}
.btn-icon:hover { background: var(--bg); }

/* ── Page Content ─────────────────────────────────────── */
.page-content { flex: 1; }
.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ── KPI Cards ────────────────────────────────────────── */
.kpi-card { border-radius: 10px; }
.kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 800;
  font-family: var(--mono);
  line-height: 1;
}
.kpi-sub { font-size: 11px; color: var(--mid); margin-top: 6px; }
.kpi-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
/* purple not in BS5 defaults */
.text-purple { color: var(--purple) !important; }
.bg-purple  { background-color: var(--purple) !important; }

/* ── Machine Cards ────────────────────────────────────── */
.machine-card {
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow .2s, transform .15s;
}
.machine-card:hover { box-shadow: var(--shadow-md) !important; transform: translateY(-1px); }
.card-issue { border-color: var(--tpc) !important; background: #FFF5F5 !important; }
.machine-card-lg { border-radius: 10px; cursor: default; }
.mc-tag { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: .5px; }
.mc-line { font-size: 11px; color: var(--dim); margin-top: 2px; }
.mc-weight { font-size: 38px; font-weight: 800; font-family: var(--mono); letter-spacing: 1.5px; line-height: 1; }
.mc-unit { font-size: 11px; color: var(--mid); margin-top: 2px; }

/* ── Status indicators ────────────────────────────────── */
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.dot-online  { background: var(--ok); box-shadow: 0 0 0 3px #F0FBF5; }
.dot-offline { background: var(--dim); }

/* ── Cpk badge (on machine card) ─────────────────────── */
.cpk-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.cpk-ok   { background: #F0FBF5; border: 1px solid #A7DFC0; }
.cpk-warn { background: #FFF8EC; border: 1px solid #F8D889; }
.cpk-bad  { background: #FDF2F3; border: 1px solid #F5AEBB; }
.cpk-label { color: var(--mid); font-weight: 600; }
.cpk-val   { font-family: var(--mono); font-weight: 700; font-size: 13px; }

/* ── Stat mini ────────────────────────────────────────── */
.stat-mini {
  text-align: center;
  background: var(--bg);
  padding: 5px 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.stat-val { font-size: 12px; font-weight: 700; font-family: var(--mono); }
.stat-lbl { font-size: 8px; color: var(--dim); letter-spacing: .5px; margin-top: 1px; text-transform: uppercase; }

/* ── OEE card ─────────────────────────────────────────── */
.oee-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 10px;
  transition: all .2s;
}
.oee-card:hover { background: var(--surface); box-shadow: var(--shadow); }
.oee-tag { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.oee-pct { font-size: 20px; font-weight: 700; font-family: var(--mono); }

/* ── SPC Panel ────────────────────────────────────────── */
.spc-panel { min-height: 200px; }
.spc-tab.active { border-bottom: 2px solid var(--tpc); color: var(--tpc); font-weight: 600; }

/* ── Stats Panel ──────────────────────────────────────── */
.stats-panel {
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 14px;
  height: 100%;
}
.stats-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--dim);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Bootstrap btn-xs (tidak ada di BS5) ─────────────── */
.btn-xs {
  padding: 2px 8px !important;
  font-size: 11px !important;
  border-radius: 4px !important;
}

/* ── Table tweaks ─────────────────────────────────────── */
.table-sm td, .table-sm th { padding: .45rem .75rem; }
.table > thead { background: var(--bg); }

/* ── Print ────────────────────────────────────────────── */
@media print {
  #sidebar, .topbar, .btn, .btn-group, .alert-dismissible .btn-close { display: none !important; }
  #main-wrap { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
}

/* ── Mobile Responsive ────────────────────────────────── */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.show {
    transform: translateX(0);
  }
  #sidebar-overlay.show { display: block; }
  #main-wrap { margin-left: 0 !important; }
  .mc-weight { font-size: 28px; }
}
