/* ========================================
   BuscaLocal - Estilos principales
   Paleta: Negro carbón + Amarillo neón + Grises
   ======================================== */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --bg-card: #ffffff;
    --bg-hover: #e9ecef;

    --accent-primary: #c20010;
    --accent-secondary: #a00010;
    --accent-muted: #d63447;

    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;

    --border-color: #dee2e6;
    --border-light: #ced4da;

    --success: #00e676;
    --warning: #ffab00;
    --error: #ff5252;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --shadow-glow: 0 0 20px rgba(194, 0, 16, 0.15);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(194, 0, 16, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(194, 0, 16, 0.02) 0%, transparent 50%),
        repeating-linear-gradient(0deg,
            transparent,
            transparent 100px,
            rgba(194, 0, 16, 0.01) 100px,
            rgba(194, 0, 16, 0.01) 101px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 100px,
            rgba(194, 0, 16, 0.01) 100px,
            rgba(194, 0, 16, 0.01) 101px);
    pointer-events: none;
    z-index: -1;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    padding: 5px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-primary), transparent);
    opacity: 0.4;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-icon {
    font-size: 2rem;
    color: var(--accent-primary);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.logo h1 {
    font-family: 'Space Mono', monospace;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 340px 6px 1fr;
    /* sidebar, resizer, content-area */
    gap: 0;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    overflow-y: auto;
    height: 88vh;
    position: relative;
    min-width: 250px;
    max-width: 600px;
    width: 340px;
}

/* Sidebar Resizer - entre sidebar y content-area */
.sidebar-resizer {
    background: var(--border-color);
    cursor: ew-resize;
    z-index: 20;
    transition: background-color var(--transition-fast);
    position: relative;
}

.sidebar-resizer:hover {
    background: var(--accent-primary);
}

.sidebar-resizer:active {
    background: var(--accent-primary);
}

.control-panel {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Control Sections */
.control-section {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 1rem;
    border: 1px solid var(--border-color);
    transition: border-color var(--transition-normal);
}

.control-section:hover {
    border-color: var(--border-light);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.875rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.section-title .icon {
    font-size: 1rem;
}

/* Location Controls */
.location-controls {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.select-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.select-input:hover {
    border-color: var(--accent-muted);
}

.select-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(194, 0, 16, 0.1);
}

.coords-display {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
}

.coord-label {
    color: var(--text-muted);
}

.coord-value {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Area Controls */
.area-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radius-control {
    display: flex;
    align-items: center;
    gap: 2px;
}

.radius-control label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.radius-control input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    appearance: none;
    cursor: pointer;
    
}

.radius-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border: 2px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.radius-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-md);
}

#radius-value {
    font-family: 'Space Mono', monospace;
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 0.5rem 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    font-weight: 600;
}

.category-content {
    display: none;
    flex-direction: column;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.category-content.active {
    display: flex;
}

/* Checkbox Items */
.amenity-filters,
.extra-filters {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.checkbox-item:hover {
    background: var(--bg-hover);
}

.checkbox-item input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.checkbox-item input:checked+.checkmark {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-item input:checked+.checkmark::after {
    content: '✓';
    font-size: 0.75rem;
    color: #ffffff;
    font-weight: 700;
}

.label-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.checkbox-item:hover .label-text,
.checkbox-item input:checked~.label-text {
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--accent-primary);
    color: #ffffff;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-outline {
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-muted);
}

.btn-outline:hover {
    background: rgba(230, 255, 0, 0.1);
    border-color: var(--accent-primary);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

.btn-large {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    filter: grayscale(50%);
}

.btn-icon {
    font-size: 1.1em;
}

/* Content Area */
.content-area {
    display: flex;
    flex-direction: column;
    height: 88vh;
    overflow: hidden;
}

/* Map Container */
.map-container {
    flex: 1;
    position: relative;
    min-height: 400px;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.map-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.loader #loader-text {
    font-weight: 500;
    font-size: 1rem;
}

.loader #loader-hint {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-right-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}



.results-panel {
    min-height: 100px;
    height: 420px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    flex-shrink: 0;
}

/* Map Container - permitir que se reduzca */
.map-container {
    flex: 1;
    position: relative;
    min-height: 100px;
    /* Reducido para permitir más expansión del panel */
}

/* Barra de redimensionamiento */
.results-panel-resizer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border-color);
    cursor: ns-resize;
    z-index: 10;
    transition: background-color var(--transition-fast);
}

.results-panel-resizer:hover {
    background: var(--accent-primary);
}

.results-panel-resizer:active {
    background: var(--accent-primary);
}

.results-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.results-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.results-stats {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.results-stats span {
    color: var(--accent-primary);
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
}

.results-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    align-content: start;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Result Card */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.125rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    animation: fadeIn 0.3s ease forwards;
    opacity: 0;
    box-shadow: var(--shadow-sm);
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.result-card:hover {
    border-color: var(--accent-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.result-card.highlighted {
    border-color: var(--accent-primary);
    background: rgba(194, 0, 16, 0.05);
    box-shadow: var(--shadow-glow);
}

.result-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-type {
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-transform: capitalize;
    font-weight: 500;
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.result-detail {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.result-detail .icon {
    width: 16px;
    text-align: center;
}

.missing-info {
    color: var(--error);
    opacity: 0.8;
    font-style: italic;
}

/* Footer */
.footer {
    padding: 0.875rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Custom Leaflet Styles */
.leaflet-container {
    font-family: inherit;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    width: 32px !important;
    height: 32px !important;
    line-height: 30px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-hover) !important;
    border-color: var(--accent-primary) !important;
}

.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.leaflet-popup-tip {
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
}

.leaflet-popup-close-button:hover {
    color: var(--accent-primary) !important;
}

.custom-marker {
    background: var(--accent-primary);
    border: 3px solid var(--bg-primary);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
}

/* Popup Content */
.popup-content {
    min-width: 200px;
}

.popup-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.popup-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.popup-info p {
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* Draw Controls */
.leaflet-draw-toolbar a {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-draw-toolbar a:hover {
    background: var(--bg-hover) !important;
    border-color: var(--accent-primary) !important;
}

.leaflet-draw-actions a {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.leaflet-draw-actions a:hover {
    background: var(--accent-primary) !important;
    color: #ffffff !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .control-panel {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .control-section {
        flex: 1;
        min-width: 280px;
    }

    .btn-large {
        min-width: 200px;
        flex: none;
    }

    .content-area {
        height: auto;
    }

    .map-container {
        height: 65vh; /* Aumentado de 50vh a 65vh para más altura */
        min-height: 500px;
    }

    .results-panel {
        height: auto;
        max-height: 400px; /* Reducido para dar más espacio al mapa */
    }
}

@media (max-width: 768px) {
    .map-container {
        height: 60vh;
        min-height: 450px;
    }

    .results-panel {
        max-height: 350px;
    }
}

@media (max-width: 640px) {
    .header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .control-panel {
        flex-direction: column;
    }

    .map-container {
        height: 70vh; /* Aún más alto en pantallas muy pequeñas */
        min-height: 400px;
    }

    .results-panel {
        max-height: 300px; /* Más pequeño para dar más espacio al mapa */
    }

    .results-list {
        grid-template-columns: 1fr;
    }
}