/* =========================================
   FLEET TRACKER - MAIN STYLESHEET
   Theme: Teal (#0084a7) & Dark Grey
   ========================================= */

:root {
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a7a;
  --teal: #0084a7;
  --teal-dark: #00607a;
  --red: #d32f2f;
  --orange: #f57c00;
  --green: #2e7d32;
  --blue: #1976d2;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* Header - Modernized */
.main-header {
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--teal) 100%);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  color: white;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.header-top-row {
  display: flex; justify-content: flex-end; margin-bottom: 5px;
}

.developer-credit {
  font-size: 11px;
  background: rgba(0,0,0,0.2);
  padding: 2px 8px;
  border-radius: 10px;
  opacity: 0.8;
  letter-spacing: 0.5px;
}

.header-content { display: flex; justify-content: space-between; align-items: center; }

.logo-area { display: flex; align-items: center; gap: 15px; }
.logo-icon-box {
  background: rgba(255,255,255,0.15);
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.logo-area h1 { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px; }
.logo-area p { margin: 0; opacity: 0.9; font-size: 0.9rem; font-weight: 300; }

/* Digital Clock Style */
.clock-container {
  background: rgba(0,0,0,0.3);
  padding: 8px 15px;
  border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}
.clock-icon { color: #81d4fa; animation: pulse 2s infinite; }
#clockDisplay {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255,255,255,0.5);
}

@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }


/* UPDATED Tabs / Menu Styling */
.tabs {
  display: flex; 
  gap: 8px; 
  overflow-x: auto;
  background: linear-gradient(to bottom, #ffffff, #f8f9fa); 
  padding: 10px; 
  border-radius: 12px; 
  margin-bottom: 25px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  border: 1px solid rgba(255,255,255,0.5);
  align-items: center;
  flex-wrap: wrap;
}

.tab-button {
  background: white; 
  border: 1px solid #e0e0e0; 
  padding: 8px 16px; /* Normalized size */
  font-size: 13px; 
  font-weight: 700; 
  color: var(--text-secondary); 
  cursor: pointer;
  border-radius: 50px; /* Pill shape */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.tab-button i { 
  font-size: 14px; 
  transition: transform 0.3s ease;
}

.tab-button:hover { 
  background: white; 
  color: var(--teal); 
  border-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 132, 167, 0.15);
}

.tab-button:hover i {
  transform: scale(1.1);
}

.tab-button.active { 
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: white; 
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(0, 132, 167, 0.3);
}

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

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

/* Controls */
.controls-section {
  background: var(--bg-secondary); padding: 20px; border-radius: 12px;
  margin-bottom: 20px; box-shadow: var(--shadow);
}
.controls-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; align-items: end; }
.form-group { display: flex; flex-direction: column; }
label { font-size: 12px; font-weight: 700; color: #666; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
input, select { padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(0, 132, 167, 0.2); }

/* Buttons - Normalized Sizing */
.btn-primary {
  background: var(--teal); color: white; border: none; padding: 8px 16px;
  border-radius: 6px; font-weight: 600; cursor: pointer; transition: background 0.2s;
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
}
.btn-primary:hover { background: var(--teal-dark); }

.btn-secondary {
  background: #eee; color: #333; border: 1px solid #ccc; padding: 8px 16px;
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 4px; border: none; cursor: pointer; background: rgba(0,0,0,0.1); }
.btn-xs:hover { background: rgba(0,0,0,0.2); }

/* Sub Filters */
.sub-filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-pill {
    background: white; border: 1px solid #ddd; padding: 6px 15px; border-radius: 20px;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.filter-pill:hover { background: #f5f5f5; }
.filter-pill.active { background: var(--text-secondary); color: white; border-color: var(--text-secondary); }
.filter-pill.critical.active { background: var(--red); border-color: var(--red); }
.filter-pill.warning.active { background: var(--orange); border-color: var(--orange); }
.filter-pill.normal.active { background: var(--green); border-color: var(--green); }


/* Stats Grid */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px; margin-bottom: 20px;
}

.stat-card {
  background: white; padding: 15px; border-radius: 10px; box-shadow: var(--shadow);
  cursor: pointer; transition: all 0.2s; border: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,0.1); }
