:root {
    --primary-forest: #0d1b11;
    --primary-forest-light: #00ff88;
    /* Vibrant neon green accent */
    --secondary-river: #00b4d8;
    --accent-earth: #ff4d4d;
    --accent-isolated: #d000ff;
    /* Magenta for isolated groups */
    --bg-dark: #050a08;
    --text-light: #f8f9fa;
    --glass: rgba(10, 20, 15, 0.7);
    --glass-border: rgba(0, 255, 136, 0.2);
    --shadow-premium: 0 12px 40px rgba(0, 0, 0, 0.6);

    /* COTA Colors - Cartographic Classes */
    --cota-stable: #2d6a4f;
    /* Verde escuro */
    --cota-future: #00ff88;
    /* Verde claro */
    --cota-corridor: #00b4d8;
    /* Azul */
    --cota-transition: #ffcc00;
    /* Amarelo */
    --cota-pressure: #ff8800;
    /* Laranja */
    --cota-risk: #ff4d4d;
    /* Vermelho */

    /* Spectral Indices Colors */
    --ndvi-low: #d94124;
    --ndvi-mid: #ffcc00;
    --ndvi-high: #2d6a4f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-forest-light);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* Sidebar Styling with Indigenous Influence */
.sidebar {
    width: 260px;
    background: var(--bg-dark);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    z-index: 2000;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.logo-container {
    padding: 20px 0;
    border-bottom: 2px solid var(--glass-border);
    margin-bottom: 20px;
    position: relative;
}

.logo-container {
    text-align: center;
    padding: 10px;
}

.logo-image {
    width: 180px;
    height: auto;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.3));
    image-rendering: -webkit-optimize-contrast;
    opacity: 1;
}

.arvia-subtitle {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--primary-forest-light);
    line-height: 1.2;
    letter-spacing: 1px;
    margin-bottom: 15px;
    font-weight: 600;
}

/* Grafismo Pattern element - Indigenous pattern image */
.grafismo-divider {
    height: 44px; /* Slight adjustment for new aspect ratio */
    background-image: url('./laika.png');
    background-size: auto 100%;
    background-repeat: repeat-x;
    margin-top: 5px;
    opacity: 1;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    image-rendering: -webkit-optimize-contrast;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-item {
    padding: 12px 15px;
    margin: 8px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(233, 236, 239, 0.7);
}

.nav-item:hover,
.nav-item.active {
    background: var(--glass);
    color: white;
    box-shadow: var(--shadow-premium);
}

/* Main Content area */
.main-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

#map {
    width: 100%;
    height: 100%;
}

/* Glassmorphism Panels - Samauma Style */
.overlay-panel {
    position: absolute;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
    z-index: 1100;
    box-shadow: var(--shadow-premium);
    color: var(--text-light);
    overflow-y: auto;
    max-height: 85vh;
}

.overlay-panel h3,
.overlay-panel h4 {
    font-family: 'Outfit', sans-serif;
    color: var(--primary-forest-light);
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.stats-panel {
    top: 20px;
    right: 20px;
    width: 220px;
}

.layer-control {
    bottom: 40px;
    left: 20px;
}

.search-bar {
    top: 20px;
    left: 20px;
    width: 350px;
}

.history-slider {
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 450px;
    text-align: left;
}

.history-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
}

.mode-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    font-size: 0.65rem;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active {
    background: var(--primary-forest-light);
    color: var(--primary-forest);
    font-weight: bold;
}

.index-selector {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    border-top: 1px solid var(--glass-border);
    padding-top: 10px;
}

.index-btn {
    font-size: 0.6rem;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    color: white;
}

.index-btn.active {
    background: var(--secondary-river);
    border-color: var(--secondary-river);
}

/* Swipe Handle */
.leaflet-sbs-range {
    display: none;
    /* We'll use a custom one if needed or just style it */
}

.swipe-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: white;
    z-index: 1000;
    cursor: ew-resize;
    pointer-events: all;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.swipe-handle::after {
    content: '↔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    font-weight: bold;
}

/* Split screen divider */
.split-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: var(--primary-forest-light);
    z-index: 1500;
    box-shadow: 0 0 10px var(--primary-forest-light);
}

