/* ========== Base Layout ========== */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: system-ui, sans-serif;
    background-color: #000;
    color: #fff;
}

/* ========== Map ========== */
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 999;
    pointer-events: auto;
}

#search-overlay {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    max-width: 90%;
    width: 500px;
}

/* ========== Marcadores del Mapa ========== */
/* Marcador individual básico */
.marker-individual {
    position: absolute;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.marker-individual img {
    width: 40px;
    height: 40px;
    display: block;
    transition: transform 0.2s ease;
}

.marker-individual:hover {
    filter: drop-shadow(0 2px 6px rgba(255, 255, 255, 0.3));
}

.marker-individual:hover img {
    transform: scale(1.05);
}

/* Marcador consolidado con badge */
.marker-consolidado {
    position: absolute;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.marker-consolidado .marker-pin {
    width: 40px;
    height: 40px;
    display: block;
    transition: transform 0.2s ease;
}

.marker-consolidado .marker-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
    user-select: none;
    pointer-events: none;
    transition: transform 0.2s ease;
    line-height: 1;
}

/* Colores de badges según cantidad */
.marker-badge.badge-single {
    background-color: #6c757d;
    color: #fff;
}

.marker-badge.badge-few {
    background-color: #ffcc05;
    color: #000;
}

.marker-badge.badge-many {
    background-color: #ff6b35;
    color: #fff;
}

.marker-badge.badge-lots {
    background-color: #e74c3c;
    color: #fff;
    animation: pulse-badge 1.5s infinite;
}

/* Efectos hover para consolidados */
.marker-consolidado:hover {
    filter: drop-shadow(0 4px 8px rgba(255, 204, 5, 0.4));
}

.marker-consolidado:hover .marker-pin {
    transform: scale(1.1);
}

.marker-consolidado:hover .marker-badge {
    transform: scale(1.1);
}

/* Marcador hotspot (lugares muy populares) */
.marker-hotspot {
    position: absolute;
    width: 45px;
    height: 45px;
    cursor: pointer;
    border-radius: 50%;
    animation: pulse-marker 2s infinite;
    transition: filter 0.2s ease;
}

.marker-hotspot .hotspot-pin {
    width: 45px;
    height: 45px;
    display: block;
    transition: transform 0.2s ease;
}

.marker-hotspot .hotspot-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 900;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #e74c3c;
    color: #fff;
    border: 3px solid #fff;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    z-index: 10;
    user-select: none;
    pointer-events: none;
    animation: pulse-hotspot 1.5s infinite;
    transition: transform 0.2s ease;
    line-height: 1;
}

.marker-hotspot:hover {
    filter: drop-shadow(0 6px 12px rgba(231, 76, 60, 0.5));
}

.marker-hotspot:hover .hotspot-pin {
    transform: scale(1.1);
}

.marker-hotspot:hover .hotspot-badge {
    transform: scale(1.1);
}

/* Animaciones para marcadores */
@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes pulse-marker {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

@keyframes pulse-hotspot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ========== FAB Menu Button ========== */
.menu-icon {
    display: inline-block;
    transition: transform 0.4s ease;
}

.offcanvas.show .menu-icon svg {
    transform: rotate(-90deg);
    transition: transform 0.3s ease;
}

.rotate-left svg {
    animation: spin-left 1s linear infinite;
}

@keyframes spin-left {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

#main-fab-menu button {
    border-radius: 12px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    color: #222;
    font-weight: bold;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.menu-icon svg {
    width: 20px;
    height: 20px;
}

/* ========== Offcanvas Fullscreen ========== */
.offcanvas-custom {
    width: 100vw !important;
    max-width: 100vw;
    height: 100vh !important;
    border-right: none;
    background-color: #111;
    color: white;
    padding: 1.5rem;
    overflow-y: auto;
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.3, 0.8, 0.3, 1), opacity 0.4s ease-out;
    will-change: transform;
}

.offcanvas-fullscreen.show {
    transform: translateX(0%);
    opacity: 1;
    pointer-events: auto;
}

.offcanvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #444;
}

.offcanvas-body {
    padding-top: 1rem;
}

/* ========== Categoria y Comuna Buttons ========== */
#category-buttons,
#comuna-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

#category-buttons .btn,
#comuna-buttons .btn {
    border: 2px solid #ffcc05;
    background-color: #333;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 999px;
    transition: all 0.2s ease;
    cursor: pointer;
}

#category-buttons .btn:hover,
#comuna-buttons .btn:hover {
    background-color: #ffcc05;
    color: #000;
}

#category-buttons .btn.active,
#comuna-buttons .btn.active {
    background: #ffcc05;
    color: #000;
    font-weight: bold;
    border: 2px solid #333;
}

/* ========== Modal Fullscreen ========== */
.fullscreen .modal-dialog {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    margin: 0;
}

.modal.fullscreen .modal-content {
    height: 100%;
    border-radius: 0;
    background-color: #111;
    color: #fff;
    border: none;
    box-shadow: none;
    overflow-y: auto;
    padding: 2rem;
}

.modal-header {
    border-bottom: 1px solid #333;
    padding-bottom: 1rem;
}

.modal-header .btn-close {
    filter: invert(1);
}

.modal-body {
    font-size: 1.1rem;
}

.modal-footer {
    border-top: 1px solid #333;
    padding-top: 1rem;
}

