/* ============================================================
   SHEQ PORTAL - MASTER THEME & DASHBOARD STYLESHEET
   Supports Light & Dark Modes via [data-theme]
   ============================================================ */

/* ------------------------------------------------------------
   1. CSS VARIABLES / THEME TOKENS
   ------------------------------------------------------------ */
:root,
[data-theme="dark"] {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Accent & Brand Colors */
  --c-yellow: #ffd100;
  --c-yellow-hover: #e6bc00;
  --c-yellow-text: #000000;
  --c-red: #ef4444;
  --c-red-dark: #7f1d1d;
  --c-red-bg: rgba(239, 68, 68, 0.15);
  --c-red-border: #dc2626;
  --c-blue: #38bdf8;
  --c-green: #10b981;
  --c-amber: #f59e0b;
  --c-purple: #818cf8;

  /* Dark Theme Surfaces */
  --bg-app: #0d0e11;
  --bg-sidebar: #121316;
  --bg-card: #18191e;
  --bg-card-inner: #1f2026;
  --bg-input: #121316;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: #272930;

  /* Borders */
  --border-color: #272930;
  --border-color-subtle: #1e2025;
  --border-radius-sm: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 8px;

  /* Typography */
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Scrollbars & Shadows */
  --scrollbar-track: #121316;
  --scrollbar-thumb: #2b2d35;
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  /* Light Theme Surfaces */
  --bg-app: #f1f3f5;
  --bg-sidebar: #121316; /* Sidebar remains dark per design */
  --bg-card: #ffffff;
  --bg-card-inner: #f8f9fa;
  --bg-input: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: #e9ecef;

  /* Borders */
  --border-color: #d1d5db;
  --border-color-subtle: #e5e7eb;

  /* Typography */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;

  /* Scrollbars & Shadows */
  --scrollbar-track: #e5e7eb;
  --scrollbar-thumb: #9ca3af;
  --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ------------------------------------------------------------
   2. GLOBAL LAYOUT & RESET
   ------------------------------------------------------------ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.portal-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* ------------------------------------------------------------
   3. SIDEBAR NAVIGATION
   .sidebar and .nav-link are owned by 03-shell-sidebar.css -- this
   legacy sheet loads later and used to override them (fixed 230px
   width, its own colours), so those rules were removed from here.
   ------------------------------------------------------------ */
.sidebar-logo-area {
  padding: 16px;
  border-bottom: 1px solid #202227;
}

.company-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #fff;
}

.portal-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1px;
  margin-top: 14px;
  color: #fff;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 800;
  color: #6b7280;
  letter-spacing: 1px;
  padding: 16px 16px 8px;
}

.nav-list {
  list-style: none;
}

/* Sidebar Map Layers & Accordions */
.sidebar-filters-panel {
  padding: 8px 12px;
  flex: 1;
  overflow-y: auto;
}

.map-layer-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.layer-btn {
  flex: 1;
  padding: 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--border-radius-sm);
  background: #1e2025;
  border: 1px solid #2d3039;
  color: #9ca3af;
  cursor: pointer;
}

.layer-btn.active,
.layer-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.toggle-all-link {
  display: block;
  font-size: 10px;
  text-align: right;
  color: #6b7280;
  text-decoration: none;
  margin-bottom: 6px;
}

.filter-category-group {
  margin-bottom: 6px;
  background: #18191e;
  border: 1px solid #22242b;
  border-radius: var(--border-radius-sm);
}

.filter-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: #9ca3af;
}

.sidebar-reset-btn {
  margin: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid var(--c-red-border);
  color: #ef4444;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ------------------------------------------------------------
   4. TOP BANNER & METADATA BAR
   ------------------------------------------------------------ */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Yellow Header Strip */
.top-header-banner {
  background-color: var(--accent-fill);
  color: var(--accent-on-fill);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #000;
}

.header-banner-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.5px;
  margin: 0 auto;
}

