/* ============================================================================
   PORTAIL DU TOGO — Styles Principaux
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif !important;
  font-size: 18px !important; /* Global base size increased */
  background: #0f1923;
}

.wrapper,
.content-wrapper {
  height: 100% !important;
  overflow: hidden !important;
  background: transparent !important;
}

.content-wrapper {
  margin-left: 0 !important;
}

.content {
  padding: 0 !important;
  height: 100%;
}

/* Supprimer les éléments shinydashboard par défaut */
.main-header {
  display: none !important;
}

.main-sidebar {
  display: none !important;
}

.skin-black .wrapper {
  background: transparent !important;
}

/* ============================================================================
   PORTAL LAYOUT
   ============================================================================ */
.portal-wrapper {
  display: flex;
  height: 100vh;
  width: 100%;
  max-width: 100%; /* Fluide par défaut */
  margin: 0 auto;
  overflow: hidden;
  background: #f8f9fa;
}

/* Optimization for the fixed integration width of 1230px */
@media (min-width: 1900px) {
  /* On très grand écran, on peut optionnellement limiter à 1600px pour garder une lisibilité, 
     mais on reste en 100% si demandé */
}

/* --- Sidebar Navigation --- */
.portal-sidebar {
  width: 320px; /* Increased from 260px to fit larger text */
  min-width: 320px;
  height: 100vh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.05);
  border-right: 1px solid #e2e6ea;
  overflow: hidden;
}

/* --- Sidebar Collapsed State (Desktop) --- */
.portal-sidebar.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
}

.portal-sidebar.collapsed .sidebar-brand h2,
.portal-sidebar.collapsed .sidebar-brand .brand-sub,
.portal-sidebar.collapsed .menu-text,
.portal-sidebar.collapsed .sidebar-footer {
  display: none;
  opacity: 0;
}

.portal-sidebar.collapsed .sidebar-brand {
  padding: 22px 10px;
}

.portal-sidebar.collapsed .sidebar-menu-item {
  justify-content: center;
  padding: 12px 10px;
}

.portal-sidebar.collapsed .menu-icon {
  margin: 0;
}

.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid #f0f2f5;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px auto;
  background: linear-gradient(135deg, #006a4e, #00a86b);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 106, 78, 0.2);
}

.sidebar-brand h2 {
  color: #1a2b3c;
  font-size: 30px !important;
  font-weight: 700;
  margin: 0 0 2px 0;
  letter-spacing: 0.5px;
}

.sidebar-brand .brand-sub {
  color: #667085;
  font-size: 18px !important;
  font-weight: 400;
}

/* Menu Items */
.sidebar-menu-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 4px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  color: #475467;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.sidebar-menu-item:hover {
  background: #f9fafb;
  color: #101828;
}

.sidebar-menu-item.active {
  background: #effdf5;
  color: #006a4e;
  box-shadow: none;
}

.sidebar-menu-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3px;
  background: #00d68f;
  border-radius: 0 3px 3px 0;
}

.menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  background: #f2f4f7;
  transition: all 0.25s ease;
}

.sidebar-menu-item.active .menu-icon {
  background: #006a4e;
  color: #fff !important;
}

.sidebar-menu-item:hover .menu-icon {
  background: #eaecf0;
}

.menu-text {
  flex: 1;
  min-width: 0;
}

