/**
 * Flight Table Styles
 * Matches component specifications and prototype
 */

/* Table Container */
.flight-table-container {
    margin: 16px 0;
    max-width: 1200px; /* Wider table for more columns */
}

/* Base Table Styles */
.flight-table {
    width: 100%;
    table-layout: fixed; /* Fixed layout for consistent column widths */
    border-collapse: collapse;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.875rem;
}

/* Table Header */
.flight-table thead {
    background: rgba(51, 65, 85, 0.6);
}

.flight-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #f1f5f9;
    border-bottom: 2px solid #475569;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Sortable Headers */
.flight-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 150ms ease;
}

.flight-table th.sortable:hover {
    background: rgba(71, 85, 105, 0.4);
}

.flight-table th.sortable:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: -2px;
}

.flight-table th.sortable.active {
    font-weight: 700;
    color: #60a5fa;
}

.sort-icon {
    margin-left: 4px;
    font-size: 0.75rem;
    color: #94a3b8;
    transition: color 150ms;
}

.flight-table th.active .sort-icon {
    color: #60a5fa;
}

/* Table Body */
.flight-table tbody tr {
    transition: background-color 150ms ease, transform 150ms ease;
}

.flight-table tbody tr:hover {
    background: rgba(51, 65, 85, 0.3);
    cursor: pointer;
}

.flight-table td {
    padding: 6px 12px;
    border-bottom: 1px solid rgba(71, 85, 105, 0.3);
    color: #cbd5e1;
    vertical-align: top;
}

.flight-table tbody tr:last-child td {
    border-bottom: none;
}

/* Date Cell (for multi-date searches) */
.date-cell {
    min-width: 90px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #cbd5e1;
    white-space: nowrap;
}

/* Miles Cell */
.miles-cell {
    min-width: 120px;
    white-space: nowrap;
}

.miles-primary {
    font-size: 1.25rem;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.taxes-cell {
    font-size: 1rem;
    color: #94a3b8;
    text-align: right;
    padding-right: 16px;
}

/* Value Badges */
.value-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
    white-space: nowrap;
    cursor: help;
    position: relative;
}

