/* === MÓDULO DE HISTORIAL === */
#history-section {
    display: none;
    flex: 1;
    padding: 20px;
    gap: 20px;
    height: calc(100vh - 80px);
    overflow: hidden;
    animation: fadeInHistory 0.4s ease;
}

.history-sidebar {
    width: 300px;
    background: var(--card-bg);
    border: 1px solid var(--border-dark);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar-scroll-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.history-sidebar.collapsed {
    width: 0;
    padding: 0;
    border: none;
    margin-right: 0;
}

.history-sidebar.collapsed > *:not(.sidebar-toggle-btn) {
    display: none;
}

.history-results {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-dark);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-toggle-btn {
    position: absolute;
    right: 20px;
    top: 15px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    color: var(--text-bright);
}

.sidebar-toggle-btn svg {
    transition: transform 0.3s ease;
}

.history-sidebar.collapsed .sidebar-toggle-btn {
    right: -30px;
    top: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-dark);
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.history-sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.filter-group input, .filter-group select {
    background: #0f1115;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 10px;
    color: white;
    outline: none;
    font-size: 0.85rem;
}

.sidebar-dropdown-btn {
    background: #0f1115;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 10px;
    color: white;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    align-items: center;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-dropdown-btn:hover {
    border-color: var(--info);
}

/* Estilo para el icono del calendario */
.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.filter-group input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.btn-back-live {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.btn-back-live:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #3b82f6;
    color: white;
    transform: translateX(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-back-live span {
    font-size: 1.1rem;
    line-height: 1;
}

.btn-clear-filters {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-clear-filters:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.btn-history-search {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    text-transform: uppercase;
}

.btn-history-search:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.history-table-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-table-header h3 {
    font-size: 0.9rem;
    color: var(--accent-tech);
    margin: 0;
    font-weight: 700;
}

@keyframes fadeInHistory {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Radio Buttons - Filtro Estado */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 12px;
    background: #0f1115;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.radio-option:hover {
    border-color: #475569;
    background: rgba(255, 255, 255, 0.03);
}

.radio-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 2px solid #475569;
    border-radius: 50%;
    margin: 0;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    flex-shrink: 0;
}

.radio-option input[type="radio"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3b82f6;
    transition: transform 0.2s ease;
}

.radio-option input[type="radio"]:checked {
    border-color: #3b82f6;
}

.radio-option input[type="radio"]:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

.radio-option:has(input:checked) {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.08);
}

.radio-label {
    font-size: 0.73rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.3px;
    transition: color 0.25s ease;
    text-transform: uppercase;
}

.radio-option:has(input:checked) .radio-label {
    color: #e2e8f0;
}

/* =====================================================
   FILTRO OACI - Popup multi-columna (Historial)
   ===================================================== */

/* Overlay */
#hist-oaci-overlay, #stats-oaci-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}
#hist-oaci-overlay.open, #stats-oaci-overlay.open {
    display: flex;
}

/* Popup container */
#hist-oaci-popup, #stats-oaci-popup {
    background: var(--card-bg);
    border: 1px solid var(--border-dark);
    border-radius: 14px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.85);
    width: 850px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: oaciPopupIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes oaciPopupIn {
    from { opacity: 0; transform: scale(0.94) translateY(-10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* Header */
#hist-oaci-popup-header, #stats-oaci-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
    gap: 12px;
}
#hist-oaci-popup-header h3, #stats-oaci-popup-header h3 {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-tech);
    white-space: nowrap;
}
.popup-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.btn-oaci-popup {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-dark);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.63rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-oaci-popup:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: var(--info);
    color: #7dd3fc;
}
.btn-oaci-popup.apply {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--info);
    color: #7dd3fc;
}
.btn-oaci-popup.apply:hover {
    background: var(--info);
    color: #fff;
}

/* Buscador interno */
#hist-oaci-search-bar, #stats-oaci-search-bar {
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.12);
    border-bottom: 1px solid var(--border-dark);
    flex-shrink: 0;
}
#hist-oaci-search-input, #stats-oaci-search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-dark);
    border-radius: 7px;
    padding: 7px 14px;
    color: var(--text-bright);
    font-size: 0.8rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}
#hist-oaci-search-input::placeholder, #stats-oaci-search-input::placeholder { color: #475569; }
#hist-oaci-search-input:focus, #stats-oaci-search-input:focus { border-color: var(--info); }

/* Grid de chips */
#hist-oaci-grid-container, #stats-oaci-grid-container {
    overflow-y: auto;
    padding: 14px 16px;
    flex: 1;
}
#hist-oaci-grid, #stats-oaci-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
}
.oaci-chip {
    padding: 6px 4px;
    border-radius: 5px;
    font-size: 0.62rem;
    font-weight: 800;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border-dark);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.15s;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}
.oaci-chip.official-chip {
    border-color: rgba(255, 255, 255, 0.4);
    color: #e2e8f0;
}
.oaci-chip:hover, .oaci-chip.official-chip:hover {
    border-color: rgba(59, 130, 246, 0.5);
    color: #7dd3fc;
    background: rgba(59, 130, 246, 0.1);
}
.oaci-chip.selected, .oaci-chip.official-chip.selected {
    background: rgba(59, 130, 246, 0.22);
    border-color: var(--info);
    color: #7dd3fc;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

/* Footer */
#hist-oaci-popup-footer, #stats-oaci-popup-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.1);
    gap: 10px;
}
#hist-oaci-selection-count, #stats-oaci-selection-count {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}
.hist-oaci-footer-btns {
    display: flex;
    gap: 6px;
}

/* Badge en la cabecera de la columna */
#hist-loc-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    color: #e2e8f0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
#hist-loc-badge:hover {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(59, 130, 246, 0.5);
}
#hist-loc-badge.active {
    background: rgba(59, 130, 246, 0.28);
    border-color: var(--info);
    color: #7dd3fc;
}
#hist-loc-badge-count {
    background: var(--info);
    color: #fff;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 0.58rem;
    font-weight: 800;
    display: none;
    line-height: 1.4;
}
#hist-loc-badge.active #hist-loc-badge-count {
    display: inline;
}


#hist-notam-id, #hist-query {
    text-transform: uppercase;
}
