/* Any Lab Test Now — LIMS console styles.
   Brand palette is injected as CSS variables by the layout (base.html). */

* { box-sizing: border-box; }

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --line: #e3e8ee;
  --muted: #6b7a8d;
  --text: #1f2d3d;
  --sidebar: #0f2a3f;
  --sidebar-active: rgba(255, 255, 255, 0.10);
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 42, 63, 0.06), 0 4px 18px rgba(16, 42, 63, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

/* The sidebar is a Bootstrap offcanvas: a slide-in drawer below the lg
   breakpoint, pinned permanently open on large screens (see media queries). */
.sidebar {
  width: 248px;
  background: var(--sidebar);
  color: #cdd8e3;
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent);
  color: #fff; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -0.5px;
}
.sidebar .brand .name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.15; }
.sidebar .brand .name small { display:block; font-weight: 500; color: #8aa0b4; font-size: 11px; letter-spacing: .3px; }

/* display:block guards against Bootstrap's `.nav { display:flex }` reboot,
   which would otherwise lay the sidebar links out horizontally. */
.nav { display: block; padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav .group { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #6a8199; margin: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 2px 0;
  color: #cdd8e3; border-radius: 9px; font-weight: 500;
}
.nav a .ic { width: 18px; text-align: center; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }

.sidebar .foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #8aa0b4; }

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: 62px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.menu-btn {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  width: 40px; height: 38px; border-radius: 9px; font-size: 18px; line-height: 1;
  cursor: pointer; margin-right: 12px; flex-shrink: 0;
}
.menu-btn:hover { background: #f6f8fa; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.topbar .user .who { font-size: 13px; line-height: 1.2; }
.topbar .user .who small { color: var(--muted); display: block; text-transform: capitalize; }

.content { padding: 26px 28px; max-width: 1160px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card .card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.card .card-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.card .card-body { padding: 20px; }
.card.pad { padding: 20px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; color: var(--ink); }
.stat .value.accent { color: var(--accent); }
.stat .value.primary { color: var(--primary); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 11px 20px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
tbody td { padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcfd; }
.table-wrap { overflow-x: auto; }

.namecell { display: flex; align-items: center; gap: 11px; }
.namecell .avatar { width: 32px; height: 32px; font-size: 12px; }
.namecell .sub { color: var(--muted); font-size: 12.5px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-green { background: #e5f7ee; color: #1a7f47; }
.badge-blue  { background: #e7f1fd; color: #1b6fd6; }
.badge-amber { background: #fdf3e0; color: #b5730b; }
.badge-gray  { background: #eef1f4; color: #5b6b7c; }
.badge-red   { background: #fdeaec; color: #c9273b; }

.pill { display:inline-block; background:#eef1f4; color:#48576a; border-radius:6px; padding:2px 8px; font-size:12px; margin:2px 3px 2px 0; }
.pill.aa { background: #e7f1fd; color: #1b6fd6; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content:center;
  padding: 9px 16px; border-radius: 9px; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: var(--primary); color: #fff;
}
.btn:hover { filter: brightness(0.95); text-decoration: none; }
.btn.accent { background: var(--accent); }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: #f6f8fa; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.ghost.danger { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn.ghost.danger:hover { background: var(--accent); color: #fff; }
.btn.danger { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: #37475a; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date],
input[type=time], select, textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px;
  font-family: var(--font); background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,167,181,0.15); }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.check:hover { border-color: var(--primary); background: #f7fdfe; }
.check input { margin-top: 3px; }
.check .t { font-weight: 600; }
.check .d { color: var(--muted); font-size: 12.5px; }
.check .p { color: var(--accent); font-weight: 700; font-size: 13px; }

/* ---------- Misc ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 10px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing:.5px; color: var(--muted); margin: 26px 0 12px; }
.flash { background: #fdeaec; color: #b02a37; border: 1px solid #f5c2c7; padding: 11px 14px; border-radius: 9px; margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: #e5f7ee; color: #1a7f47; border-color: #b7e4c7; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; }
.flag-high { color: #c9273b; font-weight: 700; }
.flag-low  { color: #b5730b; font-weight: 700; }
.flag-normal { color: #1a7f47; }
.chips { display:flex; flex-wrap: wrap; }
code, pre { font-family: "SF Mono", Menlo, Consolas, monospace; }
pre.code {
  background: #0f2a3f; color: #dbe7f1; padding: 16px 18px; border-radius: 10px;
  overflow-x: auto; font-size: 13px; line-height: 1.55;
}
pre.code .k { color: #6ee0d6; }
.endpoint { display:flex; gap:10px; align-items:center; padding: 11px 14px; border:1px solid var(--line); border-radius:9px; margin-bottom:10px; }
.method { font-weight:700; font-size:12px; padding:3px 8px; border-radius:6px; color:#fff; min-width:52px; text-align:center; }
.method.get { background:#1b6fd6; }
.method.post { background:#1a7f47; }
.endpoint .path { font-family:"SF Mono",Menlo,monospace; font-size:13px; }
.endpoint .desc { color: var(--muted); font-size:13px; margin-left:auto; }
.keybox { display:flex; gap:10px; align-items:center; background:#f7fafb; border:1px dashed var(--primary); border-radius:9px; padding:12px 14px; }
.keybox code { font-size:14px; color: var(--ink); font-weight:600; }

/* Simulator */
.sim { display:grid; grid-template-columns: 380px 1fr; gap: 20px; align-items:start; }
.phone {
  background: #0f2a3f; border-radius: 26px; padding: 14px; box-shadow: var(--shadow);
}
.phone .screen { background:#f4f6f8; border-radius:16px; min-height: 460px; display:flex; flex-direction:column; overflow:hidden; }
.phone .callbar { background: var(--primary); color:#fff; padding:14px 16px; display:flex; align-items:center; gap:10px; }
.phone .callbar .aa { width:36px;height:36px;border-radius:50%;background:rgba(255,255,255,.2);display:flex;align-items:center;justify-content:center;font-size:18px;}
.transcript { flex:1; padding:14px; overflow-y:auto; display:flex; flex-direction:column; gap:10px; }
.bubble { max-width: 85%; padding:10px 13px; border-radius:14px; font-size:13.5px; line-height:1.45; }
.bubble.agent { background:#fff; border:1px solid var(--line); align-self:flex-start; border-bottom-left-radius:4px; }
.bubble.caller { background: var(--primary); color:#fff; align-self:flex-end; border-bottom-right-radius:4px; }
.bubble .who { font-size:11px; opacity:.7; margin-bottom:3px; font-weight:700; text-transform:uppercase; letter-spacing:.4px;}
.sim-json { background:#0f2a3f; color:#dbe7f1; border-radius:10px; padding:14px; font-size:12px; max-height:520px; overflow:auto; white-space:pre-wrap; word-break:break-word; }

/* ---------- Responsive ---------- */

/* Desktop (lg+): pin the offcanvas sidebar permanently open. The ID selector
   outranks Bootstrap's `.offcanvas` fixed/hidden rules. */
@media (min-width: 992px) {
  #sidebar.sidebar {
    position: sticky; top: 0;
    transform: none;
    visibility: visible !important;
    z-index: auto;
    border-right: 0;
  }
}

/* Below lg the sidebar is a slide-in drawer (Bootstrap offcanvas handles the
   fixed positioning, backdrop and toggle); tighten the chrome for small screens. */
@media (max-width: 991.98px) {
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px; }
  .sim { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .form-grid, .grid-2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-head .actions { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
}

@media (max-width: 560px) {
  .topbar .user .who { display: none; }
}

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-title { font-size: 16px; font-weight: 700; margin: 0 0 0 6px; }
.cal-modes { display: flex; gap: 8px; }

/* Horizontal scroll keeps the 7-column grid usable on narrow screens. */
.cal-scroll { overflow-x: auto; }
.cal { min-width: 720px; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head .cal-hcell {
  padding: 10px 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); text-align: left;
}
.cal-cell {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 8px; min-height: 116px; background: var(--surface); overflow: hidden;
}
.cal-row .cal-cell:last-child { border-right: none; }
.cal-cell.out { background: #f7f9fb; }
.cal-cell.out .cal-daynum { color: #b6c1cd; }
.cal-cell.today { background: #f0fbfc; box-shadow: inset 0 0 0 2px var(--primary); }
.cal-daynum { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.cal-cell.today .cal-daynum {
  background: var(--primary); color: #fff; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.cal-events { display: flex; flex-direction: column; gap: 4px; }
.cal-ev {
  display: flex; align-items: baseline; gap: 6px; padding: 4px 7px; border-radius: 6px;
  font-size: 12px; line-height: 1.3; text-decoration: none;
  border-left: 3px solid currentColor; overflow: hidden;
}
.cal-ev:hover { text-decoration: none; filter: brightness(0.97); }
.cal-ev .cal-ev-time { font-weight: 700; white-space: nowrap; }
.cal-ev .cal-ev-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* In week mode the single row is taller so events have room to breathe. */
.cal-week .cal-cell { min-height: 340px; }

@media (max-width: 720px) {
  .cal-toolbar { justify-content: flex-start; }
  .cal-cell { min-height: 96px; }
}
