/* style.css */

/* ---------- Global Reset & Base Styles ---------- */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #fafafa;
  overflow: hidden; /* Prevent body scrollbars */
}

/* ---------- Enterprise Header ---------- */
.enterprise-header {
    background-color: #0d1117;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 100%;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo img {
    height: 32px;
}

.header-title {
    font-size: 20px;
    font-weight: 500;
    margin: 0;
    color: white;
}

/* Main Navigation */
.main-nav {
    display: flex;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.nav-btn {
    background: none;
    border: none;
    color: #8b949e;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background-color: rgba(255,255,255,0.05);
    color: white;
}

.nav-btn.active {
    background-color: #1e4a75;
    color: white;
}

.nav-btn i {
    font-size: 16px;
}

/* Secondary nav button (for panels/toggles, not view switching) */
.nav-btn-secondary {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: #8b949e;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.nav-btn-secondary:hover {
    background-color: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}

.nav-btn-secondary.active {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    color: #60a5fa;
}

.nav-btn-secondary i {
    font-size: 14px;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-btn {
    background: none;
    border: none;
    color: #8b949e;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn:hover {
    background-color: rgba(255,255,255,0.05);
    color: white;
}

/* Create Alert Button - Professional Styling */
.create-alert-btn {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border: none;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-transform: none;
    letter-spacing: 0.025em;
}

.create-alert-btn:hover {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    color: white;
}

.create-alert-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.create-alert-btn i {
    font-size: 16px;
    opacity: 0.9;
}

#notificationBtn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: #f85149;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    display: block !important;
    min-width: 8px;
    text-align: center;
}

.notification-badge.flashing {
    animation: badge-flash 1s ease-in-out infinite !important;
    box-shadow: 0 0 8px rgba(248, 81, 73, 0.6);
}

@keyframes badge-flash {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 4px rgba(248, 81, 73, 0.4);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.15);
        box-shadow: 0 0 12px rgba(248, 81, 73, 0.8);
    }
}

/* ---------- Main Views ---------- */
#mapView, #rssView, #feedsView, #analyzeView, #trendsView {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(100% - 64px);
}

/* RSS View - ensure complete hiding when not active */
#rssView {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1;
}

/* Trends View Styling */
.trends-container {
    padding: 24px;
    overflow-y: auto;
    height: 100%;
    background-color: #f8f9fa;
}

/* KPI Cards */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    background-color: #f0f3f7;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #1e4a75;
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 32px;
    font-weight: 600;
    color: #0d1117;
    line-height: 1;
}

.kpi-label {
    font-size: 14px;
    color: #6e7681;
    margin-top: 4px;
}

.kpi-change {
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
}

.kpi-change.positive {
    color: #2ea44f;
}

.kpi-change.negative {
    color: #f85149;
}

.kpi-change.neutral {
    color: #6e7681;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #0d1117;
    margin: 0 0 20px 0;
}

.chart {
    height: 300px;
    background-color: #f8f9fa;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6e7681;
}

/* Data Tables */
.tables-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
}

.table-card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.table-title {
    font-size: 18px;
    font-weight: 600;
    color: #0d1117;
    margin: 0 0 20px 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px;
    font-weight: 600;
    color: #6e7681;
    border-bottom: 2px solid #e6e8eb;
    font-size: 14px;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f3f7;
    font-size: 14px;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* Status Indicators */
.sentiment, .priority {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.sentiment.positive {
    background-color: #dafbe8;
    color: #218838;
}

.sentiment.negative {
    background-color: #ffeef0;
    color: #d73a49;
}

.sentiment.neutral {
    background-color: #f3f4f6;
    color: #6e7681;
}

.priority.critical {
    background-color: #ffeef0;
    color: #d73a49;
}

.priority.high {
    background-color: #fff3cd;
    color: #856404;
}

.priority.medium {
    background-color: #d1ecf1;
    color: #0c5460;
}

#rssView.active {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 1;
}

/* Map View */
#mapView {
  display: block;
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

#mapView:not(.active) {
  display: none;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.top-banner .title {
  font-size: 1.3rem;
  font-weight: bold;
}
.top-banner .tabs {
  display: flex;
  gap: 20px;
}
.top-banner .tabs a {
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background 0.2s;
}
.top-banner .tabs a:hover,
.top-banner .tabs a.active {
  background-color: #ff3b3b;
}

/* ---------- Map Container ---------- */
#map {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 1; /* Base z-index for map */
  pointer-events: auto;
}