.menu-label {
  font-size: 20px !important;
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-subtitle {
  font-size: 16px !important;
  display: block;
  opacity: 0.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid #f0f2f5;
  flex-shrink: 0;
}

.sidebar-footer p {
  color: #667085;
  font-size: 11.5px;
  margin: 0;
  text-align: center;
}

/* ====== MAIN AREA ====== */
.portal-main {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f0f2f5;
  overflow: hidden;
}

/* Top Navbar */
.portal-navbar {
  height: 60px;
  min-height: 60px;
  background: #fff;
  border-bottom: 1px solid #e2e6ea;
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1010;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.navbar-hamburger {
  display: flex !important;
  background: none;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: #333;
  transition: all 0.2s ease;
}

.navbar-hamburger:hover {
  background: #f0f2f5;
  border-color: #adb5bd;
}

.navbar-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-title h1 {
  margin: 0;
  font-size: 32px !important;
  font-weight: 700;
  color: #1a2b3c;
  cursor: pointer;
}

.navbar-title h1:hover {
  color: #006a4e;
}

.navbar-title .badge-dash {
  background: linear-gradient(135deg, #006a4e, #00a86b);
  color: white;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* Navbar Filter Styles */
.navbar-filter-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 15px;
  background: #f8f9fa;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid #e9ecef;
  height: 38px;
}

.navbar-filter-container i {
  color: #006a4e;
  font-size: 13px;
}

.navbar-filter-container .form-group {
  margin-bottom: 0 !important;
}

.navbar-filter-container .selectize-control {
  margin-bottom: 0 !important;
}

.navbar-filter-container .selectize-input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 20px !important;
  font-weight: 600 !important;
  color: #1a2b3c !important;
  padding: 4px 0 !important;
  min-height: 0 !important;
}

.navbar-filter-container .selectize-input::after {
  right: -5px !important;
}

.navbar-filter-container .selectize-dropdown {
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
  border: 1px solid #eee !important;
  padding: 5px !important;
}

.navbar-filter-container .selectize-dropdown-content .option {
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 12px !important;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-flag {
  font-size: 24px;
  line-height: 1;
}

/* Content container */
.portal-content {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 0 !important; /* Garantir qu'aucun espace n'existe en haut */
}

/* Dashboard panels (stacked, show/hide) */
.dashboard-panel {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
}

.dashboard-panel.active {
  display: flex !important;
  flex-direction: column;
}

.dashboard-panel-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Loading state */
.panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 20px;
  color: #666;
}

.panel-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #006a4e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel-loading p {
  font-size: 14px;
  font-weight: 500;
}

/* Welcome Page */
.portal-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
  text-align: center;
  padding: 40px;
  overflow-y: auto;
}

.welcome-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #006a4e, #00a86b);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: white;
  box-shadow: 0 8px 32px rgba(0, 106, 78, 0.25);
}

.portal-welcome h2 {
  font-size: 28px;
  font-weight: 800;
  color: #1a2b3c;
  margin: 0 0 8px 0;
}

.portal-welcome p {
  font-size: 15px;
  color: #666;
  max-width: 500px;
  margin: 0 0 30px 0;
  line-height: 1.6;
}

/* Dashboard Cards on Welcome */
.welcome-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 680px;
  width: 100%;
}

.welcome-card {
  background: white;
  border-radius: 12px;
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #e9ecef;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.welcome-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-color, #006a4e);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.welcome-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--card-color, #006a4e);
}

.welcome-card:hover::before {
  opacity: 1;
}

.welcome-card .card-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px auto;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  background: var(--card-color, #006a4e);
}

.welcome-card .card-title {
  font-size: 13px;
  font-weight: 700;
  color: #1a2b3c;
  margin: 0 0 4px 0;
}

.welcome-card .card-desc {
  font-size: 10px;
  color: #999;
  margin: 0;
}

/* Mobile Overlay */
.sidebar-overlay-portal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1090;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay-portal.active {
  display: block;
  opacity: 1;
}

/* ============================================================================
   EMBEDDED DASHBOARD STYLES (Override pour integration dans le portail)
   ============================================================================ */

