/* ==========================================================================
   SOVEREIGN ROSTER — PAGES
   Specific styling for Control Room, Dashboard, Roster, Guards, Import, Settings, Auth
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Dashboard (KPI Strip & CSS Hours Chart)
   -------------------------------------------------------------------------- */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (max-width: 1200px) {
  .dashboard-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .dashboard-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-tile-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.kpi-tile-link:hover .stat-tile {
  border-color: var(--blue-500);
  background-color: var(--blue-50);
}

/* CSS-only Bar Chart for Hours */
.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  height: 140px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.chart-bar {
  width: 100%;
  max-width: 36px;
  background-color: var(--blue-600);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: background-color 0.15s ease;
}

.chart-bar:hover {
  background-color: var(--blue-800);
}

.chart-bar.is-today {
  background-color: var(--gold-600);
}

.chart-bar-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.chart-bar-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   2. Control Room
   -------------------------------------------------------------------------- */
.cr-quickfind {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.cr-sections-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

@media (max-width: 1100px) {
  .cr-sections-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .cr-sections-grid {
    grid-template-columns: 1fr;
  }
}

.cr-card {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-top: 3px solid var(--cat, var(--blue-600));
  border-radius: var(--radius-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cr-card-body {
  padding: var(--space-4);
  flex: 1 1 auto;
}

.cr-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.cr-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.cr-total {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.cr-active-sub {
  font-size: var(--font-size-meta);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Stacked horizontal bar of SIA state */
.cr-stacked-bar {
  display: flex;
  height: 8px;
  border-radius: 2px;
  overflow: hidden;
  background-color: var(--fill-subtle);
  margin-bottom: var(--space-2);
}

.cr-stacked-seg {
  height: 100%;
}
.cr-seg-valid { background-color: var(--status-success-text); }
.cr-seg-expiring { background-color: var(--gold-600); }
.cr-seg-expired { background-color: var(--status-danger-text); }
.cr-seg-missing { background-color: var(--border-input); }

.cr-legend {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.cr-legend-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.cr-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
}

/* 3 Compact Links with counts */
.cr-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-hairline);
}

.cr-link-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-meta);
  color: var(--text-secondary);
  text-decoration: none;
  padding: 2px 0;
}

.cr-link-row:hover {
  color: var(--blue-600);
}

.cr-link-count {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cr-card-footer {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-hairline);
  background-color: var(--fill-subtle);
}

.cr-open-btn {
  display: block;
  text-align: center;
  font-weight: 600;
  font-size: var(--font-size-meta);
  color: var(--blue-600);
  text-decoration: none;
}
.cr-open-btn:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   3. Guards List & Table
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  margin-bottom: var(--space-3);
}

.filter-bar .form-control,
.filter-bar .form-select {
  width: auto;
  min-width: 130px;
}

.guard-initials {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  background-color: var(--blue-100);
  color: var(--blue-800);
  font-weight: 600;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--space-2);
  vertical-align: middle;
}

/* --------------------------------------------------------------------------
   4. Guard Profile
   -------------------------------------------------------------------------- */
.profile-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.profile-initials-large {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  background: var(--blue-950);
  color: var(--gold-500);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 56px;
}

.profile-meta-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 var(--space-1);
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Compliance Panel (Two Equal Blocks) */
.compliance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (max-width: 768px) {
  .compliance-grid {
    grid-template-columns: 1fr;
  }
}

.compliance-block {
  background: var(--surface);
  border: var(--border-hairline-width) solid var(--border-hairline);
  border-radius: var(--radius-panel);
  padding: var(--space-4);
}

.compliance-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.compliance-status-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

/* Profile Tabs without a framework */
.profile-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-hairline);
  margin-bottom: var(--space-4);
  gap: var(--space-2);
}

.profile-tab {
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  font-size: var(--font-size-body);
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.profile-tab:hover {
  color: var(--blue-600);
}

.profile-tab.active {
  color: var(--blue-600);
  border-bottom-color: var(--blue-600);
}

/* --------------------------------------------------------------------------
   5. Form Section & Checklist Rail
   -------------------------------------------------------------------------- */
.form-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: var(--space-6);
  align-items: flex-start;
}

@media (max-width: 992px) {
  .form-layout {
    grid-template-columns: 1fr;
  }
  .form-rail {
    display: none;
  }
}

.form-rail {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-panel);
  padding: var(--space-3);
}

.rail-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
}

.rail-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-meta);
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-tag);
}

.rail-item.active,
.rail-item:hover {
  background-color: var(--fill-subtle);
  color: var(--blue-600);
}

.rail-item.complete {
  color: var(--status-success-text);
}

/* --------------------------------------------------------------------------
   6. Import (3-Step Indicator)
   -------------------------------------------------------------------------- */
.import-steps-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-panel);
}

.import-step-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-table);
  font-weight: 600;
  color: var(--text-muted);
}

.import-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--fill-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.import-step-item.active {
  color: var(--blue-600);
}