/* Leaflet z-index restored to defaults */
.leaflet-control-container .leaflet-top {
  top: 70px; /* Below banner */
}
.leaflet-control-container .leaflet-bottom {
    bottom: 10px;
}

/* ---------- Floating Buttons ---------- */
.floating-btn {
  position: fixed !important; /* Force fixed positioning */
  left: 10px !important;
  width: 50px !important;
  height: 50px !important;
  background: #ff3b3b !important;
  border: none !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  /* display: flex !important; */ /* Commented out to hide buttons */
  display: none !important; /* Hide all floating buttons */
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3) !important;
  z-index: 2147483647 !important; /* Maximum z-index value */
  pointer-events: auto !important; /* Force clicks to be captured */
  padding: 0 !important;
  transition: top 0.3s ease, background-color 0.2s !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  isolation: isolate !important; /* Create new stacking context */
}
#layersOpenBtn { top: 140px; } /* Adjusted for fixed position below header */
#legendOpenBtn { top: 200px; }
#globeBtn { top: 260px; }

.floating-btn img {
  width: 28px;
  height: 28px;
}
.floating-btn.active {
    opacity: 0.7;
    border: 2px solid #fff;
}

/* ---------- Side Panels: Legend & Layers ---------- */
.side-panel {
  position: fixed;
  top: 60px; /* Below banner */
  right: 0;
  bottom: 0;
  width: 320px;
  height: calc(100vh - 60px); /* Full height minus banner */
  background: #fff;
  box-shadow: -2px 0 8px rgba(0,0,0,0.2);
  z-index: 4000; /* Base z-index for side panels, JS might elevate active one to 4001 */
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}
.side-panel.open {
  transform: translateX(0);
  transition-delay: 0s;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.panel-header h2, .panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  flex-grow: 1;
  margin-right: 10px;
}
.panel-header .header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
}
#incidentSeverityCounts {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-shrink: 0;
}
.panel-header .panel-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
}
.panel-header .panel-controls .form-control-sm {
    height: 32px;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}
.panel-header .panel-controls .form-select-sm {
    height: 32px;
}
.panel-header button.close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 5px;
  color: #666;
}
.panel-header button.close-btn:hover {
    color: #333;
}
.panel-content {
  padding: 12px;
  flex-grow: 1;
  overflow-y: auto;
}
.panel-content h3 {
  margin-top: 0;
  font-size: 0.95rem;
  font-weight: 600;
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

/* Legend Panel Specific */
#legendPanel .legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.9rem;
}
#legendPanel .legend-icon {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  margin-right: 8px;
  flex-shrink: 0;
  display: inline-block;
  border: 1px solid #ccc;
}
#legendPanel .color-box {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    border: 1px solid #aaa;
}
#legendPanel ul {
    margin-top: 5px;
    margin-bottom: 10px;
}
#legendPanel hr {
    margin: 10px 0;
    border-top: 1px solid #eee;
}