.modal-body input.form-control,
.modal-body select.form-select {
    background-color: #222;
    color: white;
    border: 1px solid #444;
}

.modal-body input.form-control::placeholder {
    color: #aaa;
}

.modal-body input.form-control:focus,
.modal-body select.form-select:focus {
    background-color: #333;
    border-color: #ffcc05;
    color: white;
    box-shadow: 0 0 5px #ffcc05;
}

.modal-footer button.btn-success {
    background-color: #ffcc05;
    color: #111;
    font-weight: bold;
    border: none;
}

.modal-footer button.btn-success:hover {
    background-color: #e6b800;
}

/* ========== Modal Info Específico ========== */
.fullscreen .modal-dialog {
    width: 100vw;
    height: 100vh;
    margin: 0;
    max-width: none;
}

#modal-titulo {
    font-optical-sizing: auto;
    font-size: 3rem;
    font-style: normal;
    font-weight: 400;
    line-height: 3rem;
    padding: 1.3rem;
}

.modal-title-custom {
    font-family: "Roboto Slab", serif;
    font-weight: 600;
    font-size: 1.5rem;
}

.info-modal-header {
    background-color: #ffcb05;
    color: black;
    border-radius: 2rem;
}

.info-modal-content {
    height: 100%;
    max-height: 100vh;
    overflow-y: auto;
    border-radius: 0;
    background-color: #000;
    color: black;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    padding: 2rem;
    gap: 2rem;
    font-family: "DM Sans", sans-serif;
}

/* ========== Body Grid del Modal Info ========== */
.info-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.info-box {
    flex: 1;
    padding: 2rem 1rem;
    min-height: 150px;
    color: #fff;
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1.5rem;
}

.categoria-box {
    flex: 1;
    background-color: #44444E;
}

.direccion-box {
    flex: 2;
    background-color: #F7F7F7;
}

.rating-stars-container {
    flex: 1;
    flex-direction: column;
    background-color: #00FFAB;
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.rating-text {
    flex: 2;
    font-weight: bold;
    font-size: 1.1rem;
    background-color: #FF6363;
}

.rating-promedio {
    font-size: 3rem;
    font-weight: bold;
    color: white;
}

.rating-votos {
    font-size: 1rem;
    color: white;
    margin-left: 0.5rem;
}

.rating-stars {
    display: flex;
    gap: 1rem;
}

.star {
    font-size: 2rem;
    color: #000;
    cursor: pointer;
    user-select: none;
    transition: color 0.3s ease;
}

.star.hovered,
.star.selected {
    color: gold;
}

.star.highlight {
    color: red;
    animation: pop 0.3s ease;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

/* Span Styling */
#modal-categoria {
    color: white;
    font-weight: bold;
    font-size: 1em;
}

#modal-direccion {
    color: black;
    font-weight: bold;
    font-size: 1em;
}

/* Scanner Section */
.scanner-section {
    margin-top: 2rem;
}

.scanner-title {
    font-family: "DM Sans", sans-serif;
    font-size: 1.3rem;
    font-weight: bold;
    color: white;
    margin-bottom: 0.5rem;
    text-align: center;
}

.form-floating {
    margin-top: 1rem;
}

.form-control {
    background-color: #ecf0f1;
    border: none;
    border-radius: 1rem;
    padding: 1.5rem;
    font-size: 1rem;
    color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    resize: none;
    min-height: 120px;
}

.form-floating label {
    color: #7f8c8d;
    font-weight: 500;
    padding-left: 1rem;
}

.form-control:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(47, 164, 255, 0.25);
    border: 1px solid #2FA4FF;
}

.info-modal-footer {
    border-top: 1px solid #333;
    padding-top: 1rem;
    justify-content: center;
}

/* ========== Toast ========== */
#successToast {
    background-color: #333 !important;
    color: #ffcc05 !important;
    border: none !important;
}

#successToast .toast-body {
    color: #ffcc05 !important;
}

#successToast .btn-close {
    filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(90deg) brightness(90%) contrast(90%);
}

/* ========== Popup Mapbox ========== */
.mapboxgl-popup-content {
    background-color: #333 !important;
    color: white !important;
    border-radius: 12px;
    padding: 12px;
    max-width: 240px;
    font-family: system-ui, sans-serif;
}

.mapboxgl-popup-content h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: bold;
}

.mapboxgl-popup-content p {
    margin: 4px 0 8px;
    font-size: 0.95rem;
}

.mapboxgl-popup-tip {
    border-top-color: #111 !important;
}

/* ========== Búsqueda ========== */
#searchToggleButton {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background-color: #fff;
    border: none;
    z-index: 2100;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

#searchOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 2050;
}

#searchOverlay.active {
    opacity: 1;
    pointer-events: auto;
}

#searchTextarea {
    width: 100%;
    max-width: 600px;
    height: 120px;
    font-size: 1.2rem;
    resize: none;
    background: rgba(255, 255, 255, 0);
    box-shadow: 0 0 8px rgba(0, 0, 0, 0);
    border-color: rgba(255, 255, 255, 0);
    outline: none;
}

.btn-search {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #000;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    cursor: pointer;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .info-modal-body {
        grid-template-columns: 1fr;
    }

    .info-row {
        flex-direction: column;
    }

    .marker-hotspot {
        width: 40px;
        height: 40px;
    }

    .marker-hotspot .hotspot-pin {
        width: 40px;
        height: 40px;
    }
}