.top-meta-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* .topnav-date / .topnav-icon-btn are owned by 04-topbar-content.css --
   the hard-coded black versions that used to sit here made the date,
   theme toggle and bell invisible on the dark-mode top bar. */

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-box {
  width: 28px;
  height: 28px;
  background: #000;
  color: #ffd100;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.user-meta-text {
  line-height: 1.1;
}

.user-meta-name {
  font-size: 12px;
  font-weight: 800;
  color: #000;
}

.user-meta-role {
  font-size: 9px;
  font-weight: 700;
  color: #333;
}

/* ------------------------------------------------------------
   5. FILTER BAR (DASHBOARD TOP FILTERS)
   ------------------------------------------------------------ */
.dashboard-content {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.global-filter-bar {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--card-shadow);
}

.filter-btn-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.filter-pill-btn {
  background: var(--bg-card-inner);
  border: none;
  border-right: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.filter-pill-btn:last-child {
  border-right: none;
}

.filter-pill-btn.active {
  background-color: var(--accent-fill);
  color: var(--accent-on-fill);
  font-weight: 900;
}

.filter-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
}

.filter-input,
.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius-sm);
  padding: 4px 8px;
  font-size: 11px;
}

.filter-reset-btn {
  background: transparent;
  border: 1px solid var(--c-red-border);
  color: var(--c-red);
  font-size: 10px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
}

.filter-reset-btn:hover {
  background: var(--c-red);
  color: #fff;
}

/* ------------------------------------------------------------
   6. KPI CALLOUT STRIP (5 METRIC CARDS)
   ------------------------------------------------------------ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--card-shadow);
}

.kpi-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
}

.kpi-value.tone-yellow { color: #facc15; }
.kpi-value.tone-red    { color: #ef4444; }
.kpi-value.tone-amber  { color: #f59e0b; }
.kpi-value.tone-blue   { color: #0284c7; }

[data-theme="dark"] .kpi-value.tone-blue { color: #38bdf8; }

/* ------------------------------------------------------------
   7. MAIN MAP & TRENDS SPLIT SECTION
   ------------------------------------------------------------ */
.dashboard-grid-main {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 12px;
  flex: 1;
}

/* Map Card */
.map-panel-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.map-card-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.map-stage-container {
  flex: 1;
  position: relative;
  min-height: 520px;
  background: #a5bfd4; /* Default map canvas base */
}

/* Map Overlays */
.map-view-switcher {
  position: absolute;
  top: 60px;
  left: 14px;
  z-index: 10;
  display: flex;
  border: 1px solid #222;
  border-radius: 4px;
  overflow: hidden;
}

.map-view-switcher button {
  padding: 5px 10px;
  font-size: 9px;
  font-weight: 800;
  background: #18191e;
  color: #fff;
  border: none;
  cursor: pointer;
}

.map-view-switcher button.active {
  background: var(--accent-fill);
  color: var(--accent-on-fill);
}

.map-floating-alerts {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.map-alert-badge {
  background: #18191e;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-alert-badge.alert-red {
  background: #7f1d1d;
  border-color: #dc2626;
  color: #ffffff;
}

/* ------------------------------------------------------------
   8. RIGHT TREND CHARTS COLUMN
   ------------------------------------------------------------ */
.trend-charts-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trend-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
}

.trend-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.trend-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-primary);
}

.trend-dot {
  width: 8px;
  height: 8px;
  border-radius: 1px;
}