/* Layers Panel Specific */
#layersPanel .style-options {
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid #ccc;
  padding-bottom: 8px;
  margin-bottom: 10px;
}
#layersPanel .style-card {
  cursor: pointer;
  text-align: center;
  width: 80px;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.2s;
}
#layersPanel .style-card.selected {
  border-color: #4caf50;
}
#layersPanel .style-card img {
  width: 100%;
  height: 50px;
  object-fit: cover;
  display: block;
  margin: 0 auto 4px;
  border: 1px solid #eee;
}
#layersPanel .style-card div {
  font-size: 0.8rem;
}
#layersPanel .collapsible-section {
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}
#layersPanel .collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 8px 0;
  transition: background 0.3s;
}
#layersPanel .collapsible-header:hover {
  background: #fafafa;
}
#layersPanel .collapsible-header h4,
#layersPanel .collapsible-header h5 {
  margin: 0;
  font-weight: 600;
}
#layersPanel .collapsible-header h4 { font-size: 1rem; }
#layersPanel .collapsible-header h5 { font-size: 0.95rem; }
#layersPanel .collapsible-header img {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
  transform: rotate(180deg);
  cursor: pointer;
  pointer-events: auto;
}
#layersPanel .collapsible-header.open img {
  transform: rotate(0deg);
}
#layersPanel .collapsible-content {
  margin-left: 12px;
  margin-bottom: 10px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out;
}
#layersPanel .collapsible-content.open {
  max-height: 1000px; /* Allow it to grow based on content */
  transition: max-height 0.5s ease-in;
}
#layersPanel .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0;
  padding: 4px;
  cursor: default;
  font-size: 0.9rem;
}
#layersPanel .toggle-row > div:first-child {
    display: flex;
    align-items: center;
}
#layersPanel .info-btn {
    margin-left: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 59, 59, 0.7);
    color: white;
    font-size: 11px;
    font-weight: bold;
    border: none;
    padding: 0;
    pointer-events: auto;
    line-height: 1;
    text-align: center;
}
#layersPanel .info-btn:hover {
    background: #ff3b3b;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 20px;
  transition: background-color 0.3s;
}
.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}
.toggle-switch input:checked + .slider {
  background-color: #4caf50;
}
.toggle-switch input:checked + .slider:before {
  transform: translateX(20px);
}
.toggle-switch input:disabled + .slider {
  background-color: #e0e0e0;
  cursor: not-allowed;
}
.toggle-switch input:disabled + .slider:before {
  background-color: #bdbdbd;
}
.section-header-toggle {
  display: flex;
  align-items: center;
}
#wildfireFilterContainer, #floodListDateRangeContainer {
    margin-left: 20px;
    padding: 5px 0 10px 10px;
    border-left: 2px solid #eee;
    font-size: 0.9em;
    display: none;
}
#floodListDateRangeContainer {
    display: none;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 5px;
}
.filter-group-title {
    font-size: 0.9em;
    margin-bottom: 5px;
    color: #666;
    font-weight: 500;
}
.filter-option {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
}
.filter-option input[type="radio"] {
    margin-right: 5px;
}
.filter-option label {
    font-size: 0.95em;
    cursor: pointer;
}
#layersPanel #gdeltCategoriesContainer .toggle-row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 5px 10px;
    margin-bottom: 10px;
}
#layersPanel #gdeltCategoriesContainer .toggle-row-item {
    display: flex;
    align-items: center;
    font-size: 0.9em;
}
#layersPanel #gdeltCategoriesContainer .toggle-row-item label {
    margin-left: 5px;
    cursor: pointer;
}
#layersPanel #gdeltSeverityContainer .toggle-row.severity-filter-row {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    align-items: center;
    margin-top: 5px;
    padding: 5px;
    background-color: #f9f9f9;
    border-radius: 4px;
}
#layersPanel #gdeltSeverityContainer label {
    display: flex;
    align-items: center;
    font-size: 0.9em;
    margin-left: 5px;
    cursor: pointer;
}
#layersPanel .severity-color-box {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 5px;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.1);
}
#layersPanel .severity-color-box.high { background-color: #e74c3c; }
#layersPanel .severity-color-box.medium { background-color: #f39c12; }
#layersPanel .severity-color-box.low { background-color: #2ecc71; }

/* Incident Feed Panel Specific */
#incidentsPanel .panel-header {
    flex-direction: column;
    align-items: flex-start;
}
#incidentsPanel #incidentSearchInput.form-control-sm {
  flex-grow: 1;
}
#incidentsPanel #incidentSortSelect.form-select-sm,
#incidentsPanel .dropdown .filter-btn { /* filter-btn is btn-sm */
  flex-shrink: 0;
}
#incidentsPanel #mapViewFilterBtn, #incidentsPanel #incidentThresholdsBtn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 1rem;
  flex-shrink: 0;
}
#incidentsPanel #mapViewFilterBtn.active {
  background-color: #d32f2f;
  color: white;
  border-color: #d32f2f;
}
#incidentsPanel .filter-bar {
  padding: 8px 12px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
