/* Copyright (c) 2025. Jericho Crosby (Chalwk) */

.flights-section {
    padding: 40px 0;
    background-color: #f8fafc;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: #1a365d;
}

.section-subtitle {
    text-align: center;
    color: #6b7280;
    font-size: 1.1rem;
    margin-bottom: 40px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.flights-controls {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.controls-left {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    min-width: 300px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

.search-box input {
    width: 100%;
    padding: 12px 20px 12px 45px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #2d6bc9;
    box-shadow: 0 0 0 3px rgba(45, 107, 201, 0.1);
}

.filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-select {
    padding: 10px 15px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 150px;
}

.filter-select:focus {
    outline: none;
    border-color: #2d6bc9;
}

.stats-summary {
    display: flex;
    gap: 25px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4b5563;
    font-size: 0.9rem;
}

.stat-item i {
    color: #2d6bc9;
}

.flights-container {
    display: flex;
    gap: 30px;
    position: relative;
}

.flights-table-container {
    flex: 1;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.flights-table {
    width: 100%;
    border-collapse: collapse;
}

.flights-table thead {
    background-color: #1a365d;
    color: white;
}

.flights-table th {
    padding: 18px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    position: relative;
    white-space: nowrap;
}

.flights-table th:nth-child(1) { width: 8%; }
.flights-table th:nth-child(2) { width: 8%; }
.flights-table th:nth-child(3) { width: 7%; }
.flights-table th:nth-child(4) { width: 7%; }
.flights-table th:nth-child(5) { width: 12%; }
.flights-table th:nth-child(6) { width: 10%; }
.flights-table th:nth-child(7) { width: 18%; }
.flights-table th:nth-child(8) { width: 8%; }
.flights-table th:nth-child(9) { width: 8%; }
.flights-table th:nth-child(10) { width: 6%; }

.flights-table th:hover {
    background-color: #2d6bc9;
}

.flights-table th {
    position: relative;
    padding-right: 30px;
}

.flights-table th::after {
    content: '↕';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    font-size: 0.8rem;
    line-height: 1;
    pointer-events: none;
}

.flights-table th.sorted-asc::after {
    content: '↑';
    opacity: 1;
}

.flights-table th.sorted-desc::after {
    content: '↓';
    opacity: 1;
}

.flights-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
}

.flights-table tbody tr:hover {
    background-color: #f8fafc;
}

.flights-table tbody tr.mission-row {
    background-color: rgba(45, 107, 201, 0.03);
    border-left: 4px solid #2d6bc9;
}

.flights-table tbody tr.mission-row:hover {
    background-color: rgba(45, 107, 201, 0.08);
}

.flights-table tbody tr.mission-sar {
    border-left-color: #dc2626;
    background-color: rgba(220, 38, 38, 0.03);
}

.flights-table tbody tr.mission-medevac {
    border-left-color: #dc2626;
    background-color: rgba(220, 38, 38, 0.03);
}

.flights-table tbody tr.mission-patient {
    border-left-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.03);
}

.flights-table tbody tr.mission-fire {
    border-left-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.03);
}

.flights-table tbody tr.mission-tour {
    border-left-color: #059669;
    background-color: rgba(5, 150, 105, 0.03);
}

.flights-table tbody tr.mission-training {
    border-left-color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.03);
}

.flights-table tbody tr.mission-survey {
    border-left-color: #8b5cf6;
    background-color: rgba(139, 92, 246, 0.03);
}

.flights-table tbody tr.mission-police {
    border-left-color: #3730a3;
    background-color: rgba(55, 48, 163, 0.03);
}

.flights-table tbody tr.mission-vip {
    border-left-color: #7c3aed;
    background-color: rgba(124, 58, 237, 0.03);
}

.flights-table tbody tr.mission-test {
    border-left-color: #6b7280;
    background-color: rgba(107, 114, 128, 0.03);
}

.flights-table td {
    padding: 16px 15px;
    color: #374151;
    font-size: 0.9rem;
    vertical-align: middle;
}

.time-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.time-display {
    font-weight: 500;
    color: #374151;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
}

