/* ─── Light Theme (default) ──────────────────────────────────── */
:root,
[data-theme="light"] {
  /* Spacing & Layout */
  --topbar-height: 64px;
  --content-padding: 22px;

  /* Surface & Background */
  --bg:              #f4f7fb;
  --bg-top:          #eef4f8;
  --surface:         #ffffff;
  --surface-soft:    #f8fafc;
  --surface-accent:  #ecf7f5;
  --border:          #e5e7eb;

  /* Text */
  --text:   #0f172a;
  --muted:  #64748b;

  /* Brand / Primary */
  --primary:        #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft:   #dff4f1;

  /* Status */
  --success:      #15803d;
  --success-soft: #e9f8ef;
  --warning:      #b45309;
  --warning-soft: #fff7e8;
  --danger:       #dc2626;
  --danger-soft:  #feeceb;

  /* Shadow */
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);

  /* Topbar — stays dark in both modes for brand consistency */
  --topbar-bg:     #1e2433;
  --topbar-text:   #f1f5f9;
  --topbar-muted:  #94a3b8;
  --topbar-border: #2d3748;

  /* Sidebar */
  --sidebar-bg:          #f0f2f5;
  --sidebar-text:        #374151;
  --sidebar-hover:       #e4e7eb;
  --sidebar-active-bg:   #e8f3f2;
  --sidebar-active-text: #0f766e;

  /* Border Radius */
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm:  8px;
}

/* ─── Dark Theme ─────────────────────────────────────────────── */
[data-theme="dark"] {
  /* Surface & Background */
  --bg:              #0b1220;
  --bg-top:          #08111d;
  --surface:         #111827;
  --surface-soft:    #172132;
  --surface-accent:  #132621;
  --border:          #243041;

  /* Text */
  --text:  #e5e7eb;
  --muted: #94a3b8;

  /* Brand / Primary */
  --primary:        #34d399;
  --primary-strong: #10b981;
  --primary-soft:   rgba(52, 211, 153, 0.14);

  /* Status */
  --success:      #4ade80;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning:      #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --danger:       #f87171;
  --danger-soft:  rgba(239, 68, 68, 0.12);

  /* Shadow */
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.32);

  /* Topbar — slightly deeper in dark mode */
  --topbar-bg:     #070e19;
  --topbar-text:   #e5e7eb;
  --topbar-muted:  #64748b;
  --topbar-border: #1a2636;

  /* Sidebar */
  --sidebar-bg:          #0d1929;
  --sidebar-text:        #cbd5e1;
  --sidebar-hover:       #162030;
  --sidebar-active-bg:   rgba(52, 211, 153, 0.1);
  --sidebar-active-text: #34d399;
}

/* ─── Theme Toggle Button ─────────────────────────────────────── */
#themeToggle {
  font-size: 17px;
  letter-spacing: 0;
}

/* ─── Page Header ────────────────────────────────────────────── */
.hub-page-header {
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  align-items: center;
}

.hub-hero {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hub-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.hub-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
  max-width: 58ch;
}

.hub-header-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.hub-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.hub-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 0 0 1px var(--success);
}

.hub-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.hub-sync-text {
  font-size: 12.5px;
  color: var(--muted);
}

/* ─── Metric Cards ───────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.metric-value {
  font-size: clamp(1.7rem, 2.2vw, 2.2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.metric-meta {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  flex-shrink: 0;
}

/* Soft color helpers */
.soft-primary { background: var(--primary-soft); color: var(--primary); }
.soft-success { background: var(--success-soft); color: var(--success); }
.soft-warning { background: var(--warning-soft); color: var(--warning); }
.soft-danger  { background: var(--danger-soft);  color: var(--danger);  }

/* ─── Filters Bar ────────────────────────────────────────────── */
.filters-card {
  padding: 16px 20px;
}

.hub-filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.hub-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hub-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hub-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 0 12px;
  color: var(--muted);
  transition: border-color 0.15s ease;
}

.hub-search-wrap:focus-within {
  border-color: var(--primary);
}

.hub-search-wrap svg {
  flex-shrink: 0;
}

.hub-search-wrap input {
  border: 0;
  background: transparent;
  color: var(--text);
  width: 100%;
  outline: none;
  font-size: 13px;
}

.hub-search-wrap input::placeholder {
  color: var(--muted);
}

.hub-select {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.hub-select:focus {
  border-color: var(--primary);
}

/* ─── Hub Layout Grid ────────────────────────────────────────── */
.hub-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(290px, 1fr);
  gap: 12px;
  align-items: start;
}

/* ─── Section Head ───────────────────────────────────────────── */
.section-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.section-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