#incidentsPanel .filter-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
#incidentsPanel .filter-section label:first-child {
    font-weight: 500;
    font-size: 0.9rem;
    margin-right: 4px;
}
#incidentsPanel .filter-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
#incidentsPanel .filter-checkbox {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  background-color: white;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
  user-select: none;
}
#incidentsPanel .filter-checkbox input[type="checkbox"] {
  margin-right: 4px;
  width: 12px;
  height: 12px;
  cursor: pointer;
}
#incidentsPanel .filter-checkbox span {
  margin-left: 0;
  pointer-events: none;
}
#incidentsPanel .incident-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#incidentsPanel .category-header {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  margin: 12px 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}
#incidentsPanel .incident-card {
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  background: white;
  cursor: pointer;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  display: flex;
  flex-direction: column;
  border-left: 4px solid transparent;
}
#incidentsPanel .incident-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#incidentsPanel .incident-card.severity-high { border-left-color: #e74c3c; }
#incidentsPanel .incident-card.severity-medium { border-left-color: #f39c12; }
#incidentsPanel .incident-card.severity-low { border-left-color: #2ecc71; }

#incidentsPanel .incident-header {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  background-color: #f9f9f9;
  border-bottom: 1px solid #e9e9e9;
}
#incidentsPanel .incident-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#incidentsPanel .incident-icon img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#incidentsPanel .incident-title-container {
  flex-grow: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
#incidentsPanel .incident-type {
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#incidentsPanel .incident-severity-badge {
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: white;
  flex-shrink: 0;
}
#incidentsPanel .incident-severity-badge.high { background-color: #e74c3c; }
#incidentsPanel .incident-severity-badge.medium { background-color: #f39c12; }
#incidentsPanel .incident-severity-badge.low { background-color: #2ecc71; }

#incidentsPanel .incident-content {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#incidentsPanel .incident-key-metric {
  font-size: 0.95rem;
  color: #333;
  line-height: 1.3;
}
#incidentsPanel .incident-key-metric strong { font-weight: 600; }
#incidentsPanel .incident-details {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.4;
}
#incidentsPanel .incident-metadata {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.75rem;
  color: #777;
  margin-top: 4px;
  border-top: 1px dashed #eee;
  padding-top: 6px;
}
#incidentsPanel .incident-source { flex-shrink: 0; }
#incidentsPanel .incident-time { white-space: nowrap; text-align: right; flex-grow: 1; }

#incidentsPanel .incident-footer {
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid #f5f5f5;
  background-color: #f9f9f9;
}
#incidentsPanel .incident-location {
  font-size: 0.8rem;
  color: #555;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-right: 8px;
  flex-grow: 1;
}
#incidentsPanel .incident-location i.fa-map-marker {
  color: #555;
  font-size: 0.9rem;
  flex-shrink: 0;
}
#incidentsPanel .incident-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}
#incidentsPanel .incident-zoom,
#incidentsPanel .incident-action-btn {
  background-color: #eee;
  color: #333;
  border: 1px solid #ddd;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  line-height: 1.2;
}
#incidentsPanel .incident-zoom:hover,
#incidentsPanel .incident-action-btn:hover {
    background-color: #e0e0e0;
    border-color: #ccc;
}
#incidentsPanel .incident-action-btn.btn-outline-info {
    background-color: transparent;
    border-color: #0dcaf0;
    color: #0dcaf0;
}
#incidentsPanel .incident-action-btn.btn-outline-info:hover {
    background-color: #0dcaf0;
    color: white;
}
#incidentsPanel .no-incidents {
  padding: 30px;
  text-align: center;
  color: #666;
  font-style: italic;
  font-size: 0.9rem;
}
#incidentsPanel .loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
  min-height: 100px;
}
.severity-count {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
  color: white;
  font-weight: 500;
}
.severity-count.high { background-color: #e74c3c; }
.severity-count.medium { background-color: #f39c12; }
.severity-count.low { background-color: #2ecc71; }

/* Bottom Drawer (Table) */
.bottom-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: #fff;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
  z-index: 1000; /* Below floating buttons, above map */
  overflow: hidden;
  transition: height 0.3s ease;
  display: flex;
  flex-direction: column;
}
.bottom-drawer.open {
    height: 320px; /* Default open height */
    overflow: visible; /* To see resize handle */
}
.bottom-drawer-resize-handle {
  height: 8px;
  background: #ccc;
  cursor: ns-resize;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1; /* Above content within drawer */
  display: none;
}
.bottom-drawer.open .bottom-drawer-resize-handle {
  display: block;
}
.bottom-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  position: relative; /* For handle positioning */
  margin-top: 8px; /* Account for resize handle space */
}
.bottom-drawer-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.bottom-drawer-header button.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
}
.bottom-drawer-header button.close-btn:hover {
    color: #333;
}
.bottom-drawer-content {
  padding: 0;
  flex-grow: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.bottom-drawer .nav-tabs {
    padding: 8px 12px 0 12px;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}
.bottom-drawer .nav-tabs .nav-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
    border-top-left-radius: 0.25rem;
    border-top-right-radius: 0.25rem;
}
.bottom-drawer .tab-content {
    padding: 0;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}
