:root {
    --bg: #080705;
    --panel: #14100b;
    --panel2: #21170d;
    --gold: #d4af37;
    --gold2: #f1d27a;
    --text: #f7edd8;
    --muted: #c9b98d;
    --border: rgba(212, 175, 55, .35);
    --red: #b83232;
    --yellow: #d4af37;
    --green: #29b36a;
    --black: #050505;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    font-family: Georgia, 'Times New Roman', serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

.atlas-body:before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(212, 175, 55, .16), transparent 34%),
        linear-gradient(120deg, #060504, #15100a 55%, #050403);
    pointer-events: none;
}

.atlas-topbar {
    height: 82px;
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 7, 5, .88);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

.eyebrow {
    display: block;
    color: var(--gold2);
    text-transform: uppercase;
    letter-spacing: .18em;
    font-size: .68rem;
    margin-bottom: 2px;
}

h1,
h2,
h3 {
    margin: 0;
    color: var(--gold2);
    font-weight: 700;
}

h1 {
    font-size: 1.55rem;
}

h2 {
    font-size: 1.1rem;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.map-select-form {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
}

select,
input,
textarea {
    background: #0b0907;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

select:focus,
input:focus,
textarea:focus {
    border-color: var(--gold);
}

.btn-gold,
.btn-dark,
.floating-index-btn,
.icon-btn,
button {
    cursor: pointer;
}

.btn-gold {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--gold), #8f6818);
    color: #1b1307;
    font-weight: 800;
    padding: 10px 16px;
    box-shadow: 0 8px 22px rgba(212, 175, 55, .18);
}

.btn-dark {
    display: inline-flex;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    padding: 10px 16px;
    background: #100d09;
}

.atlas-shell {
    position: relative;
    z-index: 2;
    height: 100vh;
    display: flex;
    min-width: 0;
}

.map-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
}

#mapaMundo {
    width: 100%;
    height: 100%;
    background: #090807;
}

.leaflet-container {
    background: #090807;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5) !important;
}

.leaflet-control-zoom a {
    background: #171008 !important;
    color: var(--gold2) !important;
    border-color: var(--border) !important;
}

.places-panel {
    width: 380px;
    max-width: 90vw;
    position: relative;
    z-index: 700;
    height: 100%;
    display: none;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(20, 16, 11, .97), rgba(10, 8, 6, .98));
    border-right: 1px solid var(--border);
    box-shadow: 20px 0 45px rgba(0, 0, 0, .45);
}

.places-panel.is-open {
    display: flex;
}

.panel-head {
    padding: 18px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #0d0a07;
    color: var(--gold2);
    font-size: 1.4rem;
    line-height: 1;
}

.index-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.place-detail {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border-bottom: none;
    background:
        radial-gradient(circle at top, rgba(212, 175, 55, .09), transparent 45%),
        rgba(7, 5, 3, .38);
}

.place-detail-card {
    padding: 14px;
}

.place-detail-img-wrap {
    width: 100%;
    overflow: hidden;
    border-radius: 14px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    background: #050403;
}

.place-detail-img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
}

.place-detail-title {
    margin-bottom: 8px;
}

.place-detail-title h3 {
    color: var(--gold2);
    font-size: 1.25rem;
    line-height: 1.15;
    margin-top: 3px;
}

.place-detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 800;
    padding: 5px 9px;
    color: #130d06;
}

.badge-status.no_visitado {
    color: #fff;
    background: var(--red);
}

.badge-status.visitado {
    color: #191005;
    background: var(--yellow);
}

.badge-status.memorial {
    color: #f0f0f0;
    background: #050505;
    border: 1px solid #777;
}

.detail-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(212, 175, 55, .18);
}

.detail-section h4 {
    margin: 0 0 6px;
    color: var(--gold2);
    font-size: .92rem;
}

.detail-section p {
    margin: 0;
    color: var(--text);
    line-height: 1.45;
    font-size: .9rem;
}

.detail-sessions {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-sessions li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(212, 175, 55, .12);
}

.detail-sessions li:last-child {
    border-bottom: none;
}