.value-badge.excellent {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.value-badge.good {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.value-badge.poor {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Tooltip for value badges */
.value-badge[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: normal;
    width: 200px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid #475569;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
    line-height: 1.4;
}

.value-badge[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
    z-index: 100;
}

/* Program Cell with Logo */
.program-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.program-logo,
.airline-logo {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: rgba(100, 116, 139, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    color: #94a3b8;
    flex-shrink: 0;
}

.program-name,
.airline-name {
    color: #cbd5e1;
}

/* Booking Links */
.booking-link {
    color: #60a5fa;
    text-decoration: none;
    cursor: pointer;
    transition: all 200ms ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.booking-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.booking-link:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
    border-radius: 2px;
}

.external-link-icon {
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 200ms ease;
}

.booking-link:hover .external-link-icon {
    opacity: 1;
}

/* Cabin/Class Cell */
.cabin-cell {
    color: #cbd5e1;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Route Cell */
.route-cell {
    line-height: 1.5;
}

.route-airports {
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 4px;
}

.route-times {
    color: #cbd5e1;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.next-day {
    font-size: 0.75rem;
    color: #f59e0b;
    margin-left: 4px;
    font-weight: 600;
}

.route-stops {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* Stops Column Styles (NEW - dedicated column) */
.stops-cell {
    text-align: center;
    font-size: 0.875rem;
    color: #cbd5e1;
    min-width: 60px;
}

.direct-badge {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.expand-btn {
    margin-top: 8px;
    background: none;
    border: none;
    color: #60a5fa;
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 4px 0;
    transition: color 150ms, transform 150ms;
    font-family: inherit;
}

.expand-btn:hover {
    color: #93c5fd;
    transform: translateX(2px);
}

.expand-btn:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
    border-radius: 2px;
}

.expand-btn[aria-expanded="true"] {
    transform: rotate(180deg);
}

/* Duration Cell */
.duration-cell {
    text-align: left;
    white-space: nowrap;
}

/* Cash Table Specific Styles */
.cash-table th,
.cash-table td {
    padding: 10px 12px;
}

.cash-table .cash-fare {
    font-weight: 700;
    color: #34d399;
    font-size: 0.9375rem;
}

/* Table Metadata */
.table-metadata {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 12px;
    line-height: 1.6;
    padding: 0 4px;
}

.table-metadata strong {
    color: #cbd5e1;
}

/* Empty State */
.flight-table-empty {
    text-align: center;
    padding: 48px 24px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-message {
    font-size: 1.125rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-bottom: 8px;
}

.empty-suggestion {
    font-size: 0.875rem;
    color: #94a3b8;
}

/* Loading Skeleton */
.skeleton-row td {
    padding: 16px;
}

.skeleton-bar {
    height: 16px;
    background: linear-gradient(90deg, 
        rgba(71, 85, 105, 0.4) 0%, 
        rgba(100, 116, 139, 0.6) 50%, 
        rgba(71, 85, 105, 0.4) 100%
    );
    background-size: 200% 100%;
    border-radius: 4px;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .flight-table {
        font-size: 0.8125rem;
    }

    .miles-primary {
        font-size: 1.125rem;
    }
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

/* Tablet breakpoint - slightly reduce padding and hide less important columns */
@media (max-width: 1024px) {
    .flight-table-container {
        max-width: 100%;
    }
    
    .flight-table th,
    .flight-table td {
        padding: 10px 12px;
    }
    
    .miles-primary {
        font-size: 1.1rem;
    }
}

/* Mobile breakpoint - horizontal scroll with touch support */
@media (max-width: 768px) {
    .flight-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 12px -8px; /* Extend to edges */
        padding: 0 8px;
        scrollbar-width: thin;
        scrollbar-color: #475569 transparent;
    }
    
    .flight-table-container::-webkit-scrollbar {
        height: 6px;
    }
    
    .flight-table-container::-webkit-scrollbar-track {
        background: rgba(71, 85, 105, 0.2);
        border-radius: 3px;
    }
    
    .flight-table-container::-webkit-scrollbar-thumb {
        background: #475569;
        border-radius: 3px;
    }
    
    .flight-table {
        min-width: 600px; /* Ensure table doesn't collapse */
        table-layout: auto; /* Allow flexible column widths */
        font-size: 0.8125rem;
    }
    
    .flight-table th,
    .flight-table td {
        padding: 8px 10px;
        white-space: nowrap;
    }
    
    .miles-cell {
        min-width: 100px;
    }

    .miles-primary {
        font-size: 1rem;
    }
    
    .miles-taxes {
        font-size: 0.75rem;
    }

    .value-badge {
        font-size: 0.625rem;
        padding: 3px 6px;
        margin-top: 4px;
    }
    
    .route-airports,
    .route-times {
        font-size: 0.75rem;
    }
    
    /* Award table specific */
    .award-table {
        min-width: 700px;
    }
    
    /* Cash table specific */
    .cash-table {
        min-width: 550px;
    }
    
    /* Comparison table specific - needs more width */
    .value-comparison-table {
        min-width: 900px;
    }
    
    /* Scroll indicator hint */
    .flight-table-container::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, rgba(15, 23, 42, 0.8), transparent);
        pointer-events: none;
        opacity: 1;
        transition: opacity 0.3s;
    }
    
    .flight-table-container.scrolled-right::after {
        opacity: 0;
    }
}

/* Small mobile - more aggressive space saving */
@media (max-width: 480px) {
    .flight-table-container {
        margin: 8px -12px;
        padding: 0 12px;
    }
    
    .flight-table {
        font-size: 0.75rem;
    }
    
    .flight-table th,
    .flight-table td {
        padding: 6px 8px;
    }
    
    .miles-primary {
        font-size: 0.9375rem;
    }
    
    .value-badge {
        font-size: 0.5625rem;
        padding: 2px 5px;
    }
    
    /* Hide duration column on very small screens for award table */
    .award-table th:last-child,
    .award-table td:last-child {
        display: none;
    }
}

/* ========================================
   MOBILE CARD LAYOUT (Alternative View)
   For future use - currently using horizontal scroll
   ======================================== */

/*
.flight-cards {
    display: none;
}
*/

/* ========================================
   TOUCH-FRIENDLY ENHANCEMENTS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch devices - larger tap targets */
    .flight-table th.sortable {
        padding: 12px 10px;
        min-height: 44px;
    }
    
    .flight-table tbody tr {
        min-height: 48px;
    }
    
    /* Remove hover effects on touch */
    .flight-table tbody tr:hover {
        background: transparent;
    }
    
    .flight-table tbody tr:active {
        background: rgba(51, 65, 85, 0.4);
    }
    
    /* Better touch feedback for sortable headers */
    .flight-table th.sortable:active {
        background: rgba(71, 85, 105, 0.5);
    }
}

/* ========================================
   LANDSCAPE MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 896px) and (orientation: landscape) {
    .flight-table-container {
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .flight-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
    }
}

/* ========================================
   HIGH CONTRAST / ACCESSIBILITY
   ======================================== */

@media (prefers-contrast: high) {
    .flight-table {
        border: 2px solid #f1f5f9;
    }
    
    .flight-table th {
        border-bottom: 3px solid #f1f5f9;
    }
    
    .flight-table td {
        border-bottom: 1px solid #94a3b8;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .flight-table tbody tr {
        animation: none;
    }
    
    .flight-table tbody tr,
    .flight-table th.sortable,
    .sort-icon {
        transition: none;
    }
}/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flight-table tbody tr {
    animation: fadeIn 300ms ease-out backwards;
}

.flight-table tbody tr:nth-child(1) { animation-delay: 0ms; }
.flight-table tbody tr:nth-child(2) { animation-delay: 50ms; }
.flight-table tbody tr:nth-child(3) { animation-delay: 100ms; }
.flight-table tbody tr:nth-child(4) { animation-delay: 150ms; }
.flight-table tbody tr:nth-child(5) { animation-delay: 200ms; }

/* ========================================
   SCROLL SHADOW INDICATORS
   Shows user there's more content to scroll
   ======================================== */

.flight-table-container {
    position: relative;
}

/* Right scroll indicator - shows when not scrolled to end */
.flight-table-container.has-scroll::after {
    content: '→';
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(59, 130, 246, 0.8);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    pointer-events: none;
    opacity: 0.8;
    animation: pulse 2s infinite;
    z-index: 10;
}

.flight-table-container.scrolled-end::after {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; transform: translateY(-50%) translateX(0); }
    50% { opacity: 1; transform: translateY(-50%) translateX(3px); }
}

/* ========================================
   BEST DEAL BANNER
   Orange gradient callout for recommended option
   ======================================== */

.best-deal-banner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.1) 100%);
    border: 2px solid rgba(245, 158, 11, 0.4);
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
    animation: bannerFadeIn 400ms ease-out;
}

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