.trend-dot.yellow { background-color: var(--c-yellow); }
.trend-dot.blue   { background-color: #38bdf8; }
.trend-dot.green  { background-color: #10b981; }
.trend-dot.gray   { background-color: #9ca3af; }
.trend-dot.red    { background-color: #ef4444; }

.trend-expand-icon {
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}

.trend-chart-canvas {
  height: 60px;
  width: 100%;
}

/* ------------------------------------------------------------
   9. SCROLLBARS & UTILITY
   ------------------------------------------------------------ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

/* ============================================================
   Floating Draggable Dev & Support Widget (css/14-helping.css)
   ============================================================ */
.floating-help-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483640;
  font-family: inherit;
  user-select: none;
}

/* ------------------------------------------------------------
   Collapsed Pill Trigger
   ------------------------------------------------------------ */
.fhw-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #18181b;
  border: 1px solid #3f3f46;
  border-radius: 9999px;
  padding: 8px 16px;
  color: #f4f4f5;
  cursor: grab;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.fhw-pill:hover {
  background: #27272a;
  border-color: #6366f1;
  transform: translateY(-2px);
}

.fhw-pill:active {
  cursor: grabbing;
}

.fhw-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: fhwPulse 2s infinite ease-in-out;
}

@keyframes fhwPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}

.fhw-icon {
  width: 15px;
  height: 15px;
  color: #818cf8;
}

.fhw-pill-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ------------------------------------------------------------
   Expanded Card (Opens Upwards & to the Left)
   ------------------------------------------------------------ */
.fhw-card {
  display: none;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #18181b;
  border: 1px solid #3f3f46;
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: #f4f4f5;
  overflow: hidden;
  animation: fhwExpand 0.18s ease-out;
}

.floating-help-widget.is-expanded .fhw-card {
  display: block;
}

.floating-help-widget.is-expanded .fhw-pill {
  display: none;
}

@keyframes fhwExpand {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Card Header */
.fhw-header {
  padding: 14px 16px;
  background: #202024;
  border-bottom: 1px solid #27272a;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  cursor: grab;
}

.fhw-header:active {
  cursor: grabbing;
}

.fhw-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  color: #818cf8;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.fhw-header-title h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.fhw-close-btn {
  background: transparent;
  border: none;
  color: #a1a1aa;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.fhw-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Card Body */
.fhw-body {
  padding: 16px;
}

.fhw-desc {
  margin: 0 0 14px 0;
  font-size: 12px;
  color: #a1a1aa;
  line-height: 1.45;
}

.fhw-contacts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fhw-contact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #222226;
  border: 1px solid #2e2e34;
  border-radius: 8px;
  padding: 10px 12px;
}

.fhw-contact-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fhw-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3730a3;
  color: #c7d2fe;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fhw-name {
  font-size: 12px;
  font-weight: 600;
  color: #f4f4f5;
}

.fhw-role {
  font-size: 10px;
  color: #71717a;
}

.fhw-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fhw-btn-teams,
.fhw-btn-email {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fhw-btn-teams {
  background: #4f46e5;
  color: #ffffff;
  border: none;
}

.fhw-btn-teams:hover {
  background: #4338ca;
}

.fhw-btn-teams svg {
  width: 12px;
  height: 12px;
}

.fhw-btn-email {
  background: #27272a;
  border: 1px solid #3f3f46;
  color: #d4d4d8;
}

.fhw-btn-email:hover {
  background: #3f3f46;
  color: #ffffff;
}

.fhw-btn-email svg {
  width: 12px;
  height: 12px;
}

/* ============================================================
   Contacts & Support Block (css/14-helping.css)
   ============================================================ */
.contacts-block-layout {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contacts-dept-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(147, 51, 234, 0.15));
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 8px;
  margin-bottom: 4px;
}

.contacts-dept-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contacts-dept-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contacts-dept-tag {
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #93c5fd;
  font-weight: 700;
}

.contacts-dept-email {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.contacts-dept-btn {
  padding: 6px 12px;
  background: #2563eb;
  color: #ffffff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.contacts-dept-btn:hover {
  opacity: 0.9;
}

.contacts-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  margin-bottom: 8px;
}

.contacts-user-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.contacts-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #2b3b52;
  color: #60a5fa;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.contacts-user-name {
  font-weight: 600;
  font-size: 14px;
  color: #ffffff;
}

.contacts-user-role {
  font-size: 12px;
  color: #9ca3af;
}

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

.contacts-btn-teams {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: #5059C9;
  color: #ffffff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.contacts-btn-teams:hover {
  opacity: 0.85;
}

.contacts-btn-email {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: background-color 0.2s ease;
}

.contacts-btn-email:hover {
  background: rgba(255, 255, 255, 0.2);
}