/* ==========================================================
   Directorio y mapa — Plaza República
   Estilo directorio: panel lateral + plano limpio
   ========================================================== */

:root {
    --navy: #1e2a3a;
    --ink: #1a202c;
    --muted: #718096;
    --line: #e5e7eb;
    --green: #2f9e58;
    --green-soft: #e6f4ec;
    --stage: #f1f2f4;
    --occupied: #d9dee5;
    --occupied-line: #a9b1bd;
}

.directory-page {
    max-width: 1500px;
    margin: 0 auto;
    padding: 28px 4% 70px;
    font-family: 'Montserrat', sans-serif;
    color: var(--ink);
}

.directory {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    height: clamp(560px, calc(100vh - 150px), 900px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

/* ---------- Panel lateral ---------- */
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 20px 14px 0 20px;
    border-right: 1px solid var(--line);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    height: 48px;
    margin-right: 6px;
    background: var(--stage);
    border-radius: 10px;
    color: var(--muted);
}
.search-box:focus-within {
    box-shadow: 0 0 0 2px var(--navy);
}
.search-box svg {
    flex: none;
    width: 18px;
    height: 18px;
}
.search-box input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    outline: none;
    font: 500 15px 'Montserrat', sans-serif;
    color: var(--ink);
}
.search-box input::placeholder {
    color: var(--muted);
}

.local-list {
    flex: 1;
    min-height: 0;
    margin: 14px 0 0;
    padding: 0 6px 20px 0;
    list-style: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd2da transparent;
}
.local-list li[hidden] {
    display: none;
}

.local-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    text-align: left;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.local-item:hover,
.local-item.hover {
    background: #f3f4f6;
}
.local-item:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: -2px;
}
.local-item[aria-current="true"] {
    background: var(--navy);
    color: #fff;
}
.local-item .li-name {
    display: block;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}
.local-item .li-sub {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}
.local-item[aria-current="true"] .li-sub {
    color: #b8c2d0;
}
.status-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--green);
}
.status-dot.ocupado {
    background: #a0a8b3;
}

.no-results {
    margin: 8px 6px 20px 0;
    padding: 14px 4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}

/* ---------- Escenario del mapa ---------- */
.stage {
    position: relative;
    min-width: 0;
    background: var(--stage);
    overflow: hidden;
}
.stage-scroll {
    position: absolute;
    inset: 0;
    overflow: auto;
}
.stage-canvas {
    position: relative;
    width: 100%;
    height: 100%;
}

.floor-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
}
.floor-svg.active {
    display: block;
    animation: floorIn 0.35s ease;
}
@keyframes floorIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Locales */
.local {
    cursor: pointer;
    outline: none;
}
.local polygon {
    fill: #fff;
    stroke: var(--green);
    stroke-width: 2;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.08));
    transition: fill 0.2s ease, stroke 0.2s ease;
}
.local.ocupado polygon {
    fill: var(--occupied);
    stroke: var(--occupied-line);
}
.local.disponible:hover polygon,
.local.disponible.hover polygon {
    fill: var(--green-soft);
}
.local.ocupado:hover polygon,
.local.ocupado.hover polygon {
    fill: #c8cfd9;
}
.local:focus-visible polygon {
    stroke: #2563eb;
    stroke-width: 3;
}
.local.selected polygon {
    fill: var(--navy);
    stroke: var(--navy);
}
.local.dim {
    opacity: 0.3;
}

.local-label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 26px;
    fill: #2d3748;
    text-anchor: middle;
    dominant-baseline: middle;
    letter-spacing: 0.3px;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}
.local-label.lg {
    font-size: 40px;
}
.local.selected .local-label {
    fill: #fff;
}