.time-label {
    color: #6b7280;
    font-size: 0.8rem;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.time-info .time-display:empty::after {
    content: 'N/A';
    color: #9ca3af;
    font-style: italic;
}

.flight-number {
    font-weight: 600;
    color: #1a365d;
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mission-badge {
    display: inline-block;
    background: linear-gradient(135deg, #2d6bc9, #1a365d);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mission-sar .mission-badge {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.mission-medevac .mission-badge {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.mission-patient .mission-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.mission-tour .mission-badge {
    background: linear-gradient(135deg, #059669, #047857);
}

.mission-training .mission-badge {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.pilot-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pilot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d6bc9, #1a365d);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
}

.aircraft-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.aircraft-reg {
    font-weight: 600;
    color: #1a365d;
}

.aircraft-type {
    font-size: 0.8rem;
    color: #6b7280;
}

.route-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.route-airports {
    display: flex;
    align-items: center;
    gap: 5px;
}

.airport-code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    padding: 2px 8px;
    background: #f3f4f6;
    border-radius: 4px;
    color: #1a365d;
}

.route-arrow {
    color: #9ca3af;
}

.route-details {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.3;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-completed {
    background-color: #d1fae5;
    color: #065f46;
}

.status-in-progress {
    background-color: #fef3c7;
    color: #92400e;
}

.status-scheduled {
    background-color: #e0e7ff;
    color: #3730a3;
}

.status-cancelled {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-diverted {
    background-color: #ede9fe;
    color: #5b21b6;
}

.table-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: #f3f4f6;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #2d6bc9;
    color: white;
}

.flight-details-sidebar {
    width: 400px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    color: #1a365d;
}

.close-sidebar {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 4px;
    transition: color 0.2s;
}

.close-sidebar:hover {
    color: #dc2626;
}

.sidebar-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.detail-section {
    margin-bottom: 25px;
}

.detail-section h4 {
    color: #1a365d;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.detail-section h4 i {
    color: #2d6bc9;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.8rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-weight: 500;
    color: #1a365d;
    font-size: 0.95rem;
}

.detail-item .detail-value .utc-time {
    font-family: 'Courier New', monospace;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.mission-type {
    background: linear-gradient(135deg, #2d6bc9, #1a365d);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-block;
}

.mission-type-sar {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.mission-type-medevac {
    background: linear-gradient(135deg, #dc2626, #991b1b);
}

.mission-type-patient {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.mission-type-tour {
    background: linear-gradient(135deg, #059669, #047857);
}

.mission-type-training {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 40px 0;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pagination-btn {
    padding: 10px 20px;
    background: #2d6bc9;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #1a365d;
}

.pagination-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 8px;
}

.page-number {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: #4b5563;
    transition: all 0.2s;
}

.page-number:hover {
    background: #f3f4f6;
}

.page-number.active {
    background: #2d6bc9;
    color: white;
}

.flights-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.summary-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.summary-card h4 {
    color: #1a365d;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a365d;
}

.stat-label {
    font-size: 0.85rem;
    color: #6b7280;
}

.top-pilots {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pilot-rank {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    transition: transform 0.2s;
}

.pilot-rank:hover {
    transform: translateX(5px);
    background: #f0f9ff;
}

.rank-number {
    width: 30px;
    height: 30px;
    background: #2d6bc9;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.pilot-rank-info {
    flex: 1;
}

.pilot-rank-name {
    font-weight: 600;
    color: #1a365d;
    margin-bottom: 4px;
}

.pilot-rank-flights {
    font-size: 0.85rem;
    color: #6b7280;
}

.popular-routes {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.popular-route {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
    transition: transform 0.2s;
}

.popular-route:hover {
    transform: translateX(5px);
    background: #f0f9ff;
}

.route-frequency {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 0.85rem;
}

.route-frequency i {
    color: #2d6bc9;
}

.data-refresh {
    margin-top: 40px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.data-refresh p {
    color: #6b7280;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

#lastUpdated {
    font-weight: 600;
    color: #1a365d;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.refresh-notification,
.error-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.refresh-notification {
    background: #059669;
    color: white;
}

.error-notification {
    background: #dc2626;
    color: white;
}

@media (max-width: 1200px) {
    .flights-container {
        flex-direction: column;
    }

    .flight-details-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
}

@media (max-width: 992px) {
    .flights-table {
        display: block;
        overflow-x: auto;
    }

    .flights-table th,
    .flights-table td {
        white-space: nowrap;
    }

    .flights-table th:nth-child(1),
    .flights-table th:nth-child(2),
    .flights-table th:nth-child(3),
    .flights-table th:nth-child(4),
    .flights-table th:nth-child(8),
    .flights-table th:nth-child(9),
    .flights-table th:nth-child(10) {
        min-width: 80px;
    }

    .flights-table th:nth-child(5) {
        min-width: 120px;
    }

    .flights-table th:nth-child(6) {
        min-width: 100px;
    }

    .flights-table th:nth-child(7) {
        min-width: 180px;
    }
}

@media (max-width: 768px) {
    .flights-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-left {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: auto;
    }

    .filter-group {
        flex-direction: column;
        width: 100%;
    }

    .filter-select {
        width: 100%;
    }

    .summary-stats {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .time-info {
        align-items: flex-start;
    }

    .time-display {
        font-size: 0.9rem;
    }

    .time-label {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .flights-table-container {
        margin: 0 -15px;
        border-radius: 0;
    }

    .flights-table {
        font-size: 0.85rem;
    }

    .flights-table td {
        padding: 12px 10px;
    }

    .pilot-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .airport-code {
        font-size: 0.8rem;
        padding: 2px 6px;
    }

    .time-display {
        font-size: 0.85rem;
    }
}