/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --secondary: #FF9800;
    --success: #4CAF50;
    --danger: #F44336;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --radius: 12px;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Banner Publicitario */
.ad-banner {
    background: linear-gradient(135deg, #702082 0%, #a855f7 100%);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    box-shadow: 0 2px 8px rgba(112, 32, 130, 0.3);
    z-index: 101;
}

.ad-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ad-logo {
    font-size: 1.8rem;
    animation: taco-bounce 1s ease-in-out infinite;
}

@keyframes taco-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.ad-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ad-text strong {
    font-size: 1rem;
    letter-spacing: 1px;
}

.ad-text span {
    font-size: 0.8rem;
    opacity: 0.9;
}

.ad-cta {
    background: #fbbf24;
    color: #702082;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    white-space: nowrap;
}

.ad-cta:hover {
    background: #fcd34d;
    transform: scale(1.05);
}

.ad-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: background 0.2s;
}

.ad-close:hover {
    background: rgba(255,255,255,0.3);
}

/* Responsive del banner */
@media (max-width: 400px) {
    .ad-banner {
        padding: 8px 12px;
    }

    .ad-text span {
        display: none;
    }

    .ad-cta {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* Contenedor principal */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* Header */
.header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 100;
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.floor-selector {
    display: flex;
    gap: 8px;
}

.floor-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.floor-btn:hover {
    background: rgba(255,255,255,0.3);
}

.floor-btn.active {
    background: white;
    color: var(--primary);
}

/* Contenedor del mapa */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#map-canvas:active {
    cursor: grabbing;
}

/* Panel de búsqueda */
.search-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 50;
}

