#map {
    height: calc(100vh - 180px);
    /* Ajustado para considerar ambos headers */
    width: 100%;
    z-index: 1;
    margin-top: 0;
    position: relative;
    /* Importante: hace que el posicionamiento absoluto de los controles sea relativo a este elemento */
}

#map-controls {
    position: absolute;
    top: 10px;
    /* Posicionado con respecto al contenedor del mapa */
    right: 10px;
    z-index: 999;
    /* Por encima del mapa pero por debajo del panel de detalles */
    background: transparent;
}

.map-style-selector {
    position: relative;
    display: inline-block;
}

.btn-map-control {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-map-control:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

.btn-map-control i {
    font-size: 18px;
    color: #333;
}

.map-style-options {
    display: none;
    position: absolute;
    right: 0;
    top: 45px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    width: 180px;
    z-index: 1002;
}

.map-style-options.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.map-option {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s ease;
}

.map-option:not(:last-child) {
    border-bottom: 1px solid #f0f0f0;
}

.map-option:hover {
    background-color: #f8f9fa;
}

.map-option i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
    color: #0d6efd;
}

#flight-details-panel {
    position: fixed;
    top: 130px;
    /* Ajustado para considerar ambos headers */
    right: -400px;
    width: 380px;
    height: calc(100vh - 180px);
    /* Ajustado para considerar ambos headers */
    background-color: white;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
    transition: right 0.3s ease-in-out;
}

#flight-details-panel.show {
    right: 0;
}

.close-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 18px;
}

.detail-row {
    display: flex;
    border-bottom: 1px solid #f0f0f0;
    padding: 8px 0;
}

.detail-label {
    font-weight: bold;
    width: 40%;
}

.detail-value {
    width: 60%;
}

.flight-title {
    border-bottom: 2px solid #0d6efd;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.info-section {
    margin-bottom: 20px;
}

.refresh-info {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px;
    border-radius: 5px;
    font-size: 14px;
    z-index: 999;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.aircraft-marker {
    background: none !important;
    border: none !important;
    transition:
        transform 0.5s ease-out,
        left 0.5s linear,
        top 0.5s linear;
    will-change: transform, left, top;
}

.aircraft-icon {
    transform-origin: center center;
    /* Asegura que la rotación sea desde el centro */
    transition: transform 0.1s linear;
    /* Suaviza la rotación */
    color: #0d6efd;
    font-size: 20px;
    display: inline-block;
    /* Asegura que la transformación se aplique correctamente */
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

.radar-header {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 990;
    /* El nav principal ya es sticky-top, este header debe fluir normalmente debajo de él */
}

.stats-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-card {
    background-color: white;
    padding: 8px 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 120px;
    text-align: center;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #0d6efd;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
}

.search-container {
    position: relative;
    /* Asegura que los elementos hijos se posicionen en relación a este contenedor */
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-container input {
    width: 250px;
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    /* Ocultar el borde cuando está vacío */
    border: none;
    display: none;
    /* Por defecto estará oculto */
}

/* Mostrar el borde solo cuando tenga contenido */
.search-results:not(:empty) {
    border: 1px solid #ddd;
    display: block;
}

.search-results div {
    padding: 10px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.search-results div:hover {
    background: #f8f9fa;
}

/* Alert personalizado para móviles */
.mobile-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.mobile-warning-container {
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease-out;
}

.mobile-warning-title {
    color: #d9534f;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-warning-content {
    margin-bottom: 20px;
    line-height: 1.5;
}

.mobile-warning-button {
    background-color: #0d6efd;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 10px 15px;
    width: 100%;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mobile-warning-button:hover {
    background-color: #0b5ed7;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Media queries para móviles */
@media (max-width: 768px) {
    #map {
        height: calc(100vh - 220px);
        /* Más espacio para el mapa */
    }

    .radar-header {
        padding: 8px 10px;
    }

    .stats-container {
        gap: 8px;
        justify-content: space-between;
        margin-bottom: 10px;
    }

    .stat-card {
        min-width: 80px;
        padding: 6px 8px;
    }

    .stat-value {
        font-size: 1rem;
    }

    .search-container {
        width: 100%;
    }

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

    /* Panel de detalles para móviles */
    #flight-details-panel {
        top: auto;
        bottom: -70vh;
        left: 0;
        right: 0;
        width: 100%;
        height: 70vh;
        border-radius: 10px 10px 0 0;
        box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.2);
        transition: bottom 0.3s ease-in-out;
    }

    #flight-details-panel.show {
        bottom: 0;
        right: auto;
    }

    /* Cabecera deslizable del panel */
    .panel-header {
        padding: 10px;
        cursor: pointer;
        text-align: center;
        border-bottom: 1px solid #eee;
        position: relative;
    }

    .panel-header:after {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 8px auto 0;
    }

    /* Contenido desplazable */
    #flight-details-content {
        height: calc(100% - 50px);
        overflow-y: auto;
        padding-bottom: 20px;
    }

    /* Botón de cerrar ajustado para móviles */
    .close-panel {
        top: 5px;
        right: 5px;
        background: rgba(255, 255, 255, 0.8);
        border-radius: 50%;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Ajustes para los controles del mapa en móviles */
    #map-controls {
        top: auto;
        bottom: 20px;
        right: 10px;
    }

    .refresh-info {
        bottom: 80px;
        left: 10px;
        font-size: 12px;
        padding: 8px;
    }
}

/* Para pantallas muy pequeñas */
@media (max-width: 480px) {
    .stat-card {
        min-width: 70px;
        padding: 4px 6px;
    }

    .stat-value {
        font-size: 0.9rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    #flight-details-panel {
        height: 65vh;
        bottom: -65vh;
    }
}