/* Huella de la planta de abajo */
.ghost {
    fill: #e8ebef;
    stroke: #d0d5dc;
    stroke-width: 1.5;
    stroke-dasharray: 6 4;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

/* Etapas y estacionamiento: presentes pero discretos */
.etapa {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 52px;
    fill: #b3bbc6;
    letter-spacing: 14px;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Zona de servicio (Segunda etapa) */
.zona { pointer-events: none; }
.zona polygon {
    stroke: #b9c0cb;
    stroke-width: 1.5;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.zona-banqueta { fill: #e6e1d6; }
.zona-cuarto   { fill: #fff; }
.zona-andador  { stroke: #d6c9ad; }
.zona-verde    { fill: #d3ead9; stroke: #9fcfb0; }
.zona-label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    fill: #7b8594;
    text-anchor: middle;
    dominant-baseline: middle;
    letter-spacing: 1px;
    user-select: none;
    -webkit-user-select: none;
}
.zona-label.grande { fill: #b3bbc6; letter-spacing: 6px; }

/* Cajones de estacionamiento */
.parking {
    pointer-events: none;
}
.parking-line {
    stroke: #aab3bf;
    stroke-width: 1.5;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}
.parking-pmr {
    fill: #dbeafe;
}

/* Leyenda */
.legend {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 3;
    display: flex;
    gap: 16px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.legend span {
    display: flex;
    align-items: center;
    gap: 7px;
}
.legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 2px solid var(--green);
    background: #fff;
}
.legend i.ocupado {
    border-color: var(--occupied-line);
    background: var(--occupied);
}

/* Selector de planta */
.floor-switch {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.floor-btn {
    padding: 11px 20px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.55);
    font: 600 14px 'Montserrat', sans-serif;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.floor-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
}
.floor-btn[aria-selected="true"] {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}
.floor-btn:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: 2px;
}

/* Ficha del local */
.detail-card {
    position: absolute;
    left: 16px;
    bottom: 16px;
    z-index: 4;
    width: min(300px, calc(100% - 32px));
    padding: 20px 20px 18px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
    animation: cardIn 0.22s ease;
}
.detail-card[hidden] {
    display: none;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dc-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}
.dc-close:hover {
    background: #f3f4f6;
    color: var(--ink);
}
.dc-title {
    margin: 0 28px 2px 0;
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
}
.dc-sub {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--muted);
}
.dc-rows {
    margin: 0 0 14px;
    padding: 0;
    font-size: 14px;
}
.dc-rows div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-top: 1px solid var(--line);
}
.dc-rows dt {
    color: var(--muted);
}
.dc-rows dd {
    margin: 0;
    font-weight: 600;
}
.dc-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: var(--green-soft);
    color: #1f7a43;
}
.dc-status.ocupado {
    background: #eceff3;
    color: #4a5568;
}
/* Tooltip al pasar el cursor */
.map-tooltip {
    position: fixed;
    z-index: 99999;
    display: none;
    pointer-events: none;
    padding: 9px 13px;
    border-radius: 9px;
    background: rgba(26, 32, 44, 0.95);
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.map-tooltip.visible {
    display: block;
}
.map-tooltip strong {
    display: block;
    font-size: 14px;
}
.map-tooltip .tt-disponible { color: #7ce3a9; font-weight: 600; }
.map-tooltip .tt-ocupado { color: #c3cad5; font-weight: 600; }

/* ---------- Celular y tablet ---------- */
@media (max-width: 860px) {
    .directory-page {
        padding: 16px 3% 50px;
    }
    .directory {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        height: auto;
    }
    .sidebar {
        padding: 14px 10px 0 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .local-list {
        max-height: 210px;
        margin-top: 10px;
        padding-bottom: 10px;
    }
    .stage {
        height: 520px;
    }
    .stage-canvas {
        width: 100%;
        min-width: 860px;
        height: auto;
        aspect-ratio: 2500 / 2140;
    }
    .floor-switch {
        top: 12px;
        left: 12px;
        right: 12px;
        flex-direction: row;
        justify-content: center;
    }
    .floor-btn {
        padding: 9px 14px;
        font-size: 13px;
    }
    .legend {
        top: auto;
        bottom: 12px;
        left: 12px;
    }
    .stage.has-detail .legend {
        display: none;
    }
    .detail-card {
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .floor-svg.active,
    .detail-card {
        animation: none;
    }
    .local polygon,
    .local-item,
    .floor-btn {
        transition: none;
    }
}