.search-box {
    display: flex;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.search-box input {
    flex: 1;
    border: none;
    padding: 14px 16px;
    font-size: 1rem;
    outline: none;
}

.search-box button {
    background: var(--primary);
    border: none;
    color: white;
    padding: 14px 18px;
    cursor: pointer;
    font-size: 1.1rem;
}

.search-results {
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-top: 8px;
    box-shadow: var(--shadow);
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f0f0f0;
}

.result-category {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.result-info h4 {
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.result-info p {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Panel de información de tienda */
.store-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 60;
    max-height: 60vh;
    overflow-y: auto;
}

.store-panel.active {
    transform: translateY(0);
}

.store-panel-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.store-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.store-details {
    flex: 1;
}

.store-details h2 {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.store-details .category {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.store-details .hours {
    font-size: 0.85rem;
    color: var(--success);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
}

.store-panel-body {
    padding: 20px;
}

.store-description {
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 20px;
}

.store-buttons {
    display: flex;
    gap: 10px;
}

.navigate-btn, .add-route-btn {
    flex: 1;
    background: var(--success);
    color: white;
    border: none;
    padding: 14px 10px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.navigate-btn:hover {
    background: #43A047;
}

.add-route-btn {
    background: var(--primary);
}

.add-route-btn:hover {
    background: var(--primary-dark);
}

/* Waypoints en panel de ruta */
.route-waypoints {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.waypoint-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #e3f2fd;
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.8rem;
}

.waypoint-tag .waypoint-num {
    background: var(--primary);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.waypoint-tag .remove-waypoint {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0 2px;
    font-size: 1rem;
    line-height: 1;
}

.waypoint-tag .remove-waypoint:hover {
    color: var(--danger);
}

/* Panel de navegación/ruta */
.route-panel {
    position: absolute;
    top: 70px;
    right: 12px;
    width: 280px;
    max-width: calc(100% - 24px);
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 70;
    padding: 12px;
    max-height: 50vh;
    overflow-y: auto;
}

.route-panel.active {
    transform: translateX(0);
}

.route-panel.minimized {
    max-height: 60px;
    overflow: hidden;
}

.route-panel.minimized .route-directions,
.route-panel.minimized .cancel-route-btn {
    display: none;
}

.route-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.route-header h3 {
    font-size: 1.1rem;
}

.route-info {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    padding: 12px;
    background: #f0f0f0;
    border-radius: 8px;
}

.route-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.route-info-item .icon {
    font-size: 1.2rem;
}

.route-directions {
    max-height: 200px;
    overflow-y: auto;
}

.direction-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.direction-step:last-child {
    border-bottom: none;
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cancel-route-btn {
    width: 100%;
    background: var(--danger);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    margin-top: 16px;
}

/* Controles de zoom */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 40;
}

.zoom-btn {
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn:hover {
    background: #e0e0e0;
}

/* Botón de centrar */
.center-btn {
    position: absolute;
    bottom: 130px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 40;
}

/* Botón GPS */
.gps-btn {
    position: absolute;
    bottom: 185px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: var(--card-bg);
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 40;
    transition: all 0.3s;
}

.gps-btn:hover {
    background: #e0e0e0;
}

.gps-btn.active {
    background: var(--success);
    color: white;
    animation: pulse 2s infinite;
}

/* Controles de movimiento manual */
.move-controls {
    position: absolute;
    bottom: 20px;
    left: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 100;
    opacity: 0.95;
}

.move-row {
    display: flex;
    gap: 36px;
}

.move-btn {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.move-btn:active {
    transform: scale(0.9);
    background: var(--primary-dark);
}

/* Ocultar leyenda en móvil cuando hay poco espacio */
@media (max-width: 500px) {
    .legend {
        display: none;
    }
}

/* Leyenda de categorías */
.legend {
    position: absolute;
    bottom: 20px;
    left: 12px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
    z-index: 40;
    max-width: 200px;
}

.legend h4 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text-light);
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 12px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Modo kiosco (pantalla completa) */
@media (min-width: 1024px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .floor-btn {
        padding: 10px 24px;
        font-size: 1rem;
    }

    .search-panel {
        max-width: 400px;
    }

    .store-panel {
        max-width: 400px;
        left: auto;
        right: 20px;
        bottom: 20px;
        border-radius: var(--radius);
        max-height: calc(100vh - 100px);
    }

    .route-panel {
        max-width: 400px;
        left: auto;
        right: 20px;
        bottom: 20px;
        border-radius: var(--radius);
    }

    .legend {
        bottom: 20px;
    }
}

/* Botón Vista Inmersiva */
.immersive-btn {
    position: absolute;
    bottom: 240px;
    right: 12px;
    background: linear-gradient(135deg, #9C27B0, #E91E63);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 22px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 40;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.immersive-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.4);
}

/* ============ VISTA INMERSIVA 3D ============ */
.immersive-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: #000;
}

.immersive-container canvas {
    display: block;
}

.immersive-exit-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    z-index: 1001;
    transition: background 0.2s;
}

.immersive-exit-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.immersive-minimap {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 1001;
}

.immersive-minimap canvas {
    border-radius: 5px;
}

.immersive-controls-hint {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    z-index: 1001;
    transition: opacity 0.5s;
}

.immersive-controls-hint p {
    margin: 5px 0;
}

.immersive-store-info {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 1001;
    display: none;
    overflow: hidden;
}

.immersive-store-info.active {
    display: block;
}

.immersive-store-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    color: white;
}

.immersive-store-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.immersive-store-header button {
    background: rgba(255,255,255,0.3);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
}

.immersive-store-body {
    padding: 15px;
}

.immersive-store-body p {
    margin: 8px 0;
    color: #333;
}

/* Controles de movimiento 3D */
.immersive-move-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 1001;
}

.imm-move-row {
    display: flex;
    gap: 50px;
}

.imm-move-btn {
    width: 50px;
    height: 50px;
    background: rgba(33, 150, 243, 0.9);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.imm-move-btn:active {
    transform: scale(0.9);
    background: rgba(25, 118, 210, 1);
}

/* Controles de rotación 3D */
.immersive-look-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 15px;
    z-index: 1001;
}

.imm-look-btn {
    width: 55px;
    height: 55px;
    background: rgba(156, 39, 176, 0.9);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.imm-look-btn:active {
    transform: scale(0.9);
    background: rgba(123, 31, 162, 1);
}

/* Ajustes responsive para 3D */
@media (max-width: 768px) {
    .immersive-controls-hint {
        top: 70px;
        right: 10px;
        left: 10px;
        font-size: 0.8rem;
        padding: 10px 15px;
    }

    .immersive-store-info {
        bottom: auto;
        top: 70px;
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
    }

    .immersive-minimap {
        bottom: 100px;
        left: 50%;
        transform: translateX(-50%);
    }

    .imm-move-btn {
        width: 55px;
        height: 55px;
    }

    .imm-look-btn {
        width: 60px;
        height: 60px;
    }
}

@media (min-width: 769px) {
    .immersive-move-controls,
    .immersive-look-controls {
        opacity: 0.7;
    }

    .immersive-move-controls:hover,
    .immersive-look-controls:hover {
        opacity: 1;
    }
}

/* Animaciones */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}
