﻿/* Scoped Styles for 3D Map Section */
#mall-map-container {
    margin: 0;
    background-color: #050508;
    height: 100vh;
    /* Full viewport height always on map */
    width: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    position: relative;
    /* Container context */
    /* Container context */
    border-radius: 0;
    /* Remove rounding for full screen feel */
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
}

:root {
    --box-w: 200px;
    --box-h: 280px;
    --box-d: 200px;
    --gap: 350px;
}

#map-background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* IMAGEN DE FONDO */
    background-image: url('/images/floor_0_bg.png');
    /* Default, JS will update */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 1s ease-in-out;
    will-change: background-image;
}

#preload-cache {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* --- CONTROLES DE ASCENSOR --- */
#map-elevator-controls {
    position: absolute;
    right: 40px;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.elevator-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.elevator-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
    transform: scale(1.1);
}

.elevator-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(1);
}

.floor-indicator {
    color: white;
    text-align: center;
    font-weight: bold;
    text-shadow: 0 2px 4px black;
    margin-bottom: 5px;
    font-size: 1.2rem;
}

/* UI INFERIOR */
#map-ui-instruction {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    text-align: center;
    pointer-events: none;
    z-index: 100;
    text-shadow: 0 2px 4px black;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
}

/* TRANSICIÃ“N */
#map-transition-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 999;
    transition: opacity 1.5s ease-in;
}

#mall-map-container.fading-out #map-transition-overlay {
    opacity: 1;
}

#world {
    position: relative;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-out;
    z-index: 10;
}

/* --- VIDEO OVERLAY (Keep Fixed for Fullscreen Experience) --- */
#map-video-overlay {
    position: fixed;
    /* Full screen overlay */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(10px);
}

#map-video-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.video-container {
    position: relative;
    width: fit-content;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#video-player {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    box-shadow: 0 0 30px rgba(var(--video-rgb, 255, 153, 0), 0.6);
    border-radius: 10px;
    outline: none;
    background: transparent;
    display: block;
}

.video-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    background: var(--video-color, #ff9900);
    color: black;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(var(--video-rgb, 255, 153, 0), 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: inline-block;
    /* Revert to inline-block but ensure visibility */
    margin-top: 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    z-index: 2147483647;
    /* Keep high z-index */
}

.video-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(var(--video-rgb, 255, 153, 0), 0.8);
}

.floor {
    display: none;
}

.wrapper {
    position: absolute;
    transform-style: preserve-3d;
    cursor: pointer;
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

/* Estado inicial de entrada */
.wrapper.enter-state {
    opacity: 0;
    transform: scale(0.8) translateZ(-100px) !important;
}

.center-circle {
    transition: transform 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s;
    will-change: transform;
}

/* CASILLERO */
.shelf {
    position: absolute;
    width: 240px;
    height: 320px;
    left: -120px;
    top: -160px;
    transform-style: preserve-3d;
    pointer-events: none;
}

.s-face {
    position: absolute;
    background: rgba(10, 10, 10, 0.85);
    border: 1px solid rgba(100, 255, 218, 0.2);
    box-shadow: 0 0 15px rgba(0, 0, 0, 1) inset;
}

.s-top {
    width: 240px;
    height: 240px;
    transform: rotateX(90deg) translateZ(120px);
}

.s-bottom {
    width: 240px;
    height: 240px;
    transform: rotateX(-90deg) translateZ(200px);
    box-shadow: 0 0 30px black inset;
}

.s-back {
    width: 240px;
    height: 320px;
    transform: rotateY(180deg) translateZ(120px);
    background: #000;
}

.s-left {
    width: 240px;
    height: 320px;
    transform: rotateY(-90deg) translateZ(120px);
}

.s-right {
    width: 240px;
    height: 320px;
    transform: rotateY(90deg) translateZ(120px);
}

.shelf::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transform: translateZ(120px);
}