.best-deal-banner:hover {
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.2);
}

.banner-icon {
    font-size: 2.5rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    flex-shrink: 0;
}

.banner-content {
    flex: 1;
    min-width: 0;
}

.banner-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.banner-description {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #e5e7eb;
    margin-bottom: 8px;
}

.banner-description strong {
    color: #f1f5f9;
    font-weight: 600;
}

.highlight-value {
    font-weight: 700;
    color: #34d399;
    background: rgba(16, 185, 129, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.banner-savings {
    margin-top: 12px;
    font-size: 1rem;
    font-weight: 600;
    color: #34d399;
    display: flex;
    align-items: center;
    gap: 6px;
}

.banner-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.banner-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 150ms ease;
    cursor: pointer;
    border: none;
}

.banner-btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #1e293b;
}

.banner-btn-primary:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.banner-btn-secondary {
    background: rgba(71, 85, 105, 0.4);
    color: #e5e7eb;
    border: 1px solid rgba(71, 85, 105, 0.6);
}

.banner-btn-secondary:hover {
    background: rgba(71, 85, 105, 0.6);
    border-color: rgba(100, 116, 139, 0.8);
}

/* Mobile responsive banner */
@media (max-width: 640px) {
    .best-deal-banner {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }
    
    .banner-icon {
        font-size: 2rem;
    }
    
    .banner-title {
        font-size: 1.125rem;
    }
    
    .banner-description {
        font-size: 0.875rem;
    }
    
    .banner-actions {
        flex-direction: column;
    }
    
    .banner-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .best-deal-banner {
        animation: none;
    }
}

/* ========================================
   Export Button Styles
   ======================================== */

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(71, 85, 105, 0.3);
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 150ms ease;
    cursor: pointer;
    border: 1px solid rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.export-btn:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.7);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.export-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.export-btn:focus-visible {
    outline: 2px solid #34d399;
    outline-offset: 2px;
}

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

/* Export success feedback */
.export-btn.export-success {
    background: rgba(16, 185, 129, 0.3);
    border-color: #34d399;
    color: #fff;
}

.export-btn.export-success .export-btn-icon::before {
    content: '✓';
}

/* Mobile responsive */
@media (max-width: 640px) {
    .table-actions {
        justify-content: center;
    }
    
    .export-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }
}