.bottom-drawer .tab-pane {
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    box-sizing: border-box;
    opacity: 1;
    transition: opacity 0.15s linear;
}
.bottom-drawer .tab-pane:not(.show) {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
}
.bottom-drawer .tab-pane.active.show {
    opacity: 1;
    pointer-events: auto;
    position: relative;
}
.bottom-drawer .table-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    align-items: center;
    flex-shrink: 0;
}
.bottom-drawer .table-filters .form-select-sm,
.bottom-drawer .table-filters .form-control-sm {
    flex-grow: 1;
    min-width: 120px;
    max-width: 180px;
    height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}
.bottom-drawer .table-container {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    min-height: 50px;
}
.bottom-drawer table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.bottom-drawer table thead {
  background: #f0f0f0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.bottom-drawer table th,
.bottom-drawer table td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid #ddd;
  white-space: nowrap;
  vertical-align: middle;
}
.bottom-drawer table th.sortable {
  cursor: pointer;
}
.bottom-drawer table th.sortable::after {
    content: ' \2195'; opacity: 0.3; display: inline-block; margin-left: 4px;
}
.bottom-drawer table th.sorted-asc::after { content: ' \2191'; opacity: 1; }
.bottom-drawer table th.sorted-desc::after { content: ' \2193'; opacity: 1; }
.bottom-drawer table tbody tr:hover { background-color: #f5f5f5; }
.bottom-drawer table tbody tr { cursor: pointer; }

/* --- Bootstrap Modal Z-Index Adjustments --- */
.modal-backdrop {
  z-index: 10040 !important; /* Higher than side panels (4001) */
}
.modal {
  z-index: 10050 !important; /* Higher than its backdrop */
}

/* Ensure power outage modals appear above map and all other elements */
#regionModal,
#countyModal,
#airportModal,
#genericAlertPreviewModal {
  z-index: 99999 !important;
  position: fixed !important;
}

#regionModal .modal-dialog,
#countyModal .modal-dialog,
#airportModal .modal-dialog,
#genericAlertPreviewModal .modal-dialog {
  z-index: 100000 !important;
  position: relative !important;
  margin: 1.75rem auto !important;
  pointer-events: auto !important;
}

#regionModal .modal-content,
#countyModal .modal-content,
#airportModal .modal-content,
#genericAlertPreviewModal .modal-content {
  z-index: 100001 !important;
  position: relative !important;
  background: white !important;
  pointer-events: auto !important;
}

/* Ensure modal backdrop covers everything except floating buttons */
.modal-backdrop {
  z-index: 99998 !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

.modal-backdrop.show {
  opacity: 0.5 !important;
  background-color: #000 !important;
}

/* Keep original map z-index - don't force it down */

/* Ensure AlertMedia filter container is visible when shown */
#alertMediaFilterContainer {
    transition: opacity 0.3s ease, max-height 0.3s ease;
}

#alertMediaFilterContainer[style*="block"] {
    opacity: 1 !important;
    visibility: visible !important;
    max-height: 500px !important;
    overflow-y: auto !important;
}

