/* ===========================================================================
   OpsTrak by ReaperNetworks — shared stylesheet
   Bootstrap 5 supplies the base; this layers platform identity, the Central
   Hub tiles, and print rules. Theming uses Bootstrap's data-bs-theme.
   =========================================================================== */

@import url('https://cdn.jsdelivr.net/npm/@fontsource-variable/inter@5/index.css');

/* === OpsTrak design tokens — modern refresh (Phase 1) ======================
   Backward compatible: --ems-brand / --ems-accent keep their names. Swap the
   two brand values to re-skin the whole app. Light surfaces live on :root;
   dark surfaces override below. ============================================ */
:root {
  /* Brand — change these two to recolor everything */
  --ems-brand: #0f766e;
  --ems-accent: #0d9488;
  --ems-brand-rgb: 15, 118, 110;
  --ems-accent-rgb: 13, 148, 136;
  --ems-brand-hover: #0c5e57;
  --ems-brand-soft: color-mix(in srgb, var(--ems-brand) 12%, transparent);
  --ems-accent-soft: color-mix(in srgb, var(--ems-accent) 14%, transparent);

  /* Shape, depth, motion */
  --bs-border-radius: .6rem;
  --bs-border-radius-sm: .4rem;
  --bs-border-radius-lg: .85rem;
  --bs-border-radius-xl: 1.1rem;
  --ems-shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
  --ems-shadow-md: 0 6px 18px -6px rgba(16,24,40,.18);
  --ems-ease: .16s cubic-bezier(.4,0,.2,1);

  /* Typography */
  --bs-body-font-family: 'Inter Variable', 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Light surfaces (default) */
  --bs-body-bg: #f4f6f9;
  --bs-body-color: #1b2733;
  --bs-secondary-bg: #ffffff;
  --bs-tertiary-bg: #eef2f6;
  --bs-secondary-color: #5a6b7a;
  --bs-border-color: #e3e8ee;
  --bs-border-color-translucent: rgba(16,24,40,.1);
  --bs-card-bg: #ffffff;
  --bs-link-color-rgb: 15, 118, 110;
  --bs-link-hover-color-rgb: 12, 94, 87;
}

/* Dark surfaces — refined slate, not pure black */
[data-bs-theme="dark"] {
  --bs-body-bg: #0e131a;
  --bs-body-color: #e4ebf2;
  --bs-secondary-bg: #161d26;
  --bs-tertiary-bg: #121922;
  --bs-secondary-color: #93a3b4;
  --bs-border-color: #232e3a;
  --bs-border-color-translucent: rgba(255,255,255,.09);
  --bs-card-bg: #141b24;
  --ems-accent: #2dd4bf;
  --ems-accent-rgb: 45, 212, 191;
  --bs-link-color-rgb: var(--ems-accent-rgb);
  --bs-link-hover-color-rgb: 153, 225, 217;
}

body { min-height: 100vh; }
h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 { letter-spacing: -.01em; }

/* === Brand helpers ========================================================= */
.text-brand { color: var(--ems-accent) !important; }
.bg-brand { background-color: var(--ems-brand) !important; }
.btn-brand {
  background-color: var(--ems-brand);
  border-color: var(--ems-brand);
  color: #fff;
  font-weight: 500;
}
.btn-brand:hover { background-color: var(--ems-brand-hover); border-color: var(--ems-brand-hover); color: #fff; }
.btn-brand:focus-visible { box-shadow: 0 0 0 .25rem rgba(var(--ems-accent-rgb), .4); }
.btn-brand:disabled, .btn-brand.disabled {
  background-color: color-mix(in srgb, var(--ems-brand) 55%, #7c8694);
  border-color: transparent; color: #fff; opacity: .9;
}
.btn-brand-subtle {
  background-color: var(--ems-brand-soft);
  border-color: transparent;
  color: var(--ems-accent);
  font-weight: 500;
}
.btn-brand-subtle:hover { background-color: var(--ems-brand); border-color: var(--ems-brand); color: #fff; }

/* === Component polish (cascades to every Bootstrap component) =============== */
.card { box-shadow: var(--ems-shadow-sm); }
.form-control, .form-select { border-radius: var(--bs-border-radius); }
.form-control:focus, .form-select:focus {
  border-color: var(--ems-accent);
  box-shadow: 0 0 0 .2rem rgba(var(--ems-accent-rgb), .22);
}
.dropdown-menu { border-radius: var(--bs-border-radius-lg); box-shadow: var(--ems-shadow-md); }
.badge { font-weight: 500; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

.navbar-logo { max-height: 36px; width: auto; }

/* ---- Central Hub module tiles -------------------------------------------- */
.hub-tile {
  display: block;
  height: 100%;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.hub-tile:hover {
  transform: translateY(-3px);
}
.hub-tile .card {
  height: 100%;
}
.hub-tile .hub-icon {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--ems-accent);
}

/* ---- Welcome dashboard ---------------------------------------------------- */
.hub-hero {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--ems-accent) 16%, var(--bs-body-bg)),
    var(--bs-body-bg) 70%);
}
.hub-stat {
  transition: transform .12s ease, box-shadow .12s ease;
}
.hub-stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.12) !important;
}
.hub-stat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: .65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex: 0 0 auto;
}
.hub-tile .hub-tile-arrow {
  opacity: 0;
  transition: opacity .12s ease, transform .12s ease;
  vertical-align: -2px;
}
.hub-tile:hover .hub-tile-arrow {
  opacity: 1;
  transform: translateX(2px);
}