.detail-sessions span {
    display: block;
    color: var(--text);
    font-weight: 700;
}

.detail-sessions small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
    line-height: 1.35;
}

.search-box {
    padding: 14px 16px;
    flex: 0 0 auto;
}

.search-box input {
    width: 100%;
}

.legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 16px 14px;
    color: var(--muted);
    font-size: .8rem;
    border-bottom: 1px solid rgba(212, 175, 55, .15);
    flex: 0 0 auto;
}

.legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.places-list {
    overflow-y: auto;
    padding: 10px;
    min-height: 0;
    flex: 1 1 auto;
}

.places-empty {
    color: var(--muted);
    padding: 18px;
    text-align: center;
    line-height: 1.4;
}

.place-row {
    width: 100%;
    display: flex;
    text-align: left;
    align-items: center;
    gap: 10px;
    padding: 11px 10px;
    border: none;
    border-radius: 14px;
    background: transparent;
    color: var(--text);
    margin-bottom: 6px;
}

.place-row:hover,
.place-row.active {
    background: rgba(212, 175, 55, .13);
}

.place-row.active {
    outline: 1px solid rgba(41, 179, 106, .55);
    box-shadow: inset 0 0 0 1px rgba(41, 179, 106, .25);
}

.place-row span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.place-row small {
    color: var(--muted);
}

.floating-index-btn {
    position: absolute;
    top: 102px;
    left: 18px;
    z-index: 710;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(13, 10, 7, .9);
    color: var(--gold2);
    padding: 10px 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

.hidden {
    display: none !important;
}

.dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 11px;
    border: 1px solid rgba(255, 255, 255, .35);
}

.dot-red {
    background: var(--red);
}

.dot-yellow {
    background: var(--yellow);
}

.dot-green {
    background: var(--green);
}

.dot-black {
    background: var(--black);
}

.atlas-marker {
    background: transparent;
    border: none;
}

.atlas-marker span {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow:
        0 0 0 3px rgba(0, 0, 0, .35),
        0 0 20px rgba(255, 255, 255, .22);
}

.marker-red span {
    background: var(--red);
}

.marker-yellow span {
    background: var(--yellow);
}

.marker-green span {
    background: var(--green);
    animation: pulse 1.1s infinite;
}

.marker-black span {
    background: var(--black);
    border-color: #777;
}

@keyframes pulse {
    50% {
        transform: scale(1.18);
        box-shadow:
            0 0 0 4px rgba(41, 179, 106, .2),
            0 0 24px rgba(41, 179, 106, .75);
    }
}

.atlas-tooltip {
    background: rgba(18, 13, 8, .95);
    color: var(--gold2);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .35);
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    padding: 5px 9px;
}

.atlas-tooltip:before {
    border-top-color: rgba(18, 13, 8, .95);
}

.empty-state {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
    min-height: calc(100vh - 82px);
    text-align: center;
    padding: 30px;
}

.empty-state p {
    color: var(--muted);
}

.admin-body {
    overflow: auto;
}

.admin-wrap {
    position: relative;
    z-index: 2;
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px;
}