.split-map-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.map-pane {
    flex: 1;
    height: 100%;
    position: relative;
    border: 1px solid var(--glass-border);
}

.map-label {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--glass);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    z-index: 1000;
    color: var(--primary-forest-light);
    font-weight: bold;
    border: 1px solid var(--glass-border);
}

.source-selector {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.source-btn {
    font-size: 0.55rem;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    color: white;
    cursor: pointer;
}

.source-btn.active {
    background: var(--primary-forest-light);
    color: var(--primary-forest);
}

.displacement-panel {
    top: 20px;
    right: 20px;
    width: 280px;
}

/* COTA Panel Styles */
.cota-overlay {
    top: 80px;
    left: 20px;
    width: 350px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cota-subnav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.cota-subnav-item {
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 0.7rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cota-subnav-item:hover,
.cota-subnav-item.active {
    background: var(--primary-forest-light);
    color: var(--primary-forest);
    font-weight: bold;
}

.cota-metric-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 12px;
    border-left: 3px solid var(--primary-forest-light);
}

.ipmt-scale {
    height: 10px;
    border-radius: 5px;
    margin: 10px 0;
    background: linear-gradient(to right, #2d6a4f, #ffcc00, #ff4d4d);
    position: relative;
}

.ipmt-marker {
    position: absolute;
    top: -5px;
    width: 4px;
    height: 20px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.chart-placeholder {
    width: 100%;
    height: 120px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--glass-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.7rem;
}

/* Custom range slider styling */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: var(--glass-border);
    height: 6px;
    border-radius: 5px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--primary-forest-light);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Form Styles */
.occurrence-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-height: 90vh;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    z-index: 1000;
}

.occurrence-modal h2 {
    color: var(--primary-forest-light);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 8px;
    color: white;
}

.btn-submit {
    background: var(--primary-forest-light);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    margin-top: 10px;
}

/* Loading Spinner for API Calls */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 255, 136, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-forest-light);
    animation: spin 0.8s linear infinite;
    margin: 10px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* TI Explorer Panel */
.ti-explorer-panel {
    top: 15px;
    left: 280px; /* Offset from sidebar */
    width: 320px;
    height: 70vh;
    display: flex;
    flex-direction: column;
}

.search-input-wrapper {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.search-input-wrapper input {
    background: transparent;
    border: none;
    color: white;
    font-size: 0.85rem;
    width: 100%;
    outline: none;
}

#ti-list-container {
    flex: 1;
    overflow-y: auto;
    margin: 0 -5px;
    padding: 0 5px;
}

.ti-list-item {
    background: rgba(255,255,255,0.03);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.ti-list-item:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--glass-border);
}

.ti-list-item.active {
    background: var(--primary-forest-light);
    border-color: #4ade80;
}

.ti-list-item h5 {
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: white;
}

.ti-list-item p {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
}

/* TI Details Side Panel */
.side-panel {
    position: fixed;
    top: 15px;
    right: 15px;
    bottom: 45px; /* Above bottom bar */
    width: 400px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 50px rgba(0,0,0,0.5);
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.side-panel-header {
    padding: 25px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-panel-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    color: white;
    margin: 0;
}

.close-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.close-btn:hover { background: rgba(255,255,255,0.1); }

.side-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

.info-section { margin-bottom: 25px; }
.info-section label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.status-badge {
    display: inline-block;
    background: var(--primary-forest-light);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.info-item label {
    display: block;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    margin-bottom: 4px;
}

.info-item span {
    font-family: 'Outfit';
    font-size: 1.1rem;
    color: white;
}

.analysis-card {
    background: rgba(215, 68, 62, 0.1);
    border: 1px solid rgba(215, 68, 62, 0.3);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
}

.analysis-card h4 {
    font-size: 0.7rem;
    color: var(--accent-earth);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.risk-bar-container {
    height: 6px;
    background: rgba(0,0,0,0.3);
    border-radius: 3px;
    margin-top: 15px;
    overflow: hidden;
}

.risk-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff9800, #f44336);
    transition: width 1s ease-in-out;
}

.actions-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.2s;
}

.action-btn:hover {
    background: var(--primary-forest-light);
    border-color: #4ade80;
}