/* Coming-soon preview tiles (non-clickable roadmap) */
.hub-soon { opacity: .7; }
.hub-soon .hub-icon-muted {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--bs-secondary-color);
}

/* Notification + announcement accents */
.announcement-item { border-left: 4px solid var(--ems-accent); }

/* ---- Logout warning modal ------------------------------------------------- */
#idleWarningModal .modal-content { border: 2px solid var(--bs-warning); }

/* ---- Print styles --------------------------------------------------------- */
@media print {
  nav.navbar, .app-sidebar, .app-topbar, footer, .btn, .js-print, .no-print,
  .dropdown, #idleWarningModal, .nav-tabs, .nav-pills {
    display: none !important;
  }
  .app-shell, .app-content { display: block !important; min-height: 0 !important; }
  :root, html[data-bs-theme="dark"], [data-bs-theme="dark"] {
    --bs-body-bg: #ffffff !important;
    --bs-body-color: #000000 !important;
    --bs-card-bg: #ffffff !important;
    --bs-tertiary-bg: #ffffff !important;
    --bs-border-color: #cccccc !important;
    color-scheme: light !important;
  }
  html, body, main, .app-main, .container, .card, .card-body, .card-header {
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
  }
  .card { border: 0 !important; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .print-title { display: block !important; }
}
.print-title { display: none; }

/* ---- FleetTrak Kanban board ---------------------------------------------- */
.ft-kanban {
  display: flex;
  gap: .75rem;
  overflow-x: auto;
  padding-bottom: .5rem;
}
.ft-kan-col {
  flex: 0 0 240px;
  min-width: 240px;
  background: var(--bs-tertiary-bg);
  border-radius: .5rem;
  display: flex;
  flex-direction: column;
}
.ft-kan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem .65rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.ft-kan-body {
  padding: .5rem;
  min-height: 60px;
  flex: 1 1 auto;
  transition: background .12s ease;
}
.ft-kan-body.over { background: color-mix(in srgb, var(--ems-accent) 14%, transparent); }
.ft-kan-card {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: .45rem;
  padding: .5rem .6rem;
  margin-bottom: .5rem;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.ft-kan-card:last-child { margin-bottom: 0; }
.ft-kan-card.dragging { opacity: .5; }
.ft-kan-card[draggable="false"] { cursor: default; }

/* ---- Hub birthday banner -------------------------------------------------- */
.hub-birthday {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bs-warning) 18%, var(--bs-body-bg)),
    var(--bs-body-bg) 75%);
  border-left: 4px solid var(--bs-warning) !important;
}