.stat-card.active-filter { background: #e3f2fd; border-color: var(--teal); }

.stat-icon { font-size: 1.5rem; margin-bottom: 5px; opacity: 0.8; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 11px; color: #666; text-transform: uppercase; font-weight: 600; margin-top: 4px; }

/* Specific Filters Colors */
.stat-card[data-type="moving"].active-filter { background: #e8f5e9; border-color: var(--green); }
.stat-card[data-type="stopped"].active-filter { background: #ffebee; border-color: #d32f2f; }
.stat-card[data-type="critical"].active-filter { background: #ffebee; border-color: #d32f2f; }

/* GPS CUT FILTER CARD (NEW) */
.stat-card[data-type="gps_cut"] { border-bottom: 3px solid #333; }
.stat-card[data-type="gps_cut"].active-filter { background: #e0e0e0; border-color: #333; }


/* Filter Banner */
.filter-banner {
  background: var(--teal-dark); color: white; padding: 12px 20px;
  border-radius: 8px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 0.9rem; animation: slideDown 0.3s ease;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.filter-icon-badge { background: rgba(255,255,255,0.2); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }

/* NEW CLEAR BUTTON STYLE */
.btn-clear-filter {
  background: white; 
  color: var(--red); 
  border: none; 
  padding: 8px 16px; 
  border-radius: 6px; 
  font-weight: 700; 
  cursor: pointer; 
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.2s;
}
.btn-clear-filter:hover { transform: scale(1.05); background: #fff5f5; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Truck Cards */
.trucks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.truck-card {
  background: white; border-radius: 12px; padding: 0;
  box-shadow: var(--shadow); border: 1px solid #eee; overflow: hidden;
  transition: transform 0.2s;
}
.truck-card:hover { transform: translateY(-2px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); }

.truck-header {
  padding: 15px; display: flex; justify-content: space-between; align-items: start;
  border-bottom: 1px solid #eee;
}
.truck-header.moving-bg { background: linear-gradient(to right, #e8f5e9, #ffffff); border-left: 5px solid var(--green); }
.truck-header.stopped-bg { background: linear-gradient(to right, #f5f5f5, #ffffff); border-left: 5px solid #999; }

/* GPS CUT STYLES (NEW) */
.truck-header.gps-cut-bg { 
    background: linear-gradient(to right, #e0e0e0, #ffffff); 
    border-left: 5px solid #333; 
    opacity: 0.8;
}

.status-badge {
  padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 10px;
  text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px;
}
.status-badge.moving { background: var(--green); color: white; animation: pulse-green 2s infinite; }
.status-badge.stopped { background: #e0e0e0; color: #666; }

/* GPS CUT BADGE (NEW) */
.status-badge.gps-cut { 
    background: #333; 
    color: #fff; 
    animation: pulse-gray 2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(46, 125, 50, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0); }
}

@keyframes pulse-gray {
  0% { opacity: 0.7; }
  50% { opacity: 1; }
  100% { opacity: 0.7; }
}

.truck-body { padding: 15px; }

/* Progress Bars */
.progress-container { margin: 10px 0; }
.progress-bar { width: 100%; height: 10px; background: #eee; border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; transition: width 0.5s ease; }
.progress-fill.good { background: var(--green); }
.progress-fill.warning { background: var(--orange); }
.progress-fill.critical { background: var(--red); }

/* Info Grid in Card */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.info-item { background: #f8f9fa; padding: 8px; border-radius: 6px; }
.info-label { font-size: 10px; color: #888; font-weight: 700; text-transform: uppercase; }
.info-value { font-size: 14px; font-weight: 600; color: #333; }

/* Location Box */
.location-box { margin-top: 15px; font-size: 12px; color: #555; display: flex; align-items: start; gap: 8px; }
.location-box i { color: var(--teal); margin-top: 3px; }

/* Autocomplete */
.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; background: white;
  border: 1px solid #ddd; border-radius: 0 0 8px 8px; max-height: 200px;
  overflow-y: auto; z-index: 100; box-shadow: 0 4px 6px rgba(0,0,0,0.1); display: none;
}

/* Accordions */
.accordion-header {
  background: white; padding: 15px; border-radius: 8px; margin-bottom: 5px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.accordion-content { display: none; padding: 15px; background: white; border-top: 1px solid #eee; margin-bottom: 10px; }
.accordion-content.show { display: block; }

/* Calibration */
.calibration-box { grid-column: 1 / -1; background: #f0f7ff; padding: 15px; border-radius: 6px; border: 1px dashed var(--teal); }
.calibration-box textarea { width: 100%; font-family: monospace; border: 1px solid #ccc; padding: 5px; box-sizing: border-box; }
.calibration-box.global { background: #e1f5fe; border: 2px solid var(--teal-dark); margin-top: 15px; }

/* =========================================
   NEW: RULE SYSTEM STYLES (GROUPS)
   ========================================= */

.rule-cards-container {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); 
    gap: 20px;
    margin-top: 15px;
}

.rule-card {
    background: white; 
    border: 1px solid #ddd; 
    border-radius: 8px;
    border-left: 5px solid var(--teal);
    padding: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.rule-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.rule-title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
}

.rule-stats {
    font-size: 11px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
}

.rule-trucks-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 15px;
    flex-grow: 1; /* Pushes footer down */
}

.rule-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #f9f9f9;
}

/* Truck Chips / Tags */
.truck-tag {
    background: #e0f2f1;
    color: #00695c;
    border: 1px solid #b2dfdb;
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.truck-tag-remove {
    cursor: pointer;
    color: #d32f2f;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}

.truck-tag-remove:hover {
    background: rgba(211, 47, 47, 0.1);
    border-radius: 50%;
}

/* Modal for Rules (Enhanced) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: zoomIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title { font-size: 1.2rem; font-weight: 700; color: var(--teal-dark); }

/* =================================================================
   ⬇️ MAPBOX SPECIFIC STYLES (REQUIRED) ⬇️
   ================================================================= */

/* --- MAP CONTAINER --- */
#map-wrapper {
    position: relative;
    width: 100%;
    height: 75vh;
    min-height: 500px;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
    display: none;
    background: #eef0f2;
}
#map-container { width: 100%; height: 100%; }

/* --- CONTROLS --- */
.map-overlay-controls {
    position: absolute; top: 15px; left: 15px; z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px; border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(5px);
    width: 260px;
}

/* Layer Switcher & Filters */
.map-layer-select {
    width: 100%; padding: 6px; margin-bottom: 10px;
    border: 1px solid #ddd; border-radius: 6px;
    font-size: 12px;
}

/* --- NEW MAP TOOLS --- */
.map-tools-container {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #eee;
}

.tool-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 6px;
}
.tool-row:last-child { margin-bottom: 0; }

.tool-row i { color: #0084a7; font-size: 14px; width: 20px; text-align: center; }

.tool-row select, .tool-row input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 12px;
    background: transparent;
    color: #333;
}

/* Cancel Button */
.btn-cancel {
    border: none; background: #ffebee; color: #d32f2f;
    border-radius: 4px; padding: 4px 8px; cursor: pointer;
    font-size: 12px; margin-left: auto;
}
.btn-cancel:hover { background: #ffcdd2; }

/* 3D Switch */
.map-mode-switch {
    display: flex; background: #eee; border-radius: 20px;
    padding: 3px; margin-bottom: 10px; cursor: pointer;
}
.map-mode-btn {
    flex: 1; text-align: center; padding: 5px; font-size: 12px;
    font-weight: bold; border-radius: 16px; transition: all 0.3s; color: #666;
}
.map-mode-btn.active {
    background: var(--teal); color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.map-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.map-filter-btn {
    background: white; border: 1px solid #ddd; border-radius: 5px;
    padding: 5px; font-size: 11px; text-align: center; cursor: pointer;
    transition: all 0.2s; font-weight: 600; color: #555;
}
.map-filter-btn:hover { background: #f0f0f0; }
.map-filter-btn.active { background: #0084a7; color: white; border-color: #0084a7; }

/* --- MARKERS --- */
.truck-marker {
    width: 40px; height: 40px; cursor: pointer; z-index: 10;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.truck-marker:hover { transform: scale(1.2) translateY(-5px); z-index: 100; }

.marker-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: white; border: 2px solid #555;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    font-size: 14px; color: #333;
}
.marker-icon.moving { border-color: #2e7d32; color: #2e7d32; }
.marker-icon.stopped { border-color: #d32f2f; color: #d32f2f; }
.marker-icon.selected {
    background: #0084a7; color: white; border-color: white;
    box-shadow: 0 0 0 4px rgba(0, 132, 167, 0.4);
    transform: scale(1.1);
}

/* --- CUSTOM LOCATIONS (COLOR CODED) --- */
.custom-loc-marker {
    display: flex; flex-direction: column; align-items: center;
    cursor: pointer; z-index: 5; transition: all 0.2s;
}
.custom-loc-label {
    background: #333; color: white; padding: 2px 6px;
    border-radius: 4px; font-size: 10px; font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); margin-bottom: 2px;
    white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.custom-loc-icon { font-size: 24px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3)); }

/* Color Types */
.custom-loc-marker.type-client .custom-loc-icon { color: #1976d2; } /* Blue */
.custom-loc-marker.type-client .custom-loc-label { background: #1976d2; }

.custom-loc-marker.type-maintenance .custom-loc-icon { color: #d32f2f; } /* Red */
.custom-loc-marker.type-maintenance .custom-loc-label { background: #d32f2f; }

.custom-loc-marker.type-douroub .custom-loc-icon { color: #2e7d32; } /* Green */
.custom-loc-marker.type-douroub .custom-loc-label { background: #2e7d32; }

.custom-loc-marker.type-other .custom-loc-icon { color: #757575; } /* Grey */
.custom-loc-marker.type-other .custom-loc-label { background: #757575; }

/* Target Mode Active Style */
.custom-loc-marker.target-active .custom-loc-label {
    background: #ff9800 !important; transform: scale(1.1);
}
.custom-loc-marker.target-active .custom-loc-icon { color: #ff9800 !important; }

/* --- ROUTE & INFO --- */
#route-info-panel {
    position: absolute; bottom: 25px; left: 50%; transform: translateX(-50%);
    background: white; padding: 12px 25px; border-radius: 30px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2); display: none;
    align-items: center; gap: 20px; z-index: 20;
    animation: slideUp 0.3s ease-out;
}
.route-stat { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.route-stat strong { font-size: 15px; color: #0084a7; }
.route-stat span { font-size: 10px; color: #888; text-transform: uppercase; }

/* Toast Notification */
.map-toast-msg {
    position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.8); color: white; padding: 10px 20px;
    border-radius: 20px; font-size: 13px; z-index: 50; text-align: center;
    pointer-events: none; transition: opacity 0.5s;
}

@keyframes slideUp { from { transform: translate(-50%, 100%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Fix CSS Error */
* { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; }

/* Mapbox Popup Overrides */
.mapboxgl-popup-content {
    padding: 0 !important; /* Reset padding for header/body layout */
    border-radius: 8px !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) !important;
    min-width: 220px;
    font-family: 'Segoe UI', sans-serif;
    overflow: hidden;
}

.popup-header-box {
    background: #0084a7;
    color: white;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-body-box {
    padding: 10px 12px;
    background: white;
}

.popup-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 6px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 4px;
}
.popup-stat-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.popup-stat-icon { color: #888; width: 20px; text-align: center; margin-right: 5px; }
.popup-stat-value { font-weight: 700; color: #000; }

/* Status Indicators in Popup */
.status-dot { height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-dot.moving { background: #2e7d32; box-shadow: 0 0 5px #2e7d32; }
.status-dot.stopped { background: #d32f2f; }

/* Action Button */
.popup-action-btn {
    width: 100%;
    margin-top: 8px;
    background: #f0f2f5;
    color: #333;
    border: 1px solid #ddd;
    padding: 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.popup-action-btn:hover { background: #e0f7fa; color: #0084a7; border-color: #0084a7; }

/* --- SEARCH & DROPDOWN ENGINE --- */
.search-wrapper { position: relative; width: 100%; }

.map-search-results {
    position: absolute; top: 100%; left: 0; right: 0;
    background: white; border-radius: 0 0 12px 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-height: 300px; overflow-y: auto;
    z-index: 1000; display: none;
    border: 1px solid #eee; border-top: none;
}

.search-result-item {
    padding: 10px 15px; border-bottom: 1px solid #f0f0f0;
    cursor: pointer; display: flex; align-items: center; gap: 10px;
    transition: all 0.2s; font-size: 13px;
}
.search-result-item:hover { background: #f8f9fa; padding-left: 20px; }
.search-result-item:last-child { border-bottom: none; }

/* Custom Site Result (Green) */
.result-type-custom { border-left: 4px solid #2e7d32; }
.result-icon.custom { color: #2e7d32; background: #e8f5e9; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* World API Result (Blue) */
.result-type-api { border-left: 4px solid #0084a7; }
.result-icon.api { color: #0084a7; background: #e0f7fa; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* --- SURPRISE TOOLBAR (Floating Right) --- */
.map-extras-bar {
    position: absolute; top: 80px; right: 10px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 10;
}

.extra-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: white; border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    color: #555; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.extra-btn:hover { transform: scale(1.1); color: #0084a7; }
.extra-btn.active { background: #0084a7; color: white; border: 2px solid white; }

/* Tooltips for buttons */
.extra-btn::after {
    content: attr(data-tooltip);
    position: absolute; right: 50px;
    background: rgba(0,0,0,0.8); color: white;
    padding: 4px 8px; border-radius: 4px;
    font-size: 11px; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.extra-btn:hover::after { opacity: 1; }

/* Fullscreen Fixes */
#map-wrapper.fullscreen {
    position: fixed !important; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 9999; border-radius: 0; margin: 0;
}

/* Styles pour la barre de recherche globale */
.global-search-container {
  margin-left: auto;
  background: #f0f2f5;
  border: 1px solid #e1e4e8;
  border-radius: 20px;
  padding: 5px 15px;
  display: flex;
  align-items: center;
  width: 220px;
  transition: all 0.2s ease;
  height: 35px;
  box-sizing: border-box;
}
.global-search-container:focus-within {
  background: #fff; border-color: var(--teal); width: 280px; box-shadow: 0 2px 8px rgba(0, 132, 167, 0.15);
}
.global-search-container input {
  background: transparent; border: none; color: #333; width: 100%; outline: none; font-size: 13px; margin-left: 10px;
}
.global-search-container i { color: #666; font-size: 14px; }
.global-search-container:focus-within i { color: var(--teal); }

.report-filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: end; 
    background: white; padding: 15px; border-radius: 8px; border: 1px solid #ddd; margin-top: 10px;
}
.report-filters .form-group { margin-bottom: 0; min-width: 120px; }
.report-filters input, .report-filters select { padding: 8px; font-size: 13px; width: 100%; box-sizing: border-box; }

/* Modal General Styles */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center;
}
.modal-content {
    background-color: #fefefe; padding: 20px; border-radius: 8px; width: 100%; max-width: 500px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); animation: slideDown 0.3s ease;
}

/* Settings Accordion Styles */
.settings-accordion-item { border: 1px solid #ddd; border-radius: 8px; margin-bottom: 10px; overflow: hidden; background: white; }
.settings-header { 
    background: #f8f9fa; padding: 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; color: #333;
    transition: background 0.2s;
}
.settings-header:hover { background: #eef2f6; }
.settings-header i { margin-right: 10px; color: var(--teal); }
.settings-content { display: none; padding: 20px; border-top: 1px solid #eee; background: #fff; animation: slideDown 0.3s ease; }
.settings-content.open { display: block; }
.settings-arrow { transition: transform 0.3s; }
.settings-header.active .settings-arrow { transform: rotate(180deg); }

/* Wilaya Filter Styles */
.wilaya-search-box {
    width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.wilaya-section-title {
    font-size: 14px; font-weight: 700; color: #555; margin: 20px 0 10px 0; text-transform: uppercase; border-bottom: 2px solid #eee; padding-bottom: 5px;
}
.custom-zone-badge { background: #166534; color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 8px; }

.fuel-card-overlay-btn { 
    display: none; width: 100%; margin-top: 10px; background: var(--teal); color: white; 
    border: none; padding: 8px; border-radius: 4px; cursor: pointer; font-weight: bold; text-align: center;
}
.fuel-card-container:hover .fuel-card-overlay-btn { display: block; animation: fadeIn 0.3s;}
.fuel-card-overlay-btn:hover { background: var(--teal-dark); }
.pagination-controls { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 15px; padding: 10px; }
.pagination-btn { background: #fff; border: 1px solid #ddd; padding: 5px 12px; border-radius: 4px; cursor: pointer; color: #555; }
.pagination-btn:hover { background: #f0f0f0; }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-info { font-size: 12px; color: #666; }
.api-keys-box { background: #f4f6f8; border: 1px solid #c7d2dd; border-radius: 6px; padding: 10px; margin-top:10px; }
.api-keys-box textarea { width: 100%; border: 1px solid #ddd; border-radius: 4px; padding: 8px; font-family: monospace; font-size: 12px; }

@media (max-width: 768px) {
  .global-search-container { width: 100%; margin-left: 0; margin-top: 10px; order: 99; }
  .header-content { flex-direction: row; }
  #map-wrapper { height: 70vh; }
}