/*
    ██╗    ██╗██╗ ██████╗██╗  ██╗███████╗██████╗
    ██║    ██║██║██╔════╝██║ ██╔╝██╔════╝██╔══██╗
    ██║ █╗ ██║██║██║     █████╔╝ █████╗  ██║  ██║
    ██║███╗██║██║██║     ██╔═██╗ ██╔══╝  ██║  ██║
    ╚███╔███╔╝██║╚██████╗██║  ██╗███████╗██████╔╝
     ╚══╝╚══╝ ╚═╝ ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝
        W I C K E D   D E V E L O P M E N T
    ------------------------------------------------
    Project  : mv-cad — Mountain Valley RP CAD/MDT
    File     : public/css/components.css
    Author   : Wicked Development
    GitHub   : https://github.com/wickedlovesunturned
    ------------------------------------------------
    The shared component kit: status pills, priority
    tags, data tables, drawer, modal, toasts, tabs,
    command bar, sidebar, forms, timeline. Color only
    ever carries meaning — status and priority.
*/
/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 400 13.5px/1 var(--font-body);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
/* ---------- Status pill (units) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 12px/1 var(--font-body);
  padding: 4px 10px 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.pill-available::before { background: var(--st-available); }
.pill-busy::before      { background: var(--st-busy); }
.pill-enroute::before   { background: var(--st-enroute); }
.pill-onscene::before   { background: var(--st-scene); }
.pill-out::before       { background: var(--st-out); }
.pill-panic {
  border-color: var(--st-panic);
  color: #fff;
  background: color-mix(in srgb, var(--st-panic) 30%, var(--surface-2));
  animation: panic-flash 0.9s steps(2, jump-none) infinite;
}
.pill-panic::before { background: var(--st-panic); }
/* ---------- Priority tag (calls) ---------- */
.ptag {
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 11px/1 var(--font-mono);
  min-width: 26px; padding: 4px 6px;
  border-radius: var(--radius-sm);
  color: #fff;
  letter-spacing: .04em;
}
.ptag-1 { background: var(--p1); }
.ptag-2 { background: var(--p2); color: #201200; }
.ptag-3 { background: var(--p3); }
.ptag-4 { background: var(--p4); }
.ptag-1.ptag-pulse { animation: p1-pulse 1.6s ease-in-out infinite; }
/* ---------- Badge / rank chip ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 12px/1 var(--font-body);
  color: var(--text-dim);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface);
}
.chip .mono { color: var(--text-mono); }
/* ---------- Data table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface); }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th, table.data td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--hairline); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data th {
  font: 600 12px/1.3 var(--font-body);
  color: var(--text-dim);
  background: var(--surface-2);
  position: sticky; top: 0;
  user-select: none;
}
table.data th[data-sort] { cursor: pointer; }
table.data th[data-sort]:hover { color: var(--text); }
table.data th[data-sort].sorted-asc::after  { content: " ↑"; color: var(--accent); }
table.data th[data-sort].sorted-desc::after { content: " ↓"; color: var(--accent); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
table.data tr.row-click { cursor: pointer; }
table.data td.mono, table.data th.mono { font-family: var(--font-mono); color: var(--text-mono); }
/* ---------- Panels / cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-title { font: 600 14px var(--font-display); margin: 0 0 10px; }
/* ---------- Record drawer (slide-in) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(6, 10, 18, .55);
  z-index: 200; opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 94vw);
  background: var(--surface); border-left: 1px solid var(--hairline);
  box-shadow: var(--shadow-2);
  z-index: 201;
  transform: translateX(102%);
  transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.drawer.wide { width: min(720px, 96vw); }
[data-open="true"] > .drawer { transform: translateX(0); }
[data-open="true"] > .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.drawer-close { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.drawer-close:hover { color: var(--text); }
/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 10, 18, .6);
  display: none; align-items: center; justify-content: center; z-index: 300; padding: 24px;
}
[data-open="true"] > .modal-backdrop { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  width: 100%; max-width: 480px; padding: 20px;
}
.modal h2 { font-size: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
/* ---------- Toasts ---------- */
.toast-region { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast {
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px;
  box-shadow: var(--shadow-1);
  min-width: 220px; max-width: 360px;
  animation: toast-in .22s ease;
}
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-danger { border-left-color: var(--danger); }
.toast-out { opacity: 0; transform: translateX(12px); transition: all .25s ease; }
/* ---------- Tabs (MDT workspace) ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hairline); }
.tab {
  font: 400 13.5px var(--font-body);
  color: var(--text-dim);
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px; cursor: pointer; text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { padding: 16px 0; }
/* ---------- Search-and-run box ---------- */
.runbox {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 6px 6px 6px 12px;
}
.runbox:focus-within { border-color: var(--accent); }
.runbox input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font: 500 14px var(--font-mono);
}
.runbox input::placeholder { color: var(--text-dim); font-family: var(--font-body); }
/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font: 400 12.5px/1.3 var(--font-body);
  color: var(--text); margin-bottom: 5px;
}
.field input[type="text"], .field input[type="number"], .field input[type="date"],
.field input[type="datetime-local"], .field input[type="email"], .field input[type="password"],
.field select, .field textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: 400 14px var(--font-body);
  appearance: none;
  -webkit-appearance: none;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--hairline);
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -1px 0 var(--accent);
}
.field textarea { min-height: 96px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field .error-msg { font-size: 12px; color: var(--danger); margin-top: 4px; }
.field input.mono, .field textarea.mono { font-family: var(--font-mono); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
/* Hex + color picker pair (CMS pattern) */
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field input[type="color"] {
  width: 38px; height: 38px; padding: 2px;
  background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  cursor: pointer;
}
.color-field input[type="text"] { width: 110px; font-family: var(--font-mono); }
/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 40px 20px;
  border: 1px dashed var(--hairline); border-radius: var(--radius);
  color: var(--text-dim);
}
.empty .empty-icon { font-size: 26px; margin-bottom: 8px; }
.empty h3 { color: var(--text); }
/* ---------- Mugshot / photo frame ---------- */
.mugshot {
  width: 120px; height: 150px; object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 11px; text-align: center;
  overflow: hidden;
}
.mugshot img { width: 100%; height: 100%; object-fit: cover; }
.mugshot.lg { width: 160px; height: 200px; }
/* ---------- Timeline (call log / history) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--hairline);
}
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13px; }
.timeline li::before {
  content: ""; position: absolute; left: 0; top: 5px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--hairline);
}
.timeline li.tl-status::before { border-color: var(--accent); }
.timeline li.tl-panic::before { border-color: var(--st-panic); background: var(--st-panic); }
.timeline .tl-time { font-family: var(--font-mono); color: var(--text-dim); font-size: 11px; display: block; }
/* ---------- App shell: command bar + sidebar ---------- */
.app-shell { display: grid; grid-template-rows: 48px 1fr; min-height: 100vh; }
/* status toggle in the command bar */
.status-toggle { display: flex; gap: 4px; }
.status-toggle button {
  font: 700 10px/1 var(--font-mono);
  padding: 6px 7px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--hairline); cursor: pointer;
  letter-spacing: .03em;
}
.status-toggle button:hover { color: var(--text); }
.status-toggle button.on-available { background: var(--st-available); border-color: var(--st-available); color: #04120a; }
.status-toggle button.on-busy,
.status-toggle button.on-enroute { background: var(--st-busy); border-color: var(--st-busy); color: #201200; }
.status-toggle button.on-onscene { background: var(--st-scene); border-color: var(--st-scene); color: #fff; }
.status-toggle button.on-out { background: var(--st-out); border-color: var(--st-out); color: #fff; }
.content-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.content-head h1 { margin: 0; font-size: 20px; }
/* ---------- Utility ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2, .grid-3 { grid-template-columns: 1fr; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; }
.kv dd.mono { font-family: var(--font-mono); color: var(--text-mono); }
.hr { border: none; border-top: 1px solid var(--hairline); margin: 14px 0; }
.status-flash { animation: status-flash-once .5s ease; }

/* ---------- Keyframes ---------- */
@keyframes panic-flash {
  0% { background: color-mix(in srgb, var(--st-panic) 60%, var(--surface-2)); }
  100% { background: color-mix(in srgb, var(--st-panic) 15%, var(--surface-2)); }
}
@keyframes p1-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--p1) 55%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes status-flash-once { 0% { background: color-mix(in srgb, var(--accent) 30%, transparent); } }