/* ---- FacilityTrak Kanban board ------------------------------------------- */
.fac-kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.fac-kan-col { flex: 0 0 230px; min-width: 230px; background: var(--bs-tertiary-bg); border-radius: .5rem; display: flex; flex-direction: column; }
.fac-kan-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .65rem; border-bottom: 1px solid var(--bs-border-color); }
.fac-kan-body { padding: .5rem; min-height: 60px; flex: 1 1 auto; transition: background .12s ease; }
.fac-kan-body.over { background: color-mix(in srgb, var(--ems-accent) 14%, transparent); }
.fac-kan-card { background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .45rem; padding: .5rem .6rem; margin-bottom: .5rem; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.fac-kan-card:last-child { margin-bottom: 0; }
.fac-kan-card.dragging { opacity: .5; }
.fac-kan-card[draggable="false"] { cursor: default; }

/* ---- FacilityTrak calendar ----------------------------------------------- */
.fac-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.fac-cal-dow { text-align: center; font-size: .75rem; font-weight: 600; color: var(--bs-secondary-color); padding: 4px 0; }
.fac-cal-cell { min-height: 92px; border: 1px solid var(--bs-border-color); border-radius: .4rem; padding: 3px 4px; background: var(--bs-body-bg); overflow: hidden; }
.fac-cal-empty { background: transparent; border: none; }
.fac-cal-today { border-color: var(--ems-accent); box-shadow: inset 0 0 0 1px var(--ems-accent); }
.fac-cal-day { font-size: .8rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: 2px; }
.fac-cal-event { display: block; font-size: .68rem; line-height: 1.2; padding: 1px 4px; border-radius: 3px; margin-bottom: 2px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- EventTrak calendar --------------------------------------------------- */
.et-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.et-cal-dow { text-align: center; font-size: .75rem; font-weight: 600; color: var(--bs-secondary-color); padding: 4px 0; }
.et-cal-cell { min-height: 96px; border: 1px solid var(--bs-border-color); border-radius: .4rem; padding: 3px 4px; background: var(--bs-body-bg); overflow: hidden; }
.et-cal-empty { background: transparent; border: none; }
.et-cal-today { border-color: var(--ems-accent); box-shadow: inset 0 0 0 1px var(--ems-accent); }
.et-cal-day { font-size: .8rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: 2px; }
.et-cal-event { display: block; font-size: .68rem; line-height: 1.25; padding: 1px 4px; border-radius: 3px; margin-bottom: 2px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------------------
   BriefingTrak: stack wide incident tables into labeled blocks on phones.
   Applied to tables with .bt-stack-sm. Theme-aware via Bootstrap variables.
--------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  table.bt-stack-sm thead { display: none; }
  table.bt-stack-sm,
  table.bt-stack-sm tbody,
  table.bt-stack-sm tr,
  table.bt-stack-sm td { display: block; width: 100%; }
  table.bt-stack-sm tr {
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    padding: .5rem .75rem;
    margin-bottom: .75rem;
  }
  table.bt-stack-sm td {
    border: none !important;
    padding: .2rem 0;
  }
  table.bt-stack-sm td::before {
    content: attr(data-label);
    display: block;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--bs-secondary-color);
    font-weight: 600;
    margin-bottom: .1rem;
  }
  /* Hide empty read-only cells (and their labels) so blank fields don't clutter. */
  table.bt-stack-sm td:empty { display: none; }
}

/* Numbered step badges used by multi-step module forms (EduTrak, BriefingTrak). */
.bt-step{display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;border-radius:50%;background:var(--ems-brand,#0d6efd);color:#fff;font-size:.8rem;font-weight:600;margin-right:.5rem;flex-shrink:0;}

/* ===========================================================================
 * Guided Tours (assets/js/tour.js) — spotlight overlay + coachmark popover.
 * Theme-aware via Bootstrap --bs-* tokens; sits above the sticky navbar/modals.
 * ======================================================================== */
#opstour{position:fixed;inset:0;z-index:20000;pointer-events:none;}
#opstour[aria-hidden="true"]{display:none;}
.opstour-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.55);pointer-events:auto;}
.opstour-hole{position:fixed;border-radius:.5rem;box-shadow:0 0 0 9999px rgba(0,0,0,.55);
  outline:2px solid var(--ems-accent,#ffc107);outline-offset:2px;transition:all .15s ease;pointer-events:none;}
.opstour-pop{position:fixed;z-index:20001;width:340px;max-width:calc(100vw - 16px);
  background:var(--bs-body-bg,#212529);color:var(--bs-body-color,#dee2e6);
  border:1px solid var(--bs-border-color,rgba(255,255,255,.15));border-radius:.6rem;
  box-shadow:0 .5rem 1.5rem rgba(0,0,0,.4);padding:1rem 1rem .75rem;pointer-events:auto;}
.opstour-pop.opstour-pop-center{top:50% !important;left:50% !important;transform:translate(-50%,-50%);}
.opstour-x{position:absolute;top:.35rem;right:.5rem;border:none;background:none;font-size:1.4rem;line-height:1;
  color:var(--bs-secondary-color,#adb5bd);cursor:pointer;padding:.1rem .3rem;}
.opstour-x:hover{color:var(--bs-body-color,#fff);}
.opstour-title{font-weight:600;font-size:1.02rem;margin-bottom:.35rem;padding-right:1.2rem;}
.opstour-body{font-size:.9rem;color:var(--bs-secondary-color,#adb5bd);margin-bottom:.75rem;line-height:1.4;}
.opstour-foot{display:flex;align-items:center;justify-content:space-between;gap:.5rem;}
.opstour-count{font-size:.75rem;color:var(--bs-secondary-color,#adb5bd);}
.opstour-btns{display:flex;gap:.4rem;}
@media (max-width:576px){
  .opstour-pop{width:auto;left:8px;right:8px;transform:none;}
  .opstour-pop.opstour-pop-center{top:auto !important;bottom:12px;transform:none;}
}

/* ===========================================================================
 * App shell — sidebar navigation layout (Phase 2)
 * Static sidebar on desktop (lg+); Bootstrap off-canvas drawer on mobile.
 * ======================================================================== */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.app-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app-main { flex: 1 1 auto; width: 100%; padding: 1.35rem 1.35rem 2rem; }
@media (max-width: 575.98px) { .app-main { padding: 1rem .85rem 1.5rem; } }

.app-sidebar { background: var(--bs-secondary-bg); }
@media (min-width: 992px) {
  .app-sidebar {
    flex: 0 0 248px; width: 248px;
    position: sticky; top: 0; height: 100vh; align-self: flex-start;
    border-right: 1px solid var(--bs-border-color);
  }
}
.app-sidebar.offcanvas-lg { --bs-offcanvas-width: 256px; }
.app-sidebar-body { display: flex; flex-direction: column; gap: .12rem; height: 100%; padding: .85rem .7rem; overflow-y: auto; }

.app-brand { display: flex; align-items: center; gap: .6rem; min-width: 0; padding: .35rem .55rem .85rem; text-decoration: none; color: var(--bs-body-color); }
.app-brand .app-brand-mark {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
  background: var(--ems-brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.app-brand .navbar-logo { max-height: 34px; }

.app-nav-link {
  display: flex; align-items: center; gap: .7rem; white-space: nowrap;
  padding: .5rem .6rem; border-radius: .55rem;
  color: var(--bs-secondary-color); text-decoration: none;
  font-size: .92rem; font-weight: 500;
  transition: background var(--ems-ease), color var(--ems-ease);
}
.app-nav-link > i { flex: 0 0 auto; width: 1.3rem; text-align: center; font-size: 1.1rem; }
.app-nav-link > span { overflow: hidden; text-overflow: ellipsis; }
.app-nav-link:hover { background: var(--bs-tertiary-bg); color: var(--bs-body-color); }
.app-nav-link.active { background: var(--ems-brand-soft); color: var(--ems-accent); }
.app-nav-section {
  padding: .9rem .65rem .3rem; font-weight: 600;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--bs-secondary-color);
}

.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .5rem;
  min-height: 56px; padding: .5rem .9rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
}

/* ===========================================================================
 * Hub redesign (Phase 3) — CSS-only polish over the existing hub-* markup.
 * ======================================================================== */
.hub-hero {
  border: 1px solid var(--bs-border-color);
  background:
    radial-gradient(130% 150% at 100% 0%, var(--ems-brand-soft), transparent 55%),
    var(--bs-secondary-bg);
}
.hub-hero h1 { letter-spacing: -.02em; }

/* Lift interactive cards on hover (cockpit + module tiles) */
[data-tour="hub.cockpit"] > [class*="col"] > .card,
.hub-tile .card {
  transition: transform var(--ems-ease), box-shadow var(--ems-ease);
}
[data-tour="hub.cockpit"] > [class*="col"] > .card:hover,
.hub-tile:hover .card {
  transform: translateY(-2px);
  box-shadow: var(--ems-shadow-md);
}

/* Cockpit headline numbers in the brand accent */
[data-tour="hub.cockpit"] .display-6 { color: var(--ems-accent); letter-spacing: -.02em; }

/* Module + coming-soon icons become rounded badges */
.hub-tile .hub-icon, .hub-soon .hub-icon-muted {
  width: 2.9rem; height: 2.9rem; flex: 0 0 auto; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: .8rem; font-size: 1.4rem;
}
.hub-tile .hub-icon { background: var(--ems-brand-soft); color: var(--ems-accent); transition: background var(--ems-ease), color var(--ems-ease); }
.hub-tile:hover .hub-icon { background: var(--ems-brand); color: #fff; }
.hub-soon .hub-icon-muted { background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }

/* Rounder stat badge + pill progress bars */
.hub-stat-icon { border-radius: .8rem; }
.progress { border-radius: 999px; }

/* ===========================================================================
 * Component sweep (Phase 4) — unify the brand accent across Bootstrap
 * components + keyboard focus. CSS-only; cascades to every module.
 * ======================================================================== */
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background-color: var(--ems-brand); }
.nav-tabs .nav-link.active { color: var(--ems-accent); }
.page-item.active .page-link { background-color: var(--ems-brand); border-color: var(--ems-brand); }
.page-link { color: var(--ems-accent); }
.form-check-input:checked { background-color: var(--ems-brand); border-color: var(--ems-brand); }
.form-check-input:focus { border-color: var(--ems-accent); box-shadow: 0 0 0 .2rem rgba(var(--ems-accent-rgb), .22); }
.btn:focus-visible { box-shadow: 0 0 0 .25rem rgba(var(--ems-accent-rgb), .35); }
.table-hover > tbody > tr:hover > * { background-color: var(--ems-brand-soft); }
.modal-content { border-radius: var(--bs-border-radius-lg); }
