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

:root {
    --color-bg: #e8f4f3;
    --color-surface: #ffffff;
    --color-border: rgba(45, 95, 110, 0.12);
    --color-text: #1e3a44;
    --color-muted: #5f7d88;
    --color-accent: #2a8f9c;
    --color-accent-hover: #237a85;
    --color-error: #b54a4a;
    --font-sans: "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 10px;
    --shadow: 0 8px 24px rgba(30, 58, 68, 0.08);
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* ——— Login (mobile-first) ——— */

.app-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.25rem;
    background:
        radial-gradient(ellipse 90% 70% at 50% 0%, rgba(42, 143, 156, 0.12), transparent),
        var(--color-bg);
}

.login-box {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 22rem;
    padding: 2rem 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.login-box__brand {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.login-box__title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.login-box__subtitle {
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.login-box__error {
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    color: var(--color-error);
    background: rgba(181, 74, 74, 0.08);
    border: 1px solid rgba(181, 74, 74, 0.2);
    border-radius: 8px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
}

.login-form__label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
}

.login-form__input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    font: inherit;
    color: var(--color-text);
    background: #f8fbfc;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form__input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(42, 143, 156, 0.15);
}

.login-form__input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ——— Botones ——— */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.25rem;
    font: inherit;
    font-weight: 500;
    color: #fff;
    background: var(--color-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn--ghost {
    color: var(--color-muted);
    background: transparent;
    border: 1px solid var(--color-border);
}

.btn--ghost:hover:not(:disabled) {
    color: var(--color-text);
    background: rgba(42, 143, 156, 0.06);
}

.btn--sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.875rem;
}

/* ——— Mapa (vista autenticada, pantalla completa) ——— */

html.app-map-root,
html.app-map-root body.app-map {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: sans-serif;
}

body.app-map {
    position: relative;
    background: var(--color-bg);
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    touch-action: pan-x pan-y;
}

.leaflet-container {
    font-family: sans-serif;
}

.map-header {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.map-header__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.map-header__logout {
    margin: 0;
}

/* ——— Pines premium del mapa ——— */

.leaflet-div-icon.premium-marker {
    background: transparent;
    border: none;
}

.pin-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    cursor: pointer;
}

.resaltado-label {
    margin-bottom: 10px;
    padding: 10px 16px;
    font-family: sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.2;
    color: #ffffff;
    white-space: nowrap;
    text-align: center;
    background: rgba(15, 35, 75, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 12px;
    box-shadow:
        0 6px 20px rgba(0, 18, 48, 0.35),
        0 1px 0 rgba(255, 255, 255, 0.12) inset;
    pointer-events: none;
}

.pin-pulse {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 80px;
    pointer-events: auto;
    cursor: pointer;
}

.pin-pulse::after {
    content: "";
    position: absolute;
    top: 78%;
    left: 50%;
    z-index: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.38);
    transform: translate(-50%, -50%) scale(0.65);
    animation: pin-radar 2.4s ease-out infinite;
    pointer-events: none;
}

.oversized-blue-pin {
    position: relative;
    z-index: 1;
    width: 60px;
    height: 72px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 40'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='10%25' y1='0%25' x2='90%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%2360a5fa'/%3E%3Cstop offset='35%25' stop-color='%232563eb'/%3E%3Cstop offset='72%25' stop-color='%231d4ed8'/%3E%3Cstop offset='100%25' stop-color='%231e3a8a'/%3E%3C/linearGradient%3E%3ClinearGradient id='i' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%23ffffff' stop-opacity='0.5'/%3E%3Cstop offset='50%25' stop-color='%2393c5fd' stop-opacity='0.25'/%3E%3Cstop offset='100%25' stop-color='%231e40af' stop-opacity='0.2'/%3E%3C/linearGradient%3E%3ClinearGradient id='s' x1='35%25' y1='10%25' x2='65%25' y2='90%25'%3E%3Cstop offset='0%25' stop-color='%23ffffff' stop-opacity='0.92'/%3E%3Cstop offset='100%25' stop-color='%23ffffff' stop-opacity='0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M16 1.8C16 1.8 3.2 18.2 3.2 26.2a12.8 12.8 0 1 0 25.6 0C28.8 18.2 16 1.8 16 1.8z' fill='url(%23g)' stroke='%23d8e2f0' stroke-width='1.1'/%3E%3Cpath d='M16 1.8C16 1.8 3.2 18.2 3.2 26.2a12.8 12.8 0 1 0 25.6 0C28.8 18.2 16 1.8 16 1.8z' fill='url(%23i)'/%3E%3Cellipse cx='11.2' cy='20.5' rx='3.4' ry='5.8' fill='url(%23s)' opacity='0.85'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center bottom;
    background-size: contain;
    filter: drop-shadow(0 5px 12px rgba(15, 40, 100, 0.45)) drop-shadow(0 0 16px rgba(37, 99, 235, 0.35));
    transition: transform 0.2s ease, filter 0.2s ease;
}

.pin-pulse:hover .oversized-blue-pin {
    transform: translateY(-3px) scale(1.05);
    filter: drop-shadow(0 8px 16px rgba(15, 40, 100, 0.5)) drop-shadow(0 0 20px rgba(37, 99, 235, 0.45));
}

@keyframes pin-radar {
    0% {
        transform: translate(-50%, -50%) scale(0.55);
        opacity: 0.65;
    }

    70% {
        transform: translate(-50%, -50%) scale(2.8);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(2.8);
        opacity: 0;
    }
}

@media (min-width: 640px) {
    .resaltado-label {
        font-size: 15px;
        padding: 11px 18px;
    }

    .oversized-blue-pin {
        width: 60px;
        height: 72px;
    }
}

/* Modal con efecto esmerilado */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1.25rem;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content__title {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--color-text);
    padding-right: 1.5rem;
}

.modal-content__subtitle {
    margin-top: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-accent);
}

.badge-premium {
    display: inline-block;
    margin-top: 0.65rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #ffffff;
    background: #0d1b2a;
    border-radius: 999px;
}

.modal-content__desc {
    margin-top: 1rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-muted);
}

.modal-thumb {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-thumb:hover {
    transform: scale(1.02);
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.88);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
}

.image-lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

.img-fullscreen {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    cursor: default;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
}

.modal-close:hover {
    color: var(--color-text);
}

.btn-download {
    display: inline-block;
    padding: 12px 24px;
    background-color: #028090;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    transition: background 0.2s;
}

.modal-downloads-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.modal-downloads-container .btn-download {
    margin-top: 0;
}

.btn-maps {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 24px;
    background-color: #ffffff;
    color: #2a8f9c;
    border: 2px solid #2a8f9c;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    transition: background 0.2s, color 0.2s;
}

.btn-maps:hover {
    background-color: #2a8f9c;
    color: #ffffff;
}

.btn-maps[hidden] {
    display: none;
}

.btn-download:hover {
    background-color: #00a896;
}

.btn-disabled {
    background-color: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-download.btn-disabled:hover {
    background-color: #d1d5db;
}

@media (min-width: 640px) {
    .login-box {
        padding: 2.25rem 2rem;
    }

    .login-box__title {
        font-size: 1.35rem;
    }
}