.admin-card {
    background: rgba(20, 16, 11, .94);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
    margin-bottom: 18px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-grid .full {
    grid-column: 1 / -1;
}

.field label {
    display: block;
    color: var(--gold2);
    font-size: .9rem;
    margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
}

.field textarea {
    min-height: 110px;
    resize: vertical;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    border-bottom: 1px solid rgba(212, 175, 55, .18);
    padding: 10px;
    text-align: left;
}

.table th {
    color: var(--gold2);
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.notice {
    padding: 14px;
    border-radius: 14px;
    background: rgba(212, 175, 55, .12);
    border: 1px solid var(--border);
    color: var(--text);
}

.admin-map-picker {
    height: 520px;
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
}

.small-help {
    color: var(--muted);
    font-size: .88rem;
}

.checkbox-list {
    max-height: 240px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px;
    background: #0b0907;
}

.checkbox-list label {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 7px;
    border-bottom: 1px solid rgba(212, 175, 55, .1);
}

.places-panel,
.place-detail,
.places-list,
.checkbox-list {
    scrollbar-width: thin;
    scrollbar-color: #d4af37 #120d08;
}

.places-panel::-webkit-scrollbar,
.place-detail::-webkit-scrollbar,
.places-list::-webkit-scrollbar,
.checkbox-list::-webkit-scrollbar {
    width: 12px;
}

.places-panel::-webkit-scrollbar-track,
.place-detail::-webkit-scrollbar-track,
.places-list::-webkit-scrollbar-track,
.checkbox-list::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #0b0805, #1a1209, #0b0805);
    border-left: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 999px;
}

.places-panel::-webkit-scrollbar-thumb,
.place-detail::-webkit-scrollbar-thumb,
.places-list::-webkit-scrollbar-thumb,
.checkbox-list::-webkit-scrollbar-thumb {
    background:
        linear-gradient(180deg, #f1d27a 0%, #d4af37 35%, #8f6818 70%, #f1d27a 100%);
    border-radius: 999px;
    border: 2px solid #120d08;
    box-shadow:
        inset 0 0 4px rgba(255, 255, 255, 0.35),
        0 0 8px rgba(212, 175, 55, 0.35);
}

.places-panel::-webkit-scrollbar-thumb:hover,
.place-detail::-webkit-scrollbar-thumb:hover,
.places-list::-webkit-scrollbar-thumb:hover,
.checkbox-list::-webkit-scrollbar-thumb:hover {
    background:
        linear-gradient(180deg, #fff1a8 0%, #d4af37 45%, #7a5512 100%);
    box-shadow:
        inset 0 0 5px rgba(255, 255, 255, 0.45),
        0 0 12px rgba(241, 210, 122, 0.55);
}

.places-panel::-webkit-scrollbar-corner,
.place-detail::-webkit-scrollbar-corner,
.places-list::-webkit-scrollbar-corner,
.checkbox-list::-webkit-scrollbar-corner {
    background: #120d08;
}

.btn-deselect-place {
    width: 100%;
    border: 1px solid rgba(212, 175, 55, .35);
    border-radius: 999px;
    background: rgba(10, 8, 6, .86);
    color: #f1d27a;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    transition: all .2s ease;
}

.btn-deselect-place:hover {
    background: rgba(212, 175, 55, .14);
    border-color: rgba(241, 210, 122, .75);
    box-shadow: 0 0 18px rgba(212, 175, 55, .18);
}

@media (max-width: 760px) {
    .atlas-topbar {
        height: auto;
        align-items: flex-start;
        gap: 12px;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .atlas-shell {
        height: 100vh;
    }

    .places-panel {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(380px, 92vw);
    }

    .map-title-card {
        left: 12px;
        right: 12px;
        max-width: none;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   BOTÓN DE CAPAS / SELECTOR DE MAPAS
   ========================================================= */

.map-layers-btn {
    position: absolute;
    right: 52px;
    bottom: 10px;
    z-index: 810;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(212, 175, 55, .75);
    border-radius: 6px;
    background:
        linear-gradient(180deg, #fff7df, #e8d49a);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, .35),
        inset 0 0 0 1px rgba(255, 255, 255, .65);
    display: grid;
    place-items: center;
    padding: 4px;
    transition: all .2s ease;
}

.map-layers-btn img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
    filter:
        drop-shadow(0 1px 2px rgba(0, 0, 0, .8))
        saturate(1.05);
}


.map-layers-btn:hover,
.map-layers-btn.is-active {
    border-color: rgba(212, 175, 55, 1);
    background:
        linear-gradient(180deg, #ffffff, #f1d27a);
    box-shadow:
        0 0 18px rgba(212, 175, 55, .45),
        0 8px 22px rgba(0, 0, 0, .4);
    transform: translateY(-1px);
}

.map-layers-panel {
    position: absolute;
    right: 52px;
    bottom: 54px;
    z-index: 820;
    width: 330px;
    max-width: calc(100vw - 24px);
    max-height: min(520px, calc(100vh - 150px));
    background:
        radial-gradient(circle at top, rgba(212, 175, 55, .12), transparent 42%),
        linear-gradient(180deg, rgba(20, 16, 11, .98), rgba(8, 6, 4, .98));
    border: 1px solid rgba(212, 175, 55, .45);
    border-radius: 18px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, .68),
        inset 0 0 0 1px rgba(255, 255, 255, .04);
    overflow: hidden;
}

.map-layers-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(212, 175, 55, .25);
}

.map-layers-head h3 {
    margin: 0;
    color: var(--gold2);
    font-size: 1rem;
}

.mini-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(212, 175, 55, .35);
    background: rgba(10, 8, 6, .9);
    color: var(--gold2);
    font-size: 1.25rem;
    line-height: 1;
}

.mini-close-btn:hover {
    background: rgba(212, 175, 55, .13);
    border-color: rgba(241, 210, 122, .7);
}

.map-layers-list {
    padding: 12px;
    overflow-y: auto;
    max-height: calc(min(520px, calc(100vh - 150px)) - 65px);
}

.map-layer-item {
    width: 100%;
    border: 1px solid rgba(212, 175, 55, .18);
    border-radius: 14px;
    background: rgba(255, 255, 255, .035);
    color: var(--text);
    padding: 8px;
    display: grid;
    grid-template-columns: 74px 1fr auto;
    gap: 10px;
    align-items: center;
    text-align: left;
    margin-bottom: 8px;
    transition: all .18s ease;
}

.map-layer-item:hover {
    background: rgba(212, 175, 55, .12);
    border-color: rgba(212, 175, 55, .42);
    transform: translateY(-1px);
}

.map-layer-item.active {
    background: rgba(41, 179, 106, .12);
    border-color: rgba(41, 179, 106, .65);
    box-shadow: inset 0 0 0 1px rgba(41, 179, 106, .25);
}

.map-layer-thumb {
    width: 74px;
    height: 54px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(212, 175, 55, .3);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, .45);
}

.map-layer-thumb.no-image {
    background:
        linear-gradient(135deg, rgba(212, 175, 55, .18), rgba(0, 0, 0, .3)),
        #0b0805;
}

.map-layer-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.map-layer-info strong {
    color: var(--gold2);
    font-size: .92rem;
    line-height: 1.15;
}

.map-layer-info small {
    color: var(--muted);
    font-size: .76rem;
    line-height: 1.2;
}

.map-layer-check {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--green);
    color: #06170d;
    font-weight: 900;
    font-style: normal;
}

.map-layer-empty {
    color: var(--muted);
    text-align: center;
    padding: 18px;
    line-height: 1.4;
}

/* Scroll medieval también para el selector de capas */

.map-layers-list {
    scrollbar-width: thin;
    scrollbar-color: #d4af37 #120d08;
}

.map-layers-list::-webkit-scrollbar {
    width: 12px;
}

.map-layers-list::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #0b0805, #1a1209, #0b0805);
    border-left: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 999px;
}

.map-layers-list::-webkit-scrollbar-thumb {
    background:
        linear-gradient(180deg, #f1d27a 0%, #d4af37 35%, #8f6818 70%, #f1d27a 100%);
    border-radius: 999px;
    border: 2px solid #120d08;
    box-shadow:
        inset 0 0 4px rgba(255, 255, 255, 0.35),
        0 0 8px rgba(212, 175, 55, 0.35);
}

.map-layers-list::-webkit-scrollbar-thumb:hover {
    background:
        linear-gradient(180deg, #fff1a8 0%, #d4af37 45%, #7a5512 100%);
}

@media (max-width: 760px) {
    .map-layers-btn {
        right: 52px;
        bottom: 10px;
    }

    .map-layers-panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 54px;
    }

    .map-layer-item {
        grid-template-columns: 64px 1fr auto;
    }

    .map-layer-thumb {
        width: 64px;
        height: 48px;
    }
}

/* =========================================================
   MODO SIN HEADER SUPERIOR
   ========================================================= */

.atlas-no-header .atlas-topbar {
    display: none;
}

.full-empty-state {
    min-height: 100vh;
}

.empty-logo {
    display: block;
    width: min(260px, 80vw);
    max-height: 150px;
    object-fit: contain;
    margin: 0 auto 22px;
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, .65));
}

