/* Laboratory Inventory Management System */
:root {
  --lab-primary: #232F5C;        /* BIOTRUST navy — buttons, links, topbar */
  --lab-primary-dark: #1a2344;
  --lab-sidebar: #758C2A;        /* BIOTRUST green — left panel, login */
  --lab-sidebar-active: #5f7222;
  --lab-accent: #e8f0cf;
  --lab-amber: #b97b0c;
  --lab-bg: #f2f5f4;
  --lab-ink: #16302d;
}

body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--lab-bg);
  color: var(--lab-ink);
}
.mono { font-family: 'IBM Plex Mono', monospace; }

/* ---------- Login ---------- */
#loginView {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #4e5e1c 0%, #66791f 55%, #758C2A 100%);
}
.login-card {
  width: 100%; max-width: 400px; border: none; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-brand {
  letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
  color: var(--lab-primary); font-size: .8rem;
}

/* ---------- Layout ---------- */
#appView { display: none; }
.sidebar {
  width: 232px; min-height: 100vh; background: var(--lab-sidebar);
  position: fixed; top: 0; left: 0; z-index: 1030;
  display: flex; flex-direction: column;
}
.sidebar .brand {
  color: #fff; padding: 18px 18px 14px; font-weight: 600; font-size: 1.02rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand small { color: var(--lab-accent); letter-spacing: .12em; font-size: .62rem; }
.sidebar .brand img {
  max-height: 42px; max-width: 130px; display: block;
  background: #fff; border-radius: 8px; padding: 3px 7px; margin-bottom: 8px;
}
.sidebar .nav-link {
  color: #eef3da; padding: 9px 18px; border-left: 3px solid transparent;
  font-size: .92rem; cursor: pointer;
}
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.10); }
.sidebar .nav-link.active {
  color: #fff; background: var(--lab-sidebar-active); border-left-color: var(--lab-accent);
}
.sidebar .nav-section {
  color: #dfe9bd; font-size: .66rem; text-transform: uppercase; letter-spacing: .14em;
  padding: 14px 18px 4px;
}
.main { margin-left: 232px; padding: 0 24px 48px; }
.topbar {
  background: var(--lab-primary); margin: 0 -24px 20px; padding: 12px 24px;
  border-bottom: none; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 4px rgba(26,35,68,.25);
}
.topbar #pageTitle, .topbar h5 { color: #fff; }
.topbar .btn-link, .topbar .bi-list { color: #fff; }
.nav-pills .nav-link.active { background: var(--lab-primary); }

@media (max-width: 991px) {
  .sidebar { left: -232px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .main { margin-left: 0; }
}

/* ---------- Cards & tables ---------- */
.stat-card { border: none; border-radius: 12px; box-shadow: 0 1px 3px rgba(22,48,45,.08); }
.stat-card .stat-icon {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; background: #e9edf7; color: var(--lab-primary);
}
.stat-card .stat-icon.warn { background: #fdf1d7; color: var(--lab-amber); }
.stat-card .stat-icon.danger { background: #fbe4e1; color: #c0392b; }
.stat-card .stat-value {
  font-size: 1.45rem; font-weight: 600; line-height: 1.15;
  letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-card .stat-label { font-size: .68rem; color: #6c8a84; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 2px; white-space: nowrap; }
.stat-card.clickable { cursor: pointer; transition: transform .1s; }
.stat-card.clickable:hover { transform: translateY(-2px); }

.card { border: none; border-radius: 12px; box-shadow: 0 1px 3px rgba(22,48,45,.08); }
.table > :not(caption) > * > * { padding: .55rem .75rem; }
.table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: #6c8a84; border-bottom: 2px solid #dfe8e6; white-space: nowrap;
}
.table tbody tr:hover { background: #f6faf9; }

.btn-lab { background: var(--lab-primary); color: #fff; }
.btn-lab:hover { background: var(--lab-primary-dark); color: #fff; }

/* ---------- Status badges ---------- */
.badge-status { font-weight: 500; padding: .35em .7em; border-radius: 20px; font-size: .74rem; }
.st-Draft     { background: #e8ecea; color: #55706b; }
.st-Pending   { background: #fdf1d7; color: var(--lab-amber); }
.st-Approved  { background: #dbeafe; color: #1d4ed8; }
.st-Received, .st-Completed { background: #d7f2e7; color: #0d7a4f; }

.qty-low  { color: var(--lab-amber); font-weight: 600; }
.qty-out  { color: #c0392b; font-weight: 600; }
.qty-ok   { color: #0d7a4f; }

/* ---------- Notifications ---------- */
.notif-badge {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px;
  background: #dc3545; color: #fff; border-radius: 10px; font-size: .62rem;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-menu { width: 360px; max-height: 480px; overflow-y: auto; }

/* ---------- Print (A4) ---------- */
#printArea { display: none; }
@media print {
  /* Hide the app, show only the print area — without touching table layout */
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  #printArea h3 { font-size: 15px; margin: 6px 0; }
  #printArea table { width: 100%; border-collapse: collapse; font-size: 11px; }
  #printArea th, #printArea td { border: 1px solid #444; padding: 4px 6px; text-align: left; }
  #printArea th { background: #f0f0f0; }
  #printArea thead { display: table-header-group; }
  #printArea tr { page-break-inside: avoid; }
  #printArea .qty-out { color: #c0392b !important; font-weight: 600; }
  #printArea .qty-low { color: #b97b0c !important; font-weight: 600; }
  #printArea .print-header { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 10px; }
  #printArea .print-header img { max-height: 60px; }
  #printArea .print-info { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 30px; font-size: 11.5px; margin: 8px 0 10px; }
  #printArea .print-info .pi-l { font-weight: 600; }
  #printArea .sig-row { display: flex; justify-content: space-between; gap: 30px; margin-top: 40px; }
  #printArea .sig { flex: 1; text-align: center; font-size: 11px; }
  #printArea .sig .line { border-top: 1px solid #000; margin-top: 42px; padding-top: 5px; }
  #printArea .print-footer { margin-top: 16px; font-size: 10px; display: flex; justify-content: space-between; border-top: 1px solid #888; padding-top: 6px; }
  @page { size: A4; margin: 14mm 12mm; }
}

/* ---------- Searchable item picker ---------- */
.ip-menu {
  display: none; position: fixed; z-index: 2000;
  max-height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid #cfdbd8; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(22,48,45,.22);
}
.ip-group {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .1em;
  color: #6c8a84; padding: 6px 10px 2px; background: #f6faf9; position: sticky; top: 0;
}
.ip-item {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 5px 10px; font-size: .86rem; cursor: pointer; white-space: nowrap;
}
.ip-item:hover { background: #e7f4f1; }
.ip-code { color: #6c8a84; font-family: 'IBM Plex Mono', monospace; font-size: .76rem; }

/* Entire row red when item is out of stock (available = 0) */
.row-out td { color: #c0392b; }
.row-out td .qty-low { color: #c0392b; }

/* Whole-row orange for expiring-soon / low-stock report rows */
.row-warn td { color: #b97b0c; }

/* Items with expired lots: entire row orange (out-of-stock red wins if both) */
.row-expired td { color: #b45309; }

/* Item History: green rows for stock in */
.row-ok td { color: #0d7a4f; }
