:root {
    --primary: #0a4b63;
    --primary-dark: #063142;
    --primary-light: #166b8b;
    --accent-teal: #0ea5e9;
    --accent-coral: #ea580c;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --brava-color: #d97706;
    --other-oil-color: #64748b;
    
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    height: 64px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    flex-shrink: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.brand-titles h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand-titles p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.search-box {
    position: relative;
    width: 260px;
}

.search-box input {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2.2rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s;
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.65);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

.header-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.4);
}

.header-btn.btn-accent {
    background: var(--accent-coral);
    border-color: transparent;
}
.header-btn.btn-accent:hover {
    background: #c2410c;
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 380px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 500;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
    height: 100%;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.sidebar-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: #f1f5f9;
}

.tab-btn {
    flex: 1;
    padding: 0.65rem;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    text-align: center;
}

.tab-btn.active {
    color: var(--primary);
    background: #ffffff;
    border-bottom-color: var(--primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Accordion Sections for Layers */
.layer-group {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 0.85rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.layer-group-header {
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.layer-group-header:hover {
    background: #f1f5f9;
}

.layer-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.layer-group-count {
    font-size: 0.72rem;
    background: #e2e8f0;
    color: var(--text-muted);
    padding: 0.15rem 0.45rem;
    border-radius: 12px;
    font-weight: 600;
}

.layer-items {
    padding: 0.5rem 0.85rem;
}

.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px dashed #f1f5f9;
}

.layer-item:last-child {
    border-bottom: none;
}

.layer-info {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex: 1;
}

.layer-indicator {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.layer-label {
    font-size: 0.82rem;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
}

.layer-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: block;
}

/* Switch toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.25s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.25s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(16px);
}

/* Municipalities List Tab */
.municipios-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.municipio-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border-left: 4px solid var(--primary);
}

.municipio-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.mun-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.mun-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.mun-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: #e0f2fe;
    color: #0369a1;
}

.mun-stats-quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    font-size: 0.74rem;
    color: var(--text-muted);
}

.mun-stat-item strong {
    color: var(--text-main);
}

.mun-fish-summary {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid #f1f5f9;
    font-size: 0.74rem;
    color: var(--accent-coral);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Map Area */
.map-container {
    flex: 1;
    position: relative;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    background: #e2e8f0;
}

/* Floating Map Controls */
.map-floating-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: var(--primary-dark);
    padding: 0.55rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.glass-btn:hover {
    background: #ffffff;
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.basemap-selector {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.35rem;
    box-shadow: var(--shadow-md);
    display: flex;
    gap: 0.25rem;
}

.basemap-opt {
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.basemap-opt.active {
    background: var(--primary);
    color: #ffffff;
}

/* Map Legends Floating Container */
.map-legends-container {
    position: absolute;
    bottom: 1.5rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    align-items: flex-end;
    z-index: 400;
    pointer-events: none;
}

/* Map Legend Box */
.map-legend {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    font-size: 0.78rem;
    box-shadow: var(--shadow-lg);
    max-width: 260px;
    width: 250px;
    pointer-events: auto;
}

/* Legenda de Intensidade de Pesca (Acima da legenda atual) */
.map-legend-intensity {
    border-left: 3.5px solid #ea580c;
    background: rgba(255, 255, 255, 0.97);
    transition: all 0.25s ease-in-out;
}

.intensity-subtitle {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: -0.25rem;
    margin-bottom: 0.6rem;
    line-height: 1.2;
}

.intensity-scale-body {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
}

.intensity-vertical-bar {
    width: 14px;
    min-height: 140px;
    border-radius: 7px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: linear-gradient(to bottom, 
        #9a3412 0%, 
        #ea580c 20%, 
        #f97316 40%, 
        #fb923c 60%, 
        #fed7aa 80%, 
        #ffedd5 100%
    );
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.intensity-scale-labels {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 3px;
    font-size: 0.7rem;
    line-height: 1.2;
}

.intensity-scale-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.35rem;
}

.intensity-scale-row .intensity-kg {
    font-weight: 600;
    color: #334155;
    font-variant-numeric: tabular-nums;
    font-size: 0.69rem;
}

.intensity-scale-row .intensity-text {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    background: #f8fafc;
    color: #64748b;
    white-space: nowrap;
}

.intensity-scale-row .intensity-text.lvl-6 { color: #9a3412; background: #ffedd5; }
.intensity-scale-row .intensity-text.lvl-5 { color: #c2410c; background: #ffedd5; }
.intensity-scale-row .intensity-text.lvl-4 { color: #ea580c; background: #fff7ed; }
.intensity-scale-row .intensity-text.lvl-3 { color: #d97706; background: #fffbeb; }
.intensity-scale-row .intensity-text.lvl-2 { color: #ca8a04; background: #fefce8; }
.intensity-scale-row .intensity-text.lvl-1 { color: #78716c; background: #f5f5f4; }

.legend-title {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    color: var(--text-main);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Custom Leaflet Popups */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    line-height: 1.4;
}

.pea-popup {
    min-width: 260px;
    max-width: 320px;
}

.pea-popup-header {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
}

.pea-popup-header.header-brava {
    background: linear-gradient(135deg, #d97706, #b45309);
}

.pea-popup-header.header-uc {
    background: linear-gradient(135deg, #059669, #047857);
}

.pea-popup-header.header-infra {
    background: linear-gradient(135deg, #475569, #334155);
}

.pea-popup-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.pea-popup-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
}

.pea-popup-body {
    padding: 0.85rem 1rem;
    font-size: 0.82rem;
    background: #ffffff;
}

.pea-popup-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    border-bottom: 1px dashed #f1f5f9;
    padding-bottom: 0.25rem;
}

.pea-popup-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pea-popup-label {
    color: var(--text-muted);
    font-weight: 500;
}

.pea-popup-val {
    font-weight: 600;
    color: var(--text-main);
    text-align: right;
}

.pea-popup-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.45rem;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pea-popup-btn:hover {
    background: var(--primary-dark);
}

/* Modal / Drawer for Details */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    justify-content: flex-end;
}

.drawer-backdrop.open {
    display: flex;
}

.drawer-panel {
    width: 500px;
    max-width: 90vw;
    height: 100%;
    background: #ffffff;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    padding: 1.25rem;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

.drawer-header p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.drawer-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.drawer-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.grid-stats-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.stat-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
}

.stat-card-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 0.15rem;
}

.species-bar-item {
    margin-bottom: 0.65rem;
}

.species-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.species-bar-bg {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.species-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-coral), #f97316);
    border-radius: 4px;
}

.note-box {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.75rem;
    color: #92400e;
    line-height: 1.4;
    margin-top: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        height: 100%;
        left: 0;
        z-index: 1000;
    }
    .search-box {
        display: none;
    }
}
