/* === CORE LAYOUT === */
body { margin: 0; padding: 0; display: flex; flex-direction: column; height: 100vh; background: #000; font-family: sans-serif; overflow: hidden; }

/* === SYSTEM: AR CAMERA VIEWPORT === */
#camera-container { flex: 1; position: relative; overflow: hidden; background: #111; display: none; align-items: center; justify-content: center; color: #555; }
#camera-container.active { display: flex; }
video { width: 100%; height: 100%; object-fit: cover; display: none; }
video.active { display: block; }

/* AR Node Elements (Injected via JS) */
.ar-node { position: absolute; top: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 10; display: none; }
.ar-bubble { background: rgba(40, 167, 69, 0.9); color: white; padding: 10px 20px; border-radius: 20px; font-weight: bold; font-size: 18px; box-shadow: 0 0 10px rgba(0,0,0,0.5); border: 2px solid white; white-space: nowrap; }
.ar-dist { font-size: 14px; margin-top: 5px; text-shadow: 0 1px 2px black; color: #fff; font-weight: bold; }
.ar-breadcrumb { width: 15px; height: 15px; background: #0078FF; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 8px rgba(0, 120, 255, 0.8); }

/* === SYSTEM: UI OVERLAYS === */
#map { flex: 1; width: 100%; }

/* The main control stack. Uses max-height and overflow-y to prevent buttons from pushing off-screen on small mobile devices. */
#controls { position: absolute; bottom: 20px; left: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-height: 85vh; overflow-y: auto; padding-right: 10px; scrollbar-width: none; }
#controls::-webkit-scrollbar { display: none; }
#data-display { display: none; position: fixed; bottom: 20px; right: 80px; z-index: 1000; background: rgba(0, 0, 0, 0.7); padding: 8px 15px; border-radius: 15px; color: white; flex-direction: column; min-width: 140px; }
.data-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-bottom: 4px; }
.data-val { font-weight: bold; font-family: monospace; font-size: 16px; }

/* Interactive Buttons */
.pill-btn { background-color: #444; color: white; border: none; padding: 12px 20px; border-radius: 50px; font-size: 14px; font-weight: bold; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.3); text-align: center; width: 120px; transition: background-color 0.2s; }
.pill-btn.active { background-color: #28a745; }
#btn-route { background-color: #007bff; }
#btn-reset { background: #d9534f; color: white; border: none; border-radius: 4px; padding: 4px 8px; font-size: 11px; cursor: pointer; margin-top: 5px; align-self: flex-end; }
.btn-row { display: flex; gap: 10px; align-items: center; }


/* === SYSTEM: MODALS & POPUPS === */
#chart-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 3000; display: none; flex-direction: column; align-items: center; justify-content: center; }
#chart-container { width: 95%; height: 50%; background: white; border-radius: 8px; padding: 10px; }
#close-chart { margin-top: 20px; padding: 10px 30px; background: white; border: none; font-weight: bold; border-radius: 50px; cursor: pointer; }

#status-row { position: fixed; top: 66px; left: 16px; display: flex; gap: 8px; z-index: 1000; pointer-events: none; }
#status, #compass-status { background: rgba(0, 0, 0, 0.6); color: white; padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; }
.leaflet-top { margin-top: 58px !important; }
#zoom-warning { color: #d9534f; font-size: 13px; font-weight: bold; pointer-events: none; display: none; text-transform: uppercase; letter-spacing: 0.5px; }

/* Settings Tabs */
.settings-tabs { display: flex; margin-bottom: 20px; border-bottom: 2px solid #eee; }
.settings-tab { flex: 1; padding: 10px 6px; background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -2px; font-size: 13px; font-weight: bold; color: #aaa; cursor: pointer; transition: 0.2s; }
.settings-tab.active { color: #333; border-bottom-color: #28a745; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* Settings Gear & Compass Icon Buttons */
#btn-settings { position: fixed; bottom: 20px;  right: 20px; z-index: 2000; background: rgba(50, 50, 50, 0.9); color: white; border: none; border-radius: 50%; width: 50px; height: 50px; font-size: 24px; box-shadow: 0 4px 8px rgba(0,0,0,0.4); cursor: pointer; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
#btn-graph  { position: fixed; bottom: 80px;  right: 20px; z-index: 2000; background: rgba(50, 50, 50, 0.9); border: none; border-radius: 50%; width: 50px; height: 50px; font-size: 24px; box-shadow: 0 4px 8px rgba(0,0,0,0.4); cursor: pointer; display: flex; justify-content: center; align-items: center; transition: filter 0.3s; filter: grayscale(100%); }
#btn-graph.active { filter: grayscale(0%); }
#btn-path   { position: fixed; bottom: 140px; right: 20px; z-index: 2000; background: rgba(50, 50, 50, 0.9); border: none; border-radius: 50%; width: 50px; height: 50px; font-size: 24px; box-shadow: 0 4px 8px rgba(0,0,0,0.4); cursor: pointer; display: flex; justify-content: center; align-items: center; transition: filter 0.3s; filter: grayscale(100%); }
#btn-path.active { filter: grayscale(0%); }
#btn-locate { position: fixed; bottom: 200px; right: 20px; z-index: 2000; background: rgba(50, 50, 50, 0.9); border: none; border-radius: 50%; width: 50px; height: 50px; font-size: 24px; box-shadow: 0 4px 8px rgba(0,0,0,0.4); cursor: pointer; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
#zoom-controls { display: none; position: fixed; bottom: 320px; right: 20px; z-index: 2000; width: 50px; background: white; border-radius: 8px; border: 2px solid rgba(0,0,0,0.25); box-shadow: 0 2px 6px rgba(0,0,0,0.35); overflow: hidden; }
#zoom-controls button { display: block; width: 100%; height: 34px; background: white; border: none; font-size: 20px; font-weight: bold; color: #333; cursor: pointer; padding: 0; line-height: 1; }
#zoom-controls button:first-child { border-bottom: 1px solid rgba(0,0,0,0.2); }
#zoom-controls button:hover { background: #f4f4f4; }
.btn-zoom-toggle { color: white; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: bold; width: 70px; transition: 0.2s; }
#settings-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 3000; display: none; flex-direction: column; align-items: center; justify-content: center; }
.settings-content { background: white; padding: 25px; border-radius: 15px; width: 90%; max-width: 400px; text-align: left; color: #333; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.5); }
#close-settings { position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold; color: #888; cursor: pointer; }

.storage-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; align-items: center; }
.grid-header { font-size: 12px; color: #888; text-transform: uppercase; font-weight: bold; border-bottom: 1px solid #ddd; padding-bottom: 5px; }
.grid-cell { font-size: 14px; }
.name-cell { font-weight: bold; color: #444; }
.size-cell { font-family: monospace; color: #666; text-align: right; padding-right: 10px; }
.btn-clear-row { background: #d9534f; color: white; border: none; padding: 8px 0; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: bold; width: 100%; transition: 0.2s; }

/* Dynamic Route Legend (Appears above data display) */
#route-legend { background: rgba(0, 0, 0, 0.8); padding: 10px 15px; border-radius: 12px; margin-bottom: 5px; color: white; display: none; flex-direction: column; gap: 6px; min-width: 140px; box-shadow: 0 2px 5px rgba(0,0,0,0.5); }
.legend-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: bold; }
.legend-label { display: flex; align-items: center; gap: 8px; color: #ddd; font-weight: normal; }
.legend-color { width: 16px; height: 4px; border-radius: 2px; }

/* === SYSTEM: SEARCH BAR === */
#search-container {
    position: fixed;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 2500;
    display: flex;
    flex-direction: column;
}
#search-pill {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 50px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.35);
    overflow: hidden;
    height: 48px;
}
#search-mode-toggle {
    flex-shrink: 0;
    width: 72px;
    height: 100%;
    border: none;
    background: white;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#search-mode-toggle:hover { background: #f5f5f5; }
#search-divider {
    flex-shrink: 0;
    width: 1px;
    height: 60%;
    background: #ddd;
}
#search-input {
    flex: 1;
    height: 100%;
    padding: 0 16px;
    border: none;
    font-size: 15px;
    outline: none;
    background: white;
    color: #333;
}
#search-input::placeholder { color: #aaa; }
#search-results {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-height: 250px;
    overflow-y: auto;
    display: none;
}
#search-results li {
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    line-height: 1.4;
}
#search-results li:last-child { border-bottom: none; }
#search-results li:hover { background: #f0f0f0; }

/* === SYSTEM: MAP CANVAS CONTROLS (Top Right Grid) === */
.leaflet-right .leaflet-control-layers,
.leaflet-right .leaflet-locate-control { clear: none !important; float: right !important; }


.leaflet-control-layers {
    background: none !important; border: none !important; box-shadow: none !important; padding: 0 !important;
    display: flex !important; flex-direction: column !important; align-items: flex-end !important;
}
.leaflet-control-layers-toggle {
    background-color: rgba(50, 50, 50, 0.9) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolygon points='12,2 22,7 12,12 2,7' fill='white' opacity='0.9'/%3E%3Cpolygon points='2,11 12,16 22,11' fill='none' stroke='white' stroke-width='1.5' opacity='0.9'/%3E%3Cpolygon points='2,15 12,20 22,15' fill='none' stroke='white' stroke-width='1.5' opacity='0.9'/%3E%3C/svg%3E") !important;
    background-size: 22px 22px !important;
    width: 50px !important; height: 50px !important;
    border-radius: 50% !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4) !important;
    border: none !important;
    flex-shrink: 0 !important;
}
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
    display: flex !important;
}
.leaflet-control-layers-expanded {
    background: none !important; border: none !important; box-shadow: none !important; padding: 0 !important;
}
.leaflet-control-layers-list {
    margin-top: 8px !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    padding: 10px 15px !important;
    font-size: 13px !important;
    color: #333 !important;
    min-width: 180px !important;
}

.map-legend {
    background: rgba(255, 255, 255, 0.9); padding: 10px; border-radius: 5px; box-shadow: 0 1px 5px rgba(0,0,0,0.4); font-size: 12px; line-height: 18px; color: #333; display: none; z-index: 1000; clear: both !important; margin-top: 10px !important;
}
.map-legend i { width: 14px; height: 14px; float: left; margin-right: 8px; opacity: 0.8; border: 1px solid #999; }

/* === SYSTEM: WEATHER POPUP STYLES === */
.weather-popup { text-align: center; min-width: 150px; font-family: sans-serif; }
.weather-popup h4 { margin: 0 0 5px 0; font-size: 16px; }
.weather-popup .elev { margin: 0 0 5px 0; color: #555; font-size: 13px; }
.weather-popup .temp { margin: 0 0 15px 0; font-size: 22px; font-weight: bold; }

.btn-container { display: flex; justify-content: space-between; gap: 8px; }
.btn-weather { flex: 1; padding: 6px; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: bold; }
.btn-24hr { background: #0078FF; }
.btn-24hr:hover { background: #0056b3; }
.btn-7day { background: #28a745; }
.btn-7day:hover { background: #1e7e34; }