/* Custom Info Popup Styles */
.custom-popup-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 10045 !important; /* Higher than side panels, can be same as modal-backdrop or slightly lower */
    opacity: 0; transition: opacity 0.3s ease; pointer-events: none;
}
.custom-popup-backdrop.visible { opacity: 1; pointer-events: auto; }
.custom-popup {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: white; border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 10055 !important; /* Higher than custom backdrop and standard modals */
    width: 90%; max-width: 500px; opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex; flex-direction: column; max-height: 80vh; pointer-events: none;
}
.custom-popup.visible { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: auto; }
.custom-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 15px; border-bottom: 1px solid #eee; background-color: #f8f9fa;
    border-top-left-radius: 8px; border-top-right-radius: 8px; flex-shrink: 0;
}
.custom-popup-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.custom-popup-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0 5px; color: #6c757d; }
.custom-popup-close:hover { color: #343a40; }
.custom-popup-content { padding: 15px; overflow-y: auto; flex-grow: 1; }
.custom-popup-content h4 { margin-top: 10px; margin-bottom: 5px; font-size: 1rem; }
.custom-popup-content ul { padding-left: 20px; margin-bottom: 10px;}
.custom-popup-content p { margin-bottom: 10px; line-height: 1.5;}
.custom-popup-footer {
    padding: 10px 15px; border-top: 1px solid #eee; text-align: right;
    background-color: #f8f9fa; border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px; flex-shrink: 0;
}
.custom-popup-button {
    padding: 6px 12px; border: 1px solid #adb5bd; background-color: #e9ecef;
    color: #495057; border-radius: 4px; cursor: pointer; transition: background-color 0.2s;
}
.custom-popup-button:hover { background-color: #dee2e6; }

/* Power Outage Specific Styles */
.no-data-pattern path {
    stroke-dasharray: none !important; stroke-linecap: inherit !important;
    stroke-linejoin: inherit !important; fill: url(#noDataCrossHatch) !important;
}

/* Modal Canvas Styling & Chart Containers */
.modal-body canvas {
    display: block !important;
    position: relative;
    width: 100% !important;
}
.outage-modal-chart,
.airport-modal-chart-container { /* Target the specific container for airport chart */
    position: relative;
    width: 100%;
    height: 300px; /* Explicit height for chart containers */
    min-height: 280px;
    margin-bottom: 1rem;
    flex-shrink: 0; /* Prevent shrinking if modal body is flex and content is long */
}
.modal-body { /* Ensure modal bodies can flex their content vertically */
    display: flex;
    flex-direction: column;
}
#noDataMessage { margin-top: 15px; text-align: center; }
.hidden { display: none !important; }
#appContainer.hidden ~ .leaflet-control-container { display: none; }

/* Outage Modal Metrics Enhancements */
.outage-modal-info strong { display: inline-block; min-width: 110px; }
.outage-modal-metrics { background-color: #f8f9fa; padding: 10px 5px; border-radius: 5px; border: 1px solid #dee2e6; }
.outage-modal-metrics .metric-item { display: flex; flex-direction: column; text-align: center; padding: 5px; }
.outage-modal-metrics .metric-label { font-size: 0.8rem; color: #6c757d; margin-bottom: 2px; text-transform: uppercase; font-weight: 500; }
.outage-modal-metrics .metric-value { font-size: 1.2rem; font-weight: 600; color: #212529; line-height: 1.2; }
#providersContainer h6 { font-weight: 600; color: #495057; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.outage-provider-list .list-group-item { padding: 0.5rem 0.75rem; font-size: 0.9rem; border-color: #f1f1f1; }
.outage-provider-list .list-group-item:hover { background-color: #e9ecef; cursor: default; }


/* Media Queries for Responsiveness */
@media (max-width: 768px) {
  .top-banner .tabs { display: none; }
  .floating-btn { width: 40px; height: 40px; }
  .floating-btn img { width: 20px; height: 20px; }
  #layersOpenBtn { top: 70px; }
  #legendOpenBtn { top: 120px; }
  #globeBtn { top: 170px; }

  .side-panel { width: 280px; }
  #incidentsPanel .panel-controls { flex-direction: column; align-items: stretch; }
  .bottom-drawer .table-filters { flex-direction: column; align-items: stretch; }
   .bottom-drawer .table-filters .form-select-sm,
   .bottom-drawer .table-filters .form-control-sm { max-width: none; }
}

@media (max-width: 576px) {
  .top-banner .title { font-size: 1.1rem; }
  .side-panel { width: 95%; transform: translateX(100%); border-left: none; }
  #incidentsPanel .incident-metadata { flex-direction: column; gap: 4px; align-items: flex-start; }
  #incidentsPanel .filter-section { flex-direction: column; align-items: flex-start; }
  #incidentsPanel .filter-options { flex-wrap: wrap; }
}