.section-tools {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Table Card ─────────────────────────────────────────────── */
.hub-table-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Location Name cell */
.location-name-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-healthy  { background: var(--success); }
.dot-warning  { background: var(--warning); }
.dot-delayed  { background: var(--warning); } /* kept for backward compat */
.dot-critical { background: var(--danger);  }

.location-code {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 1px;
}

.subtext {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* No-data placeholder row */
.no-data-cell {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

/* Row tinting by status */
.hub-row[data-status="delayed"],
.hub-row[data-status="warning"] {
  background-color: var(--warning-soft);
}

.hub-row[data-status="critical"] {
  background-color: var(--danger-soft);
}

.hub-row[data-status="delayed"]:hover,
.hub-row[data-status="warning"]:hover,
.hub-row[data-status="critical"]:hover {
  filter: brightness(0.965);
}

/* ─── Side Stack (Detail + Events) ──────────────────────────── */
.side-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hub-detail-card,
.hub-events-card {
  display: flex;
  flex-direction: column;
}

/* ─── Detail Panel ───────────────────────────────────────────── */
.detail-stat {
  padding: 14px 20px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.mini-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-stat strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
  line-height: 1.3;
}

.meta-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.meta-list li {
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.meta-list li:last-child {
  border-bottom: none;
}

.sticky-actions {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-actions .btn {
  flex: 1;
  justify-content: center;
  min-height: 38px;
}

/* ─── Timeline / Events ──────────────────────────────────────── */
.timeline-list {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 5px;
  flex-shrink: 0;
}

.dot-success-tl { background: var(--success); }
.dot-warning-tl { background: var(--warning); }
.dot-danger-tl  { background: var(--danger);  }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1366px) {
  :root {
    --topbar-height: 56px;
    --content-padding: 18px;
  }
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hub-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hub-layout-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .hub-page-header {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hub-header-actions {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  :root {
    --content-padding: 14px;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .hub-filters {
    grid-template-columns: 1fr;
  }

  .hub-page-header {
    padding: 16px;
  }
}

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

/* ─── New Report Notification Modal ─────────────────────────── */
.new-report-modal {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  display: none;
  animation: slideUpModal 0.28s ease;
}

.new-report-modal.is-visible {
  display: block;
}

@keyframes slideUpModal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.new-report-modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  padding: 20px 22px;
  min-width: 280px;
  max-width: 340px;
}

.new-report-modal-content .modal-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.new-report-modal-content p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

/* Primary button variant for the modal (matches brand color) */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Date Range Picker Bar (overview.html) ──────────────────── */
.date-range-bar {
  padding: 14px 18px;
  margin-bottom: 0;
}

.date-range-inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.date-range-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.date-range-label .subtext {
  font-weight: 400;
  margin-left: 4px;
}

.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hub-date-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.hub-date-input:focus {
  outline: none;
  border-color: var(--primary);
}

.date-range-sep {
  font-size: 13px;
  color: var(--muted);
  padding: 0 2px;
}

@media (max-width: 640px) {
  .new-report-modal {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }
  .new-report-modal-content {
    max-width: 100%;
  }
  .date-range-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Users page */
.users-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.users-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.users-chip-muted {
  opacity: 0.8;
}

.users-chip-overflow {
  font-weight: 700;
}

.users-chip-selectable {
  padding-right: 4px;
}

.users-chip-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.users-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  box-sizing: border-box;
}

.users-modal.is-open {
  display: flex;
}

.users-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 12, 22, 0.65);
  z-index: 0;
}

.users-modal-card {
  position: relative;
  width: min(1080px, calc(100vw - 32px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 1;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px 24px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .users-modal-card {
  background: #0b1324;
}

.users-modal-open,
html:has(.users-modal-open) {
  overflow: hidden;
}

.users-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  margin-top: 20px;
}

.users-grid-span-2 {
  grid-column: span 2;
}

.users-form-actions {
  justify-content: flex-end;
}

.users-location-section {
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.users-location-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.users-multiselect-wrap {
  position: relative;
}

.users-multiselect-toggle {
  justify-content: flex-start;
  width: 100%;
}

.users-multiselect-menu {
  position: fixed;
  z-index: 3000;
  max-height: 192px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  padding: 6px;
}

.users-multiselect-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
}

.users-multiselect-item:hover {
  background: var(--surface);
}

.users-multiselect-item-main {
  font-size: 13px;
  font-weight: 600;
}

.users-multiselect-item-sub {
  grid-column: 2;
  font-size: 12px;
  opacity: 0.8;
}

.users-selected-chips-wrap {
  align-items: flex-start;
}

.users-selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  width: 100%;
}

@media (max-width: 920px) {
  .users-modal {
    padding: 10px;
  }

  .users-modal-card {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 24px);
    padding: 12px 14px;
  }

  .users-form-grid {
    grid-template-columns: 1fr;
  }

  .users-grid-span-2 {
    grid-column: span 1;
  }
}