/* CAJA */
.box {
    position: relative;
    width: var(--box-w);
    height: var(--box-h);
    left: -100px;
    top: -140px;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.face {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(10, 15, 20, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backface-visibility: visible;
    box-shadow: 0 0 20px inset rgba(0, 0, 0, 0.8);
}

.face.front {
    width: var(--box-w);
    height: var(--box-h);
    transform: translateZ(calc(var(--box-d) / 2));
    border-color: var(--color);
}

.face.back {
    width: var(--box-w);
    height: var(--box-h);
    transform: rotateY(180deg) translateZ(calc(var(--box-d) / 2));
}

.face.right {
    width: var(--box-d);
    height: var(--box-h);
    transform: rotateY(90deg) translateZ(calc(var(--box-w) / 2));
}

.face.left {
    width: var(--box-d);
    height: var(--box-h);
    transform: rotateY(-90deg) translateZ(calc(var(--box-w) / 2));
}

.face.top {
    width: var(--box-w);
    height: var(--box-d);
    transform: rotateX(90deg) translateZ(calc(var(--box-h) / 2));
    background: var(--color);
    color: black;
    font-size: 2rem;
}

.face.bottom {
    width: var(--box-w);
    height: var(--box-d);
    transform: rotateX(-90deg) translateZ(calc(var(--box-h) / 2));
}

.icon {
    font-size: 4rem;
    filter: drop-shadow(0 0 10px currentColor);
    color: var(--color);
}

.label {
    position: absolute;
    bottom: 35px;
    left: 0;
    width: 100%;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: white;
    font-size: 0.85rem;
    text-align: center;
}

/* ESTADOS */
.wrapper.open .box {
    transform: translateZ(200px);
}

.wrapper.open .face {
    background: rgba(var(--rgb), 0.2);
    border-color: white;
    box-shadow: 0 0 30px rgba(var(--rgb), 0.8);
}

.wrapper.traveling .box {
    transform: translateZ(2000px) rotateY(360deg) scale(2);
    opacity: 0;
    transition: transform 1.5s ease-in, opacity 1.5s ease-in;
}

/* --- CIRCULO CENTRAL --- */
.center-circle {
    position: relative;
    width: 260px;
    height: 260px;
    left: -130px;
    top: -130px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    font-family: 'Segoe UI', sans-serif;
    font-weight: bold;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s;
    cursor: pointer;
    z-index: 10;
}

.center-circle::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    animation: spin 20s linear infinite;
}

.center-circle:hover {
    transform: translateZ(50px) scale(1.1);
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.3);
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
}

.circle-text {
    transform: translateZ(20px);
    text-shadow: 0 2px 10px black;
    padding: 20px;
    position: relative;
    z-index: 2;
}

/* 3D PARTICLE EFFECT */
.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    perspective: 600px;
    pointer-events: none;
}

.p-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-style: preserve-3d;
    border-radius: 50%;
    border: 2px solid transparent;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.p-ring:nth-child(1) {
    width: 100%;
    height: 100%;
    border-top: 2px solid rgba(0, 255, 255, 0.7);
    border-bottom: 2px solid rgba(0, 255, 255, 0.3);
    animation: rot1 4s linear infinite;
}

.p-ring:nth-child(2) {
    width: 80%;
    height: 80%;
    border-left: 2px solid rgba(255, 0, 255, 0.7);
    border-right: 2px solid rgba(255, 0, 255, 0.3);
    animation: rot2 6s linear infinite;
}

.p-ring:nth-child(3) {
    width: 60%;
    height: 60%;
    border-top: 2px solid rgba(255, 255, 0, 0.7);
    border-bottom: 2px solid rgba(255, 255, 0, 0.3);
    animation: rot3 5s linear infinite;
}

@keyframes rot1 {
    0% {
        transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotateX(360deg) rotateY(360deg);
    }
}