.empty-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

/* =========================================================
   LOGO Y NAVEGACIÓN EN BARRA LATERAL
   ========================================================= */

.side-brand {
    flex: 0 0 auto;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(212, 175, 55, .25);
    background:
        radial-gradient(circle at top, rgba(212, 175, 55, .13), transparent 48%),
        linear-gradient(180deg, rgba(9, 7, 5, .98), rgba(18, 13, 8, .96));
}

.side-logo-link {
    display: block;
    text-decoration: none;
}

.side-logo {
    display: block;
    width: 100%;
    max-width: 250px;
    max-height: 115px;
    object-fit: contain;
    margin: 0 auto;
    filter:
        drop-shadow(0 10px 22px rgba(0, 0, 0, .7))
        drop-shadow(0 0 12px rgba(212, 175, 55, .14));
}

.side-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.side-btn {
    justify-content: center;
    min-width: 110px;
    padding: 9px 14px;
    font-size: .86rem;
}

/* Ajuste del botón para mostrar el panel cuando está oculto */
.floating-index-btn {
    top: 18px;
}

/* Como ya no hay header, el panel lateral usa todo el alto */
.places-panel {
    height: 100vh;
}

/* El mapa ahora ocupa todo el alto */
.map-wrap {
    height: 100vh;
}

