/* NOTAM Explorer Specific Styles */

/* Main Layout - 3 sections: filter (left) | map (right) on top, table full width below */
.explorer-container {
    display: grid;
    grid-template-columns: 350px 1fr; /* Fixed 350px for filters, rest for map */
    grid-template-rows: auto auto 1fr; /* Row 1: filters & map, Row 2: results summary, Row 3: table */
    height: calc(100vh - 80px); /* Account for header height */
    gap: 1rem;
    padding: 1rem;
    background-color: var(--bg-color, #1a1a1a);
}

/* Left Panel - Filter section (top left) */
.left-panel {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: visible; /* No scrollbars */
}

/* Right Panel - Map section (top right) */
.right-panel {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #2a2a2a);
    border-radius: 8px;
    overflow: hidden;
    min-height: 500px; /* Ensure map has good height */
}

/* Filter Panel */
.filter-panel {
    background: var(--card-bg, #2a2a2a);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color, #444);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.filter-panel h3 {
    margin: 0 0 1rem 0;
    color: var(--primary-color, #00d4ff);
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color, #00d4ff);
}

.filter-group {
    margin-bottom: 0.8rem;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    color: var(--text-color, #e0e0e0);
    font-size: 0.85rem;
    font-weight: 500;
}

.filter-group label i {
    color: var(--primary-color, #00d4ff);
    font-size: 0.9rem;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border-color, #444);
    border-radius: 6px;
    background: var(--input-bg, #333);
    color: var(--text-color, #e0e0e0);
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.filter-group input:hover,
.filter-group select:hover {
    border-color: rgba(0, 212, 255, 0.5);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-color, #00d4ff);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

/* Route Filter */
.route-filter .route-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.route-filter input {
    flex: 1;
}

.route-arrow {
    color: var(--primary-color, #00d4ff);
    font-weight: bold;
    font-size: 1rem;
}

/* Checkbox Label */
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    margin: 0;
}

/* Clear Filters Button */
#clear-filters-btn {
    padding: 0.6rem 1rem !important;
    font-size: 0.85rem !important;
    margin-top: 0.8rem;
    width: 100%;
    background: rgba(255, 75, 87, 0.1) !important;
    border: 1px solid #ff4b57 !important;
    color: #ff4b57 !important;
    transition: all 0.2s ease !important;
}

#clear-filters-btn:hover {
    background: rgba(255, 75, 87, 0.2) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255, 75, 87, 0.3) !important;
}

/* Results Summary - spans both columns, positioned above table */
.results-summary {
    grid-column: 1 / 3; /* Span both columns */
    grid-row: 2; /* Second row, before table */
    background: var(--card-bg, #2a2a2a);
    border-radius: 8px;
    padding: 0.6rem;
    border: 1px solid var(--border-color, #444);
    text-align: center;
    align-self: start; /* Don't stretch vertically */
}

.summary-stats {
    color: var(--text-color, #e0e0e0);
    font-size: 0.8rem;
}

#results-count {
    font-weight: bold;
    color: var(--primary-color, #00d4ff);
}

#filter-status {
    color: var(--muted-color, #aaa);
    font-style: italic;
}

.loading-indicator {
    margin-top: 0.3rem;
    color: var(--primary-color, #00d4ff);
    font-size: 0.75rem;
}

.loading-indicator.hidden {
    display: none;
}

/* Table Container - spans full width below filter and map */
.table-container {
    grid-column: 1 / 3; /* Span both columns */
    grid-row: 3; /* Third row */
    min-height: 400px; /* Ensure table shows multiple rows */
    background: var(--card-bg, #2a2a2a);
    border-radius: 8px;
    border: 1px solid var(--border-color, #444);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Table Styles */
#notams-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#notams-table thead {
    background: var(--primary-color, #00d4ff);
    color: var(--bg-color, #1a1a1a);
}

#notams-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Column widths for fixed table layout */
#notams-table th:nth-child(1) { width: 12%; } /* Country */
#notams-table th:nth-child(2) { width: 15%; } /* Type */
#notams-table th:nth-child(3) { width: 10%; } /* Airport */
#notams-table th:nth-child(4) { width: 15%; } /* Start Time */
#notams-table th:nth-child(5) { width: 35%; } /* Description */
#notams-table th:nth-child(6) { width: 13%; } /* Actions */

#notams-table {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto; /* Allow shrinking to make room for pagination */
    min-height: 0; /* Important: allows flex item to shrink below content size */
    overflow: hidden;
    width: 100%;
    font-size: 0.85rem;
}

#notams-table thead {
    flex-shrink: 0;
}

#notams-table tbody {
    flex: 1 1 auto;
    min-height: 0; /* Important: allows flex item to shrink */
    overflow-y: auto;
    display: block;
}

#notams-table thead tr,
#notams-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#notams-table tr {
    border-bottom: 1px solid var(--border-color, #444);
    transition: background-color 0.2s ease;
}

#notams-table tbody tr:hover {
    background-color: var(--hover-bg, rgba(0, 212, 255, 0.1));
    cursor: pointer;
}

#notams-table tbody tr.highlighted {
    background-color: var(--accent-color, rgba(255, 193, 7, 0.2));
}

#notams-table td {
    padding: 0.5rem 0.4rem;
    color: var(--text-color, #e0e0e0);
    vertical-align: top;
    font-size: 0.8rem;
}

/* NOTAM Type Badges */
.notam-type-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.notam-type-badge:hover {
    transform: scale(1.05);
}

.notam-type-badge.runway {
    background-color: #ff4757;
    color: white;
}

.notam-type-badge.obstacle {
    background-color: #ff6b35;
    color: white;
}

.notam-type-badge.airspace {
    background-color: #3742fa;
    color: white;
}

.notam-type-badge.service {
    background-color: #2ed573;
    color: white;
}

.notam-type-badge.lighting {
    background-color: #ffa502;
    color: white;
}

.notam-type-badge.navigation {
    background-color: #5352ed;
    color: white;
}

.notam-type-badge.other {
    background-color: #747d8c;
    color: white;
}

/* Description Cell */
.description-cell {
    max-width: 200px;
}

.description-preview {
    cursor: pointer;
}

.description-full {
    display: none;
}

.description-toggle {
    color: var(--primary-color, #00d4ff);
    cursor: pointer;
    font-weight: bold;
    margin-left: 0.5rem;
}

.description-toggle:hover {
    text-decoration: underline;
}

/* Country Flag */
.country-flag {
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

.country-name {
    cursor: pointer;
    transition: color 0.2s ease;
}

.country-name:hover {
    color: var(--primary-color, #00d4ff);
}

/* Action Buttons */
.action-btn {
    padding: 0.25rem 0.4rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    margin-right: 0.2rem;
}

.action-btn:last-child {
    margin-right: 0;
}

.action-btn.view {
    background-color: var(--primary-color, #00d4ff);
    color: var(--bg-color, #1a1a1a);
}

.action-btn.zoom {
    background-color: var(--success-color, #2ed573);
    color: white;
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.action-btn:disabled {
    background-color: var(--muted-color, #666);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Pagination */
.pagination-container {
    padding: 0.6rem;
    border-top: 1px solid var(--border-color, #444);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg, #2a2a2a);
    flex-shrink: 0;
}

.pagination-info {
    color: var(--muted-color, #aaa);
    font-size: 0.7rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-controls .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

#page-numbers {
    display: flex;
    gap: 0.3rem;
}

.page-number {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color, #444);
    border-radius: 4px;
    background: var(--input-bg, #333);
    color: var(--text-color, #e0e0e0);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.page-number:hover {
    background: var(--hover-bg, rgba(0, 212, 255, 0.1));
    border-color: var(--primary-color, #00d4ff);
}

.page-number.active {
    background: var(--primary-color, #00d4ff);
    color: var(--bg-color, #1a1a1a);
    border-color: var(--primary-color, #00d4ff);
}

/* Map Container */
.map-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color, #444);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg, #2a2a2a);
}

.map-header h3 {
    margin: 0;
    color: var(--primary-color, #00d4ff);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
}

#notam-map-container {
    flex: 1;
    min-height: 450px; /* Bigger map */
}

/* Map Legend (old - hidden, using Leaflet control instead) */
.map-legend {
    display: none;
}

.map-legend h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-color, #e0e0e0);
    font-size: 0.9rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-color, #e0e0e0);
}

.legend-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.legend-marker.runway {
    background-color: #ff4757;
}

.legend-marker.obstacle {
    background-color: #ff6b35;
}

.legend-marker.airspace {
    background-color: #3742fa;
}

.legend-marker.service {
    background-color: #2ed573;
}

.legend-marker.other {
    background-color: #747d8c;
}

/* Map Legend Control (Leaflet overlay) */
.map-legend-control {
    background: rgba(42, 42, 42, 0.95);
    padding: 10px 12px;
    border-radius: 8px;
    border: 2px solid var(--primary-color, #00d4ff);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
}

.map-legend-control .legend-header {
    font-weight: 700;
    color: var(--primary-color, #00d4ff);
    margin-bottom: 8px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-legend-control .legend-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.map-legend-control .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-color, #e0e0e0);
}

.map-legend-control .legend-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    flex-shrink: 0;
}

.map-legend-control .legend-marker.runway {
    background-color: #ff4757;
}

.map-legend-control .legend-marker.obstacle {
    background-color: #ff6b35;
}

.map-legend-control .legend-marker.airspace {
    background-color: #3742fa;
}

.map-legend-control .legend-marker.service {
    background-color: #2ed573;
}

.map-legend-control .legend-marker.other {
    background-color: #747d8c;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    overflow-y: auto;
}

.modal-content {
    background-color: var(--card-bg, #2a2a2a);
    margin: 3% auto;
    padding: 0;
    border-radius: 10px;
    border: 2px solid var(--primary-color, #00d4ff);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 700px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color, #444);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color, #00d4ff), #0099cc);
    color: var(--bg-color, #1a1a1a);
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--bg-color, #1a1a1a);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    color: var(--text-color, #e0e0e0);
}

.modal-footer {
    padding: 0.75rem 1rem;
    border-top: 2px solid var(--border-color, #444);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

/* NOTAM Detail Styles */
.notam-detail-field {
    margin-bottom: 1rem;
}

.notam-detail-field:last-child {
    margin-bottom: 0;
}

.notam-detail-label {
    font-weight: bold;
    color: var(--primary-color, #00d4ff);
    margin-bottom: 0.3rem;
    display: block;
}

.notam-detail-value {
    color: var(--text-color, #e0e0e0);
    line-height: 1.4;
}

.notam-detail-value.description {
    background: var(--input-bg, #333);
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color, #444);
    font-family: monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

/* New Compact Modal Layout */
.notam-modal-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.notam-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.notam-info-row .notam-info-item.full-width {
    grid-column: 1 / -1;
}

.notam-info-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color, #00d4ff);
    transition: all 0.2s ease;
}

.notam-info-item:hover {
    background: rgba(0, 212, 255, 0.15);
    transform: translateX(2px);
}

.notam-info-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.notam-info-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--primary-color, #00d4ff);
    font-weight: 700;
    letter-spacing: 0.8px;
    margin-bottom: 0.2rem;
    opacity: 0.95;
}

.notam-info-value {
    font-size: 0.85rem;
    color: var(--text-color, #e0e0e0);
    font-weight: 500;
    line-height: 1.3;
}

.notam-description-section {
    padding: 0.7rem 0.8rem;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color, #00d4ff);
    transition: all 0.2s ease;
}

.notam-description-section:hover {
    background: rgba(0, 212, 255, 0.15);
}

.notam-description-text {
    color: var(--text-color, #e0e0e0);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    font-size: 0.8rem;
    max-height: none;
    overflow-wrap: break-word;
}

/* Compact Map Popup Styles */
.marker-popup-compact {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 280px;
    max-width: 380px;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid rgba(0, 212, 255, 0.3);
}

.popup-header strong {
    font-size: 0.95rem;
    color: #1a1a1a;
    font-weight: 700;
}

.popup-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.popup-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #444;
    flex-wrap: wrap;
}

.popup-icon {
    font-size: 1rem;
    line-height: 1;
}

.popup-separator {
    color: #999;
    margin: 0 0.2rem;
}

.popup-description {
    font-size: 0.8rem;
    color: #222;
    line-height: 1.45;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    max-height: 150px;
    overflow-y: auto;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}

.popup-view-details {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

.popup-view-details button {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popup-view-details button:hover {
    background: linear-gradient(135deg, #00b8e6, #007acc);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.4);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .explorer-container {
        grid-template-columns: 45% 55%;
    }
}

@media (max-width: 768px) {
    .explorer-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        min-height: calc(100vh - 80px);
    }
    
    .left-panel {
        order: 2;
    }
    
    .right-panel {
        order: 1;
        min-height: 400px;
    }
    
    .modal-content {
        width: 95%;
        margin: 2% auto;
        max-height: 95vh;
    }
    
    .filter-panel {
        padding: 0.75rem;
    }
    
    .route-filter .route-inputs {
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .route-arrow {
        transform: rotate(90deg);
        margin: 0.2rem 0;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* Small Buttons */
.btn-small {
    padding: 0.3rem 0.6rem !important;
    font-size: 0.75rem !important;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.auth-container {
    background: var(--card-bg, #2a2a2a);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color, #444);
    color: var(--text-color, #e0e0e0);
}

.auth-container h2 {
    color: var(--primary-color, #00d4ff);
    margin-bottom: 1rem;
}

/* Custom Scrollbar */
.table-container tbody {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color, #00d4ff) var(--card-bg, #2a2a2a);
}

.table-container tbody::-webkit-scrollbar {
    width: 8px;
}

.table-container tbody::-webkit-scrollbar-track {
    background: var(--card-bg, #2a2a2a);
}

.table-container tbody::-webkit-scrollbar-thumb {
    background-color: var(--primary-color, #00d4ff);
    border-radius: 4px;
}

.table-container tbody::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-hover, #00b8e6);
}
