/* ============================================================
   LHS Fire Admin Portal — common.css
   Upload to: public/assets/common.css
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --navy:         #0A2A4A;
  --navy-header:  #071E35;
  --teal:         #2596BE;
  --teal-light:   #E8F4F9;
  --teal-mid:     #C2E0EE;
  --red:          #DB3A34;
  --amber:        #F2AE26;
  --green:        #2D9E5F;
  --light-grey:   #F5F7F9;
  --border:       #E1E5EA;
  --white:        #ffffff;
  --text:         #282828;
  --muted:        #5A5A5A;

  --sidebar-width: 230px;
  --header-height: 58px;
  --radius:        6px;
  --radius-lg:     10px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.14);
  --transition:    0.18s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 15px; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--light-grey);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--navy-header);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar-logo {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-logo img {
  height: 32px;
  width: auto;
}
.sidebar-logo .logo-text {
  color: var(--white);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 14px 18px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(255,255,255,.72);
  font-size: .875rem;
  font-weight: 400;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--white);
  text-decoration: none;
}
.nav-item.active {
  border-left-color: var(--teal);
  background: rgba(37,150,190,.14);
  color: var(--white);
  font-weight: 500;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .8;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--teal);
  color: var(--white);
  font-size: .68rem;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nav-badge.red { background: var(--red); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 600;
  color: var(--white);
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: .82rem;
  font-weight: 500;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: .72rem;
  color: rgba(255,255,255,.45);
}

/* ── Main Content Area ──────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
  flex: 1;
}
.page-header .header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  flex: 1;
  padding: 24px;
}

/* ── Breadcrumb ─────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--teal); }
.breadcrumb-sep { color: var(--border); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--navy);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--light-grey);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Stat Cards ─────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-sub {
  font-size: .78rem;
  color: var(--muted);
}
.stat-card.teal  { border-top: 3px solid var(--teal); }
.stat-card.green { border-top: 3px solid var(--green); }
.stat-card.amber { border-top: 3px solid var(--amber); }
.stat-card.red   { border-top: 3px solid var(--red); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), border-color var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.btn-primary {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}
.btn-primary:hover { background: #1d80a6; border-color: #1d80a6; box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--light-grey); border-color: #ccd1d9; }

.btn-danger {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.btn-danger:hover { background: #c2322c; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--light-grey); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-icon { padding: 7px; }

.btn:disabled, .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Form Elements ──────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}
.form-label {
  font-size: .83rem;
  font-weight: 500;
  color: var(--text);
}
.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}
.form-control:hover { border-color: #b0bac5; }
.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(37,150,190,.15);
}
.form-control.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(219,58,52,.12);
}
.form-control::placeholder { color: #9aa5b4; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: .78rem;
  color: var(--muted);
}
.form-error {
  font-size: .78rem;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tables ─────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  background: var(--white);
}
thead th {
  background: var(--light-grey);
  padding: 11px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--light-grey); }
tbody td { padding: 11px 14px; color: var(--text); vertical-align: middle; }
.table-ref {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .8rem;
  color: var(--navy);
  font-weight: 500;
}
.table-actions { display: flex; gap: 6px; align-items: center; }
.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: .875rem;
}

/* ── Badges / Status Pills ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: .73rem;
  font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-teal    { background: var(--teal-light);         color: #1a6e8e; }
.badge-green   { background: rgba(45,158,95,.12);       color: #1e7044; }
.badge-amber   { background: rgba(242,174,38,.15);      color: #9b6b00; }
.badge-red     { background: rgba(219,58,52,.12);       color: #a52b27; }
.badge-navy    { background: rgba(10,42,74,.1);         color: var(--navy); }
.badge-grey    { background: var(--light-grey);         color: var(--muted); border: 1px solid var(--border); }

/* Status-specific shorthands */
.badge-active      { background: rgba(45,158,95,.12);  color: #1e7044; }
.badge-suspended   { background: rgba(242,174,38,.15); color: #9b6b00; }
.badge-archived    { background: var(--light-grey);    color: var(--muted); border: 1px solid var(--border); }
.badge-open        { background: var(--teal-light);    color: #1a6e8e; }
.badge-complete    { background: rgba(45,158,95,.12);  color: #1e7044; }
.badge-invoiced    { background: rgba(10,42,74,.1);    color: var(--navy); }
.badge-cancelled   { background: var(--light-grey);    color: var(--muted); border: 1px solid var(--border); }

/* ── Alerts / Banners ───────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  border-left: 4px solid;
  margin-bottom: 16px;
}
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-teal  { background: var(--teal-light); border-color: var(--teal);  color: #1a6e8e; }
.alert-green { background: rgba(45,158,95,.1); border-color: var(--green); color: #1e7044; }
.alert-amber { background: rgba(242,174,38,.12); border-color: var(--amber); color: #9b6b00; }
.alert-red   { background: rgba(219,58,52,.1);  border-color: var(--red);   color: #a52b27; }

.suspended-banner {
  background: rgba(242,174,38,.18);
  border: 1px solid rgba(242,174,38,.5);
  border-left: 4px solid var(--amber);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  color: #7a5200;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,30,53,.55);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 600; color: var(--navy); }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--light-grey); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px;
}
.page-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  font-size: .83rem;
  transition: background var(--transition), border-color var(--transition);
}
.page-btn:hover { background: var(--light-grey); }
.page-btn.active { background: var(--teal); border-color: var(--teal); color: var(--white); font-weight: 600; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.pagination-info { font-size: .8rem; color: var(--muted); margin-left: auto; }

/* ── Filter Bar ─────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar .form-control { width: auto; min-width: 0; }
.filter-bar .search-input { flex: 1; min-width: 200px; }

/* ── Loading / Skeleton ─────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e8ecf0 25%, #f0f3f6 50%, #e8ecf0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-h2    { height: 22px; width: 60%; margin-bottom: 12px; }
.skeleton-block { height: 48px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 10;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--teal-mid);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast Notifications ────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: .875rem;
  max-width: 360px;
  pointer-events: all;
  animation: toast-in .22s ease forwards;
  border-left: 4px solid;
  background: var(--white);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.fade-out {
  animation: toast-out .2s ease forwards;
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}
.toast-success { border-color: var(--green); }
.toast-error   { border-color: var(--red); }
.toast-warning { border-color: var(--amber); }
.toast-info    { border-color: var(--teal); }
.toast-title   { font-weight: 600; color: var(--text); }
.toast-body    { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* ── Search + Detail split layout ──────────────────────── */
.split-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
.list-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.list-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--light-grey); }
.list-item.selected { background: var(--teal-light); border-left: 3px solid var(--teal); padding-left: 13px; }
.list-item-title { font-weight: 500; font-size: .875rem; color: var(--text); }
.list-item-sub   { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ── Detail Panel Tabs ──────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  overflow-x: auto;
  background: var(--white);
}
.tab-btn {
  padding: 12px 18px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }
.tab-content { display: none; padding: 20px; }
.tab-content.active { display: block; }

/* ── Utility Classes ────────────────────────────────────── */
.text-muted    { color: var(--muted); }
.text-teal     { color: var(--teal); }
.text-red      { color: var(--red); }
.text-green    { color: var(--green); }
.text-amber    { color: var(--amber); }
.text-navy     { color: var(--navy); }
.text-sm       { font-size: .8rem; }
.text-xs       { font-size: .72rem; }
.font-mono     { font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

.d-flex        { display: flex; }
.d-none        { display: none !important; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.flex-1        { flex: 1; }

.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.p-0   { padding: 0; }
.p-16  { padding: 16px; }
.p-20  { padding: 20px; }

.w-full { width: 100%; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .split-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-width: 56px; }
  .sidebar-logo .logo-text,
  .nav-item span,
  .nav-section-label,
  .sidebar-user-info { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item .nav-icon { margin: 0; }
  .sidebar-logo { justify-content: center; padding: 0; }
  .nav-badge { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-body { padding: 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}