@keyframes rot2 {
    0% {
        transform: translate(-50%, -50%) rotateX(0deg) rotateY(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotateX(360deg) rotateY(-360deg);
    }
}

@keyframes rot3 {
    0% {
        transform: translate(-50%, -50%) rotateX(60deg) rotateY(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotateX(60deg) rotateY(360deg);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* --- MOBILE 2D GRID (replaces 3D on small screens) --- */
#mobile-map-grid {
    display: none;
}

@media (max-width: 768px) {
    /* === MOBILE FOUNDATION === */
    html, body {
        overflow: hidden !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        position: fixed !important;
        width: 100% !important;
        top: 0;
        left: 0;
    }

    #mall-map-section.container,
    #mall-map-section.map-section {
        padding: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        height: 100% !important;
        overflow: hidden !important;
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100% !important;
    }

    #mall-map-container {
        height: 100% !important;
        overflow: hidden !important;
        width: 100%;
        max-width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    #map-background-layer {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 0;
    }

    /* Back Button */
    .nav-back {
        position: fixed;
        top: 10px;
        left: 10px;
        padding: 6px 12px;
        font-size: 0.75rem;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(8px);
        border-radius: 20px;
        z-index: 500;
    }

    /* === ELEVATOR CONTROLS === */
    #map-elevator-controls {
        position: fixed !important;
        right: 8px;
        bottom: auto;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
        gap: 6px;
        z-index: 500;
    }

    .elevator-btn {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
        background: rgba(0, 0, 0, 0.75);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.35);
        border-radius: 50%;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    }

    .elevator-btn:active {
        background: rgba(255, 255, 255, 0.25);
        transform: scale(0.9);
    }

    .floor-indicator {
        font-size: 0.75rem;
        background: rgba(0, 0, 0, 0.75);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.25);
        border-radius: 20px;
        padding: 3px 8px;
        text-align: center;
        color: white;
        font-weight: 700;
    }

    /* === VIDEO OVERLAY === */
    #video-player {
        max-width: 95vw;
        max-height: 50vh;
    }

    .video-btn {
        padding: 12px 30px;
        font-size: 1rem;
        width: 80%;
        text-align: center;
        margin-top: 15px;
    }

    #map-ui-instruction {
        display: none;
    }

    /* ===== MOBILE 2D GRID ===== */
    #mobile-map-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 35px 6px 10px 6px;
        width: 100%;
        box-sizing: border-box;
        height: 100%;
        align-content: center;
        overflow: hidden;
        position: relative;
        z-index: 1;
    }

    /* --- CENTER ZABIA LOGO --- */
    .mobile-grid-center {
        aspect-ratio: 1 / 1;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        border-radius: 50%;
        background: rgba(5, 5, 10, 0.85);
        border: 2px solid rgba(255, 255, 255, 0.25);
        box-shadow:
            0 0 15px rgba(255, 255, 255, 0.15),
            inset 0 0 20px rgba(0, 0, 0, 0.8);
        animation: mobileCardIn 0.5s ease-out both;
        transition: transform 0.3s, box-shadow 0.3s;
        margin: auto;
        width: 85%;
    }

    .mobile-grid-center:active {
        transform: scale(0.95);
        box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
    }

    .mobile-grid-center img {
        width: 75%;
        height: 75%;
        object-fit: contain;
        filter: drop-shadow(0 0 10px rgba(255,255,255,0.3));
        animation: mobileLogoFloat 3s ease-in-out infinite;
    }

    @keyframes mobileLogoFloat {
        0%, 100% { transform: scale(0.95); }
        50% { transform: scale(1.02); filter: drop-shadow(0 0 15px rgba(255,255,255,0.5)); }
    }

    /* --- STORE CARDS (matching 3D look) --- */
    .mobile-grid-card {
        position: relative;
        aspect-ratio: 5 / 4;
        background: rgba(10, 10, 15, 0.9);
        border: 1px solid rgba(var(--rgb), 0.35);
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        overflow: hidden;
        transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
        animation: mobileCardIn 0.5s ease-out both;
        box-shadow:
            0 0 12px rgba(var(--rgb), 0.35),
            inset 0 0 20px rgba(0, 0, 0, 0.7);
    }

    .mobile-grid-card:active {
        transform: scale(0.93);
        border-color: var(--color);
        box-shadow:
            0 0 20px rgba(var(--rgb), 0.5),
            inset 0 0 15px rgba(var(--rgb), 0.1);
    }

    .mobile-card-icon {
        width: 65%;
        height: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        filter: drop-shadow(0 0 18px rgba(var(--rgb), 1)) brightness(1.2);
    }

    .mobile-card-icon img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }

    .mobile-card-label {
        position: absolute;
        bottom: 6px;
        left: 0;
        width: 100%;
        text-align: center;
        color: white;
        font-size: 0.46rem;
        line-height: 1.08;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.55px;
        text-shadow: 0 1px 3px rgba(0,0,0,0.9);
    }

    /* Top color accent line (like 3D face.top colored bar) */
    .mobile-card-border-top {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 2px;
        background: var(--color);
        opacity: 0.5;
        border-radius: 8px 8px 0 0;
    }

    /* Bottom color accent line (like 3D colored base) */
    .mobile-card-border-bottom {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 3px;
        background: var(--color);
        opacity: 0.7;
        border-radius: 0 0 8px 8px;
    }

    /* Subtle inner glow (like 3D inset box-shadow) */
    .mobile-card-glow {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 8px;
        box-shadow: inset 0 0 15px rgba(var(--rgb), 0.08);
        pointer-events: none;
    }

    /* Open state for mobile cards */
    .mobile-grid-card.m-open {
        border-color: var(--color);
        box-shadow:
            0 0 25px rgba(var(--rgb), 0.6),
            0 0 50px rgba(var(--rgb), 0.2),
            inset 0 0 15px rgba(var(--rgb), 0.15);
        transform: scale(1.03);
    }

    @keyframes mobileCardIn {
        from {
            opacity: 0;
            transform: translateY(15px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
}
@keyframes floatLogo {
    0% { transform: translateZ(0px) translateY(0px) scale(0.9); }
    50% { transform: translateZ(20px) translateY(-10px) scale(1); filter: drop-shadow(0 0 15px rgba(255,255,255,0.4)); }
    100% { transform: translateZ(0px) translateY(0px) scale(0.9); }
}