/* En móvil también usamos toda la pantalla */
@media (max-width: 760px) {
    .atlas-shell {
        height: 100vh;
    }

    .places-panel {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        width: min(380px, 92vw);
    }

    .side-logo {
        max-height: 95px;
        max-width: 220px;
    }

    .side-actions {
        gap: 8px;
    }

    .side-btn {
        min-width: auto;
        flex: 1 1 120px;
    }

    .floating-index-btn {
        top: 14px;
        left: 14px;
    }
}

/* =========================================================
   ESPACIO INFERIOR EXTRA EN BARRA LATERAL PARA MÓVILES
   Evita que la barra de navegación del celular tape el contenido
   ========================================================= */

@media (max-width: 760px) {
    .places-list {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .place-detail {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .place-detail-card {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .index-content {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* =========================================================
   CONTROLES DEL MAPA: ZOOM + CAPAS
   Bloque único para evitar conflictos entre reglas duplicadas.
   ========================================================= */

/*
    Para mover SOLO el botón de capas:
    - Aumenta --layers-button-extra-up para subirlo.
    - Usa 0px para alinearlo con el botón de zoom.
    - Usa valores negativos para bajarlo.

    Ejemplos:
    --layers-button-extra-up: 10px;  sube 10px
    --layers-button-extra-up: 0px;   no lo sube
    --layers-button-extra-up: -5px;  baja 5px
*/

:root {
    --map-controls-bottom-safe: calc(24px + env(safe-area-inset-bottom, 0px));
    --map-controls-right-safe: calc(18px + env(safe-area-inset-right, 0px));
    --map-controls-gap-safe: 16px;
    --map-control-size: 36px;
    --layers-button-extra-up: 10px;
}

/* Control de zoom + / - de Leaflet */
.leaflet-bottom.leaflet-right {
    bottom: var(--map-controls-bottom-safe) !important;
    right: var(--map-controls-right-safe) !important;
    z-index: 850 !important;
}

/* Botón de capas */
.map-layers-btn {
    bottom: calc(var(--map-controls-bottom-safe) + var(--layers-button-extra-up)) !important;
    right: calc(
        var(--map-controls-right-safe) + var(--map-control-size) + var(--map-controls-gap-safe)
    ) !important;
    width: var(--map-control-size) !important;
    height: var(--map-control-size) !important;
    z-index: 860 !important;
}

/* Panel de capas */
.map-layers-panel {
    bottom: calc(var(--map-controls-bottom-safe) + 54px + var(--layers-button-extra-up)) !important;
    z-index: 870 !important;
}

/* =========================================================
   TABLETS Y PANTALLAS MEDIANAS
   ========================================================= */

@media (min-width: 761px) and (max-width: 1180px) {
    :root {
        --map-controls-bottom-safe: calc(70px + env(safe-area-inset-bottom, 0px));
        --map-controls-right-safe: calc(22px + env(safe-area-inset-right, 0px));
        --map-controls-gap-safe: 18px;
        --layers-button-extra-up: 10px;
    }

    .map-layers-panel {
        right: 22px !important;
        max-height: calc(100vh - 170px - env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* =========================================================
   CELULARES
   ========================================================= */

@media (max-width: 760px) {
    :root {
        --map-controls-bottom-safe: calc(86px + env(safe-area-inset-bottom, 0px));
        --map-controls-right-safe: calc(16px + env(safe-area-inset-right, 0px));
        --map-controls-gap-safe: 16px;
        --map-control-size: 36px;

        /*
           ESTA ES LA PARTE QUE PUEDES AJUSTAR:
           Sube o baja SOLO el botón de capas en celular.
        */
        --layers-button-extra-up: 10px;
    }

    .map-layers-btn img {
        width: 26px !important;
        height: 26px !important;
    }

    .map-layers-panel {
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
        max-height: calc(100vh - 210px - env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* =========================================================
   TABLETS EN HORIZONTAL O NAVEGADORES CON BARRA INFERIOR GRANDE
   ========================================================= */

@media (pointer: coarse) and (min-width: 761px) {
    :root {
        --map-controls-bottom-safe: calc(82px + env(safe-area-inset-bottom, 0px));
        --map-controls-right-safe: calc(24px + env(safe-area-inset-right, 0px));
        --map-controls-gap-safe: 18px;
        --layers-button-extra-up: 10px;
    }

    .map-layers-panel {
        bottom: calc(var(--map-controls-bottom-safe) + 66px + var(--layers-button-extra-up)) !important;
    }
}
/* =========================================================
   SCROLL GENERAL PARA TODA LA BARRA LATERAL
   Permite bajar logo, botones, cabecera, listado y detalle juntos
   ========================================================= */

.places-panel {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: none;
}

/* Cuando está abierta mantiene flex, pero permite scroll general */
.places-panel.is-open {
    display: flex !important;
    flex-direction: column;
}

/* Evita que estas secciones internas generen scroll separado */
.index-content {
    flex: 0 0 auto !important;
    min-height: auto !important;
    overflow: visible !important;
}

.place-detail {
    flex: 0 0 auto !important;
    min-height: auto !important;
    overflow: visible !important;
}

.places-list {
    flex: 0 0 auto !important;
    min-height: auto !important;
    overflow: visible !important;
}

/* Espacio inferior para que en celular nada quede tapado por la navegación */
.places-panel {
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Mantiene el scroll medieval en toda la barra */
.places-panel {
    scrollbar-width: thin;
    scrollbar-color: #d4af37 #120d08;
}

.places-panel::-webkit-scrollbar {
    width: 12px;
}

.places-panel::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #0b0805, #1a1209, #0b0805);
    border-left: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 999px;
}

.places-panel::-webkit-scrollbar-thumb {
    background:
        linear-gradient(180deg, #f1d27a 0%, #d4af37 35%, #8f6818 70%, #f1d27a 100%);
    border-radius: 999px;
    border: 2px solid #120d08;
    box-shadow:
        inset 0 0 4px rgba(255, 255, 255, 0.35),
        0 0 8px rgba(212, 175, 55, 0.35);
}

.places-panel::-webkit-scrollbar-thumb:hover {
    background:
        linear-gradient(180deg, #fff1a8 0%, #d4af37 45%, #7a5512 100%);
    box-shadow:
        inset 0 0 5px rgba(255, 255, 255, 0.45),
        0 0 12px rgba(241, 210, 122, 0.55);
}

/* Ajuste especial en celular */
@media (max-width: 760px) {
    .places-panel {
        height: 100vh !important;
        max-height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .places-list,
    .place-detail,
    .place-detail-card,
    .index-content {
        padding-bottom: 0 !important;
    }
}


