/* PVU WebGIS - Estilos Mobile-First */

:root {
    /* Colores Secretaría de Salud */
    --primary: #1a5f7a;
    --primary-dark: #0d3d4d;
    --secondary: #57c5b6;
    --accent: #159895;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Spacing */
    --header-height: 56px;
    --sidebar-width: 320px;
    --footer-height: 40px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

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

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.header-text h1 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.header-text .subtitle {
    font-size: 11px;
    opacity: 0.85;
}

.menu-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: var(--sidebar-width);
    background: var(--surface);
    z-index: 900;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-content {
    padding: 16px;
    padding-bottom: calc(var(--footer-height) + 24px);
}

/* Mode Selector */
.mode-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.mode-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: var(--primary);
    background: rgba(26, 95, 122, 0.05);
}

.mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.mode-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.mode-label {
    font-size: 14px;
    font-weight: 600;
}

.mode-desc {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
}

/* Mode Indicator on Map */
.mode-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    z-index: 100;
}

/* Search */
.search-section {
    margin-bottom: 20px;
}

.search-section label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box button {
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.search-box button:hover {
    background: var(--primary-dark);
}

.search-results {
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.search-result-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--background);
}

/* Filters */
.filter-section,
.layers-section,
.legend-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.filter-section h3,
.layers-section h3,
.legend-section h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.filter-group {
    margin-bottom: 12px;
}

.filter-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}

.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Layer toggles */
.layer-group {
    margin-bottom: 16px;
}

.layer-group h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 6px;
    transition: background 0.15s;
}

.layer-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.layer-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.layer-color {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid;
    flex-shrink: 0;
}

.layer-name {
    flex: 1;
    font-size: 13px;
    color: var(--text);
}

.legend-empty {
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
    padding: 8px 0;
}

/* Legend */
.legend-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.legend-color {
    width: 20px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Toggle Switch */
.control-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

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

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

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

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

/* Basemap Selector */
.basemap-section {
    margin-bottom: 20px;
}

.basemap-options {
    display: flex;
    gap: 8px;
}

.basemap-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.2s;
}

.basemap-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.basemap-btn.active {
    border-color: var(--primary);
    background: rgba(26, 95, 122, 0.08);
    color: var(--primary);
}

.basemap-icon {
    font-size: 20px;
}

/* Opacity Control */
.opacity-control {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.opacity-control label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.opacity-control input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.opacity-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Map Container */
.map-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
}

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

/* Map Controls */
.map-controls {
    position: absolute;
    right: 16px;
    bottom: 80px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.control-btn {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--background);
    transform: scale(1.05);
}

.control-btn:active {
    transform: scale(0.95);
}

/* Info Panel */
.info-panel {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-height: 40vh;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    z-index: 100;
    transform: translateY(150%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.info-panel.visible {
    transform: translateY(0);
}

.info-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: var(--background);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-panel h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-right: 40px;
    color: var(--primary);
}

.info-content {
    font-size: 14px;
}

.info-hint {
    color: var(--text-light);
    font-style: italic;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.info-table th,
.info-table td {
    padding: 8px 4px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.info-table th {
    font-weight: 500;
    color: var(--text-light);
    width: 40%;
}

.info-table td {
    color: var(--text);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-light);
}

.info-value {
    font-weight: 600;
}

/* Loading */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 11px;
    color: var(--text-light);
    z-index: 50;
}

/* Desktop Styles */
@media (min-width: 768px) {
    .menu-toggle {
        display: none;
    }

    .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-sm);
    }

    .map-container {
        left: var(--sidebar-width);
    }

    .info-panel {
        left: calc(var(--sidebar-width) + 16px);
        right: auto;
        width: 360px;
    }

    .footer {
        left: var(--sidebar-width);
    }

    .header-text h1 {
        font-size: 18px;
    }
}

/* Large Desktop */
@media (min-width: 1200px) {
    :root {
        --sidebar-width: 360px;
    }

    .info-panel {
        width: 400px;
    }
}