/* Chaque dashboard est injecté dans un .dashboard-panel. */
.dashboard-panel.active {
  display: flex !important;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.dashboard-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

/* On doit surcharger certains styles shinydashboard internes. */
.dashboard-panel .content-wrapper {
  height: 100% !important;
  overflow: hidden !important;
  background: #f5f5f5 !important;
}

/* Styles communs des dashboards intégrés */
.dashboard-panel .dashboard-header {
  background: white;
  padding: 10px 20px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-panel .dashboard-header h2 {
  margin: 0;
  font-size: 32px !important;
  font-weight: 700;
  color: #1a2b3c;
}

.dashboard-panel .dashboard-header p {
  margin: 0;
  font-size: 11px;
  color: #666;
}

.dashboard-panel .btn-details {
  background: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dashboard-panel .btn-details:hover {
  background: #2980b9;
  transform: translateY(-1px);
}

.dashboard-panel .hamburger-btn {
  display: none !important;
}

/* Main container 3 colonnes */
.dashboard-panel .main-container {
  display: flex;
  height: calc(100% - 45px); /* Ajusté pour éviter le scroll inutile */
  padding: 15px;
  padding-top: 10px; /* Réduit pour coller plus haut */
  gap: 15px;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Responsiveness: Stack columns vertically below 1150px */
@media (max-width: 1150px) {
  .dashboard-panel .main-container {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100%;
    padding: 10px;
    gap: 15px;
  }

  .dashboard-panel .left-column,
  .dashboard-panel .center-column,
  .dashboard-panel .right-column {
    width: 100% !important;
    height: auto !important;
    flex: none !important;
  }
  
  .dashboard-panel .map-container {
    min-height: 500px; /* On donne plus de place à la carte en version empilée */
  }
  
  .dashboard-panel .chart-box {
    min-height: 350px;
  }
}

/* Left Column */
.dashboard-panel .left-column {
  width: 22%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* KPI Boxes */
.dashboard-panel .kpi-box {
  border-radius: 8px;
  padding: 12px 15px;
  color: white;
  flex-shrink: 0;
  font-family: 'Outfit', sans-serif;
}

.dashboard-panel .kpi-box h3 {
  margin: 0;
  font-size: 28px !important;
  font-weight: 700;
}

.dashboard-panel .kpi-box p {
  margin: 3px 0 0 0;
  font-size: 14px !important;
  opacity: 0.9;
}

.dashboard-panel .kpi-box .icon {
  float: right;
  font-size: 22px;
  opacity: 0.3;
  margin-top: -5px;
}

.dashboard-panel .kpi-blue {
  background: linear-gradient(135deg, #5dade2, #3498db);
}

.dashboard-panel .kpi-teal {
  background: linear-gradient(135deg, #48c9b0, #1abc9c);
}

.dashboard-panel .kpi-green {
  background: linear-gradient(135deg, #58d68d, #27ae60);
}

.dashboard-panel .kpi-orange {
  background: linear-gradient(135deg, #f5b041, #e67e22);
}

/* Table Section */
.dashboard-panel .table-section {
  background: white;
  border-radius: 8px;
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.dashboard-panel .table-section h4 {
  margin: 0 0 8px 0;
  font-size: 22px !important;
  font-weight: 600;
  flex-shrink: 0;
}

.dashboard-panel .table-container {
  flex: 1;
  overflow: hidden; /* Changed from auto to hidden because DataTable will handle scrolling */
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Force DataTable to fill the flex container */
.dashboard-panel .table-container .dataTables_wrapper {
  height: 100% !important;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.dashboard-panel .table-container .dataTables_scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-panel .table-container .dataTables_scrollBody {
  flex: 1 !important;
  min-height: 0;
}

.dashboard-panel .table-container table {
  width: 100% !important;
  margin: 0 !important;
}

/* Center Column */
.dashboard-panel .center-column {
  width: 35%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.dashboard-panel .year-slider-box {
  background: white;
  border-radius: 8px;
  padding: 12px 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-panel .chart-box {
  background: white;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  flex: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.dashboard-panel .chart-box>div:last-child {
  flex: 1;
  min-height: 0;
}

.dashboard-panel .chart-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.dashboard-panel .chart-box-header h4 {
  margin: 0;
  font-size: 23px !important;
  font-weight: 600;
}

/* Toggle Buttons */
.dashboard-panel .toggle-btn {
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dashboard-panel .toggle-btn.active {
  background: #e8f4fd;
  border-color: #3498db;
  color: #3498db;
}

/* Right Column */
.dashboard-panel .right-column {
  width: 43%;
  display: flex;
  flex-direction: column;
  position: relative;
  height: 100%;
}

.dashboard-panel .map-container {
  background: white;
  border-radius: 8px;
  flex: 1;
  position: relative;
  overflow: visible;
  min-height: 400px;
}

/* Force Shiny widgets to fill container */
.dashboard-panel .plotly.html-widget,
.dashboard-panel .leaflet.html-widget,
.dashboard-panel .shiny-bound-output.plotly,
.dashboard-panel .shiny-bound-output.leaflet {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
}

/* Map Controls */
.dashboard-panel .map-title {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 999;
  font-size: 12px;
  font-weight: 600;
  color: #2c3e50;
  border: 1px solid #ddd;
  white-space: nowrap;
}

.dashboard-panel .map-top-bar {
  position: absolute;
  top: 10px;
  left: 50px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
}

.dashboard-panel .map-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
}

.dashboard-panel .map-filter-info {
  position: absolute;
  bottom: 15px;
  left: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  font-size: 11px;
  border: 1px solid #ddd;
  min-width: 130px;
}

.dashboard-panel .filter-info-item {
  margin-bottom: 3px;
  border-bottom: 1px solid #eee;
  padding-bottom: 2px;
}

.dashboard-panel .filter-info-item span:first-child {
  font-weight: 700;
  color: #555;
  margin-right: 4px;
}

/* Map Filter Panel (Floating) */
.dashboard-panel .map-filters-panel {
  z-index: 1000;
}

.dashboard-panel .map-floating-filter {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  font-size: 12px;
}

.dashboard-panel .map-floating-filter label {
  font-weight: 700;
  font-size: 11px;
  color: #2c3e50;
  display: block;
  margin-bottom: 5px;
}

/* Sidebar Overlay (from individual dashboards) */
.dashboard-panel .sidebar-overlay {
  display: none !important;
}

/* leaflet zoom controls offset */
.dashboard-panel .leaflet-top.leaflet-left {
  top: 45px !important;
}

/* Global Leaflet Control Responsive Adjustments */
.leaflet-control-layers {
  font-size: 10px !important;
  padding: 4px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(0,0,0,0.1) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
}

.leaflet-control-layers-expanded {
  padding: 10px !important;
}

.leaflet-control-layers-group-label {
  font-weight: 700;
  margin-bottom: 3px;
}

.leaflet-control-layers-selector {
  margin-top: 1px !important;
}

.leaflet-legend, .leaflet-control-legend {
  font-size: 10px !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  max-width: 150px;
}

@media (max-width: 768px) {
  .leaflet-control-layers {
    margin-top: 10px !important;
  }
  
  .leaflet-control-layers-toggle {
    width: 30px !important;
    height: 30px !important;
  }
  
  .leaflet-bottom.leaflet-right {
    margin-bottom: 70px !important; /* Space for FAB or other bottom sheet */
  }
  
  .leaflet-bottom.leaflet-left {
    margin-bottom: 20px !important;
  }
}


/* Map toggle radio */
.dashboard-panel .map-toggle-radio {
  background: white;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-panel .map-toggle-radio label {
  margin: 0;
  font-size: 16px !important;
}

/* DataTables compact */
.dashboard-panel .dataTable {
  font-size: 18px !important;
}

.dashboard-panel .dataTables_wrapper .dataTables_length,
.dashboard-panel .dataTables_wrapper .dataTables_filter,
.dashboard-panel .dataTables_wrapper .dataTables_info {
  font-size: 18px !important;
}

/* Shiny input margins reset */
.dashboard-panel .shiny-input-container {
  margin: 0;
}

/* Slider styles */
.dashboard-panel .irs--shiny .irs-bar {
  background: #3498db;
}

.dashboard-panel .irs--shiny .irs-handle {
  border-color: #3498db;
}

/* ============================================================================
   RESPONSIVE: Tablet & Mobile (< 1150px)
   ============================================================================ */
@media (max-width: 1150px) {
  /* Sidebar handling */
  .portal-sidebar {
    position: fixed !important;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 2500 !important;
    width: 280px !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
  }

  .portal-sidebar.sidebar-open {
    transform: translateX(0) !important;
  }

  .portal-main {
    margin-left: 0 !important;
    width: 100% !important;
    left: 0 !important;
    padding: 0 !important;
  }

  .sidebar-overlay-portal.active {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2400 !important;
    backdrop-filter: blur(2px);
  }

  /* Dashboard Layout */
  .dashboard-panel .main-container {
    flex-direction: column !important;
    display: flex !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: visible !important;
    padding: 15px !important;
    gap: 20px !important;
  }

  .dashboard-panel .left-column,
  .dashboard-panel .center-column,
  .dashboard-panel .right-column {
    width: 100% !important;
    flex: none !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  .dashboard-panel .chart-box {
    height: 400px !important;
    min-height: 400px !important;
  }

  .dashboard-panel .map-container {
    height: 500px !important;
    min-height: 500px !important;
  }

  .dashboard-panel .table-section {
    min-height: 450px !important;
    height: auto !important;
  }

  /* Welcome cards responsive */
  .welcome-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================================
   RESPONSIVE: Small Mobile (< 768px)
   ============================================================================ */
@media (max-width: 768px) {
  .portal-navbar {
    padding: 0 12px;
    height: 60px;
  }
  
  .navbar-title h1 {
    font-size: 16px !important;
  }

  .navbar-filter-container {
    display: none !important; /* Hide ministry filter in navbar to save space */
  }

  .welcome-cards {
    grid-template-columns: 1fr;
    max-width: 320px;
  }

  .dashboard-panel .kpi-box h3 {
    font-size: 24px !important;
  }

  .dashboard-panel .chart-box {
    height: 350px !important;
  }

  .dashboard-panel .map-container {
    height: 450px !important;
  }
  
  .dashboard-panel .table-section {
    min-height: 350px !important;
  }

  /* Position mobile map title */
  .dashboard-panel .map-title {
    top: 10px;
    font-size: 10px !important;
    padding: 4px 10px;
  }

  /* Floating filters on mobile */
  .dashboard-panel .map-filters-panel {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    top: auto !important;
    width: 100% !important;
    z-index: 1050 !important;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .dashboard-panel .map-filters-panel.mobile-visible {
    transform: translateY(0);
  }
  
  .dashboard-panel .map-filters-panel > div {
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -5px 25px rgba(0,0,0,0.2) !important;
    padding: 20px !important;
  }

  .portal-welcome h2 {
    font-size: 22px;
  }

  .portal-welcome p {
    font-size: 13px;
  }
  
  /* Mobile FAB for filters */
  .btn-mobile-filter {
    display: flex !important;
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: #006a4e;
    color: white;
    border: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(0, 106, 78, 0.4);
    z-index: 1040;
    cursor: pointer;
  }
}

/* Base style for FAB (hidden on desktop) */
.btn-mobile-filter {
  display: none !important;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */
.fade-in {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth scrollbar for content areas */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c1c7cd;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0a7ae;
}

/* ============================================================================
   WIDGET FIXES
   ============================================================================ */
.plotly.html-widget,
.leaflet.html-widget,
.shiny-bound-output.plotly,
.shiny-bound-output.leaflet {
  width: 100% !important;
  height: 100% !important;
  min-height: 100px;
  flex: 1;
}

.map-container {
  flex: 1;
  display: flex !important;
  flex-direction: column !important;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 300px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e2e6ea;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* ============================================================================
   GLOBAL LOADER OVERLAY
   ============================================================================ */
.portal-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(240, 242, 245, 0.85);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.portal-loader-overlay.visible {
  display: flex !important;
  animation: fadeIn 0.3s ease;
}

.loader-content {
  text-align: center;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e2e6ea;
  border-top: 4px solid #006a4e;
  border-radius: 50%;
  margin: 0 auto 15px;
  animation: spin 1s linear infinite;
}

.loader-content p {
  color: #1a2b3c;
  font-weight: 600;
  font-size: 15px;
  margin: 0;
  letter-spacing: 0.5px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


.chart-box>div:last-child,
.map-container>div.leaflet-map-output,
.map-container>div.leaflet {
  flex: 1 !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

/* ============================================================================
   MODAL DETAILS — Professional Styling
   ============================================================================ */
.modal-details-content {
  padding: 10px 5px;
  font-family: 'Outfit', sans-serif !important;
}

.modal-section {
  margin-bottom: 25px;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-header-custom {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eaecf0;
}

.modal-header-custom i {
  color: #006A4E;
  font-size: 1rem;
  background: #effdf5;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d1fadf;
}

.modal-header-custom h4 {
  color: #101828;
  font-weight: 700;
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.2px;
}

.modal-text-block {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #475467;
  margin-bottom: 12px;
}

.modal-list-custom {
  list-style: none;
  padding-left: 0;
  margin: 15px 0;
}

.modal-list-custom li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #344054;
  line-height: 1.5;
}

.modal-list-custom li::before {
  content: '\f058';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  left: 0;
  top: 1px;
  color: #006A4E;
  font-size: 15px;
}

.modal-table-wrapper {
  border-radius: 10px;
  border: 1px solid #eaecf0;
  overflow: hidden;
  margin-top: 15px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.modal-data-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.modal-data-table th {
  text-align: left;
  padding: 12px 16px;
  background: #f9fafb;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #667085;
  font-weight: 600;
  border-bottom: 1px solid #eaecf0;
}

.modal-data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #eaecf0;
  font-size: 0.88rem;
  color: #344054;
}

.modal-data-table tr:last-child td {
  border-bottom: none;
}

.modal-data-table code {
  color: #006A4E;
  background: #effdf5;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid #d1fadf;
}