.import-step-item.active .import-step-num {
  background: var(--blue-600);
  color: #ffffff;
}

.import-step-item.complete {
  color: var(--status-success-text);
}

.import-step-item.complete .import-step-num {
  background: var(--status-success-bg);
  color: var(--status-success-text);
}

/* --------------------------------------------------------------------------
   7. Roster Grid
   -------------------------------------------------------------------------- */
.roster-wrap {
  overflow: auto;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-panel);
  background: var(--surface);
  max-height: calc(100vh - 270px);
  min-height: 320px;
}

table.roster {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1100px;
  table-layout: fixed;
}

table.roster th,
table.roster td {
  border-right: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: top;
  padding: 4px;
}

table.roster thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--fill-subtle);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 6px;
}

table.roster thead th small {
  display: block;
  color: var(--text-muted);
  font-weight: 500;
}

table.roster th.rowhead,
table.roster td.rowhead {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 200px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border-hairline);
}

table.roster thead th.rowhead {
  z-index: 5;
  background: var(--fill-subtle);
}

/* Today column marked with a thin gold top rule */
table.roster .is-today {
  background-color: var(--gold-100);
}

table.roster thead th.is-today {
  background-color: #fbf3d9;
  border-top: 2px solid var(--gold-600);
  color: #705411;
}

/* Compact shift blocks with 3px left border */
.shift-chip {
  --c: var(--blue-600);
  display: block;
  border-left: 3px solid var(--c);
  border-radius: var(--radius-tag);
  padding: 3px 5px;
  margin-bottom: 3px;
  font-size: 11px;
  line-height: 1.25;
  background: var(--fill-subtle);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
}

.shift-chip:hover {
  background: var(--blue-50);
}

.shift-chip .t {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.shift-chip .who {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shift-chip.night {
  --c: #553bb8;
  background: #f4f2fa;
}

.shift-chip.open,
.shift-chip.unassigned {
  --c: var(--status-danger-text);
  background: var(--status-danger-bg);
}

.shift-chip.cancelled,
.shift-chip.no_show {
  --c: var(--text-muted);
  background: var(--fill-subtle);
  color: var(--text-muted);
  text-decoration: line-through;
}

/* --------------------------------------------------------------------------
   8. Settings Sub-Navigation
   -------------------------------------------------------------------------- */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-6);
  align-items: flex-start;
}

@media (max-width: 768px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

.settings-subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-panel);
  padding: var(--space-2);
}

.settings-nav-item {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-table);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-button);
  text-decoration: none;
}

.settings-nav-item:hover {
  background: var(--fill-subtle);
  color: var(--text-primary);
}

.settings-nav-item.active {
  background: var(--blue-50);
  color: var(--blue-600);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   9. Auth / Login / First-Run Setup (Two Column)
   -------------------------------------------------------------------------- */
.auth-shell,
.auth-split-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  background: var(--surface);
}

@media (max-width: 900px) {
  .auth-shell,
  .auth-split-shell {
    grid-template-columns: 1fr;
  }
  .auth-art,
  .auth-brand-pane {
    display: none;
  }
}

.auth-art,
.auth-brand-pane {
  background-color: var(--blue-950) !important;
  color: #ffffff;
  padding: var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

/* Faint diagonal slash pattern (60° stripes, 6% opacity) */
.auth-art::before,
.auth-brand-pane::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    60deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.06) 1px,
    transparent 1px,
    transparent 16px
  );
  pointer-events: none;
}

.auth-art::after,
.auth-brand-pane::after {
  display: none !important; /* No glowing orbs */
}

.auth-art h2,
.auth-brand-pane h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: var(--space-2);
  line-height: 1.25;
}

.auth-art p,
.auth-brand-pane p {
  color: #a9b9d6;
  font-size: var(--font-size-body);
  max-width: 40ch;
}

.auth-points {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0;
  display: grid;
  gap: var(--space-2);
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: #c9d6ee;
  font-size: var(--font-size-table);
}

.auth-points i {
  color: var(--gold-500);
  font-size: 16px;
}

.auth-form,
.auth-form-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background-color: var(--bg-page);
}

.auth-card,
.auth-form-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-panel);
  padding: var(--space-6);
  box-shadow: none;
}


/* --------------------------------------------------------------------------
   10. Print Stylesheet
   -------------------------------------------------------------------------- */
@media print {
  .navbar-vertical,
  .topbar,
  .d-print-none,
  .btn,
  .pagination,
  .table-toolbar,
  .skip-link {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
  }

  .page-wrapper {
    margin: 0 !important;
    padding: 0 !important;
  }

  .panel,
  .card,
  .compliance-block {
    box-shadow: none !important;
    border: 1px solid #999999 !important;
    page-break-inside: avoid;
  }

  .roster-wrap {
    max-height: none !important;
    overflow: visible !important;
  }

  table.roster {
    min-width: 100% !important;
    font-size: 8pt;
  }
}
