/**
 * Charleston Airport Flight Status Plugin - Enhanced CSS
 * Production-Ready Version - April 2025
 * - WCAG 2.1 AA compliant (minimum 4.5:1 contrast for text)
 * - Improved mobile-first responsive design
 * - Fixed layout transition bugs
 * - Enlarged popup containers to prevent nested scrolling
 * - FIXED: Guide popup z-index and positioning issues
 */

/* ======================================
   1. RESET & BASE STYLES
   ====================================== */
body .chs-flight-search-widget *,
body .chs-flight-status-search *,
body .chs-flight-status-table * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Brandon Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: normal;
}

/* Accessibility helper */
body .screen-reader-text {
    border: 0 !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    clip-path: inset(50%) !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    width: 1px !important;
    word-wrap: normal !important;
}

/* ======================================
   2. SEARCH COMPONENTS
   ====================================== */
/* Search container */
body .chs-flight-search-widget,
body .chs-flight-status-search {
    font-family: "Brandon Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    position: relative !important;
}

/* Tab navigation */
body .chs-flight-search-tabs {
    display: flex !important;
    width: 100% !important;
    border: none !important;
    margin-bottom: 0 !important;
    background-color: transparent !important;
}

body .chs-tab-button {
    flex: 1 !important;
    text-align: center !important;
    padding: 12px 0 !important;
    color: #000000 !important;
    background-color: #fff !important;
    border: none !important;
    transition: all 0.2s ease-in-out !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: normal !important;
    height: auto !important;
    text-transform: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-height: 48px !important; /* Ensure good touch target size */
}

body .chs-tab-button:hover {
    color: #fff !important;
    background-color: #008ad8 !important;
}

body .chs-tab-button.active {
    color: #fff !important;
    background-color: #008ad8 !important;
    border-bottom: none !important;
}

body .chs-tab-button:focus {
    outline: 2px solid #008ad8 !important;
    outline-offset: 2px !important;
}

/* Search form */
body .chs-flight-search-form {
    padding: 0 !important;
    margin: 0 !important;
    background-color: transparent !important;
    width: 100% !important;
}

body .chs-search-field {
    position: relative !important;
    display: flex !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

body .chs-search-field input[type="text"] {
    width: 100% !important;
    height: 48px !important;
    padding: 10px 40px 10px 15px !important;
    border: 1px solid #d5dadf !important;
    border-radius: 0 !important;
    background-color: #fff !important;
    color: #0f0f10 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    box-shadow: none !important;
    transition: border-color 0.2s ease-in-out !important;
    margin: 15px 0 !important;
    line-height: normal !important;
}

body .chs-search-field input[type="text"]:focus {
    border-color: #008ad8 !important;
    outline: 2px solid #1b90ff !important;
    outline-offset: -1px !important;
}

body .chs-search-button {
    position: absolute !important;
    right: 1px !important;
    top: 16px !important;
    height: calc(100% - 32px) !important;
    width: 46px !important;
    border: none !important;
    background-color: transparent !important;
    color: #000 !important;
    cursor: pointer !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    transition: color 0.2s ease-in-out !important;
    line-height: 0 !important;
    border-radius: 0 !important;
    min-height: 44px !important;
    min-width: 44px !important;
}

body .chs-search-button:hover {
    color: #008ad8 !important;
}

body .chs-search-button svg {
    width: 20px !important;
    height: 20px !important;
}

body .chs-go-button {
    width: 100% !important;
    height: 48px !important;
    margin-top: 1px !important;
    background-color: #1B365D !important;
    color: #fff !important;
    border: none !important;
    border-radius: 0 !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease-in-out !important;
    padding: 0 !important;
    text-align: center !important;
    text-transform: uppercase !important;
    line-height: 48px !important;
    letter-spacing: 0.5px !important;
    min-height: 48px !important;
}

body .chs-go-button:hover {
    background-color: #0e2944 !important;
}

body .chs-go-button:focus {
    outline: 2px solid #1b90ff !important;
    outline-offset: 2px !important;
}

/* ======================================
   3. SEARCH RESULTS
   ====================================== */
body .chs-quick-results {
    width: 100% !important;
    max-height: 350px !important;
    overflow-y: auto !important;
    background-color: #fff !important;
    border: 1px solid #d5dadf !important;
    border-top: none !important;
    margin-top: 0 !important;
    position: absolute !important;
    z-index: 1000 !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15) !important;
    left: 0 !important;
    right: 0 !important;
}

body .chs-quick-result-item {
    padding: 12px 15px !important;
    border-bottom: 1px solid #eaeaea !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease-in-out !important;
    background-color: white !important;
}

body .chs-quick-result-item:last-child {
    border-bottom: none !important;
}

body .chs-quick-result-item:hover {
    background-color: #f5f9fc !important;
}

body .chs-quick-result-item:focus {
    outline: 2px solid #1b90ff !important;
    outline-offset: -2px !important;
    position: relative !important;
    z-index: 1 !important;
}

body .chs-result-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 5px !important;
}

body .chs-result-flight-number {
    font-weight: 700 !important;
    font-size: 15px !important;
    color: #1b365d !important;
}

body .chs-result-operational-status {
    font-weight: 700 !important;
    font-size: 14px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #1b365d !important; /* Always navy blue */
}

body .chs-result-details {
    display: flex !important;
    justify-content: space-between !important;
}

body .chs-result-origin-label {
    font-size: 12px !important;
    color: #595959 !important;
    margin-bottom: 3px !important;
    display: block !important;
}

body .chs-result-origin-value {
    font-size: 14px !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 180px !important;
}

body .chs-result-time {
    text-align: right !important;
}

/* CRITICAL FIX: Timeliness status colors */
body .chs-result-timeliness-status {
    font-size: 12px !important;
    font-weight: 700 !important;
    display: block !important;
    margin-bottom: 3px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

body .chs-result-timeliness-status.on-time,
body .chs-status-on-time,
body .chs-estimated-time.chs-status-on-time {
    color: #006F4E !important; /* Darker green for better contrast (5.9:1) */
}

body .chs-result-timeliness-status.early,
body .chs-status-early,
body .chs-estimated-time.chs-status-early {
    color: #006F4E !important; /* Darker green for better contrast (5.9:1) */
}

body .chs-result-timeliness-status.delayed,
body .chs-status-delayed,
body .chs-estimated-time.chs-status-delayed {
    color: #D2415b !important; /* Red for delayed/late */
}

body .chs-status-canceled {
    color: #AF0F3C !important; /* Darker red for better contrast (5.6:1) */
}

body .chs-result-time-value {
    font-size: 14px !important;
    font-weight: 500 !important;
}

/* ======================================
   4. FLIGHT STATUS TABLE
   ====================================== */
body .chs-flight-status-table {
    width: 100% !important;
    max-width: 100% !important;
    font-family: "Brandon Grotesque", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    margin: 30px 0 !important;
    border: none !important;
    padding: 0 !important;
    background-color: transparent !important;
}

/* Table header */
body .chs-flight-status-header {
    display: flex !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background-color: #fff !important;
    color: #000 !important;
    padding: 15px 20px !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    border-bottom: 1px solid #d5dadf !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

body .chs-header-cell {
    padding: 0 10px !important;
    background-color: #fff !important;
}

/* Flight rows - consolidated style for consistency */
body .chs-flight-row {
    display: flex !important;
    align-items: center !important;
    padding: 20px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    transition: background-color 0.2s ease-in-out !important;
    position: relative !important;
    background-color: white !important; 
    border-bottom: 1px solid #d5dadf !important;
}

body .chs-flight-row:hover {
    background-color: #f8fbff !important;
}

body .chs-flight-row:focus,
body .chs-flight-row:focus-visible {
    outline: 2px solid #1b90ff !important;
    outline-offset: -2px !important;
    background-color: #e9f5fc !important;
}

/* Cell styling */
body .chs-cell {
    padding: 0 10px !important;
    display: flex !important;
    align-items: center !important;
}

/* Airline info */
body .chs-cell-airline {
    width: 20% !important;
    display: flex !important;
    align-items: center !important;
}

body .chs-airline-logo {
    width: 50px !important;
    height: 50px !important;
    object-fit: contain !important;
    margin-right: 10px !important;
}

body .chs-airline-info {
    display: flex !important;
    flex-direction: column !important;
}

body .chs-airline-name {
    font-weight: 600 !important;
    color: #0f0f10 !important;
    margin-bottom: 4px !important;
    font-size: 16px !important;
    line-height: 1.2 !important;
}

body .chs-flight-number {
    font-weight: 500 !important;
    color: #595959 !important; /* Darker for better contrast */
    font-size: 14px !important;
    line-height: 1.2 !important;
    display: block !important;
    margin-top: 4px !important;
}

/* Origin/destination column */
body .chs-cell-origin,
body .chs-cell-destination {
    width: 20% !important;
    color: #0f0f10 !important;
}

/* Status column */
body .chs-cell-status {
    width: 12% !important;
    font-weight: 600 !important;
}

body .chs-status {
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
}

/* Status colors for operational status */
body .chs-status-departed,
body .chs-status-scheduled,
body .chs-status-out-gate,
body .chs-status-in-air,
body .chs-status-landed,
body .chs-status-in-gate,
body .chs-status-arrived {
    color: #0f0f10 !important;
}

/* Time columns */
body .chs-cell-estimated,
body .chs-cell-scheduled {
    width: 12% !important;
    color: #0f0f10 !important;
}

/* Consolidated estimated time styling */
body .chs-estimated-time {
    position: relative !important;
    display: block !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    white-space: nowrap !important;
}

/* Status indicator that appears before the time */
body .chs-time-status {
    display: block !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
}

/* Style the time value */
body .chs-time-value {
    display: block !important;
    white-space: nowrap !important;
    font-size: 14px !important;
}

/* Gate/Claim columns */
body .chs-cell-gate,
body .chs-cell-claim {
    width: 10% !important;
    color: #0f0f10 !important;
}

/* ======================================
   5. GUIDE & WEATHER COMPONENTS
   ====================================== */
/* Guide column */
body .chs-cell-guide {
    width: 16% !important;
}

/* Guide button */
body .chs-guide-button {
    background-color: transparent !important;
    color: #1b365d !important;
    border: none !important;
    padding: 8px 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    font-size: 14px !important;
    cursor: pointer !important;
    text-decoration: underline !important;
    border-radius: 0 !important;
    min-height: 44px !important;
    min-width: 44px !important;
}

/* This is critical - preserve the img element in the guide button */
body .chs-guide-button img.chs-guide-icon-img {
    width: 35px !important;
    height: 35px !important;
    margin-right: 10px !important;
    background-color: #94f0ff !important;
    border-radius: 50% !important;
    padding: 6px !important;
    display: inline-block !important;
}

/* Ensure SVG icons are displayed properly */
body .chs-guide-button svg,
body .chs-weather-button svg {
    display: inline-block !important;
    width: 35px !important;
    height: 35px !important;
    margin-right: 10px !important;
    background-color: #94f0ff !important;
    border-radius: 50% !important;
    padding: 6px !important;
}

/* ====================================== 
   POPUP FIX: Guide popup positioning and z-index
   ====================================== */

/* Guide popup */
body .chs-guide-content,
body .chs-weather-content {
    position: fixed !important; /* FIXED: Changed from absolute to fixed */
    z-index: 999999 !important; /* FIXED: Increased z-index dramatically */
    width: 350px !important; 
    max-width: 90% !important; /* FIXED: Added max-width for mobile */
    max-height: 85vh !important; /* FIXED: Increased height to avoid scrolling */
    top: 50% !important; /* FIXED: Center vertically */
    left: 50% !important; /* FIXED: Center horizontally */
    transform: translate(-50%, -50%) !important; /* FIXED: Center positioning */
    margin: 0 !important; /* FIXED: Remove margin that could affect positioning */
    background-color: white !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important; /* FIXED: Stronger shadow */
    overflow: auto !important; /* FIXED: Allow scrolling inside popup if needed */
    padding: 20px !important;
    display: none;
}

body .chs-guide-content-inner,
body .chs-weather-content-inner {
    position: relative !important;
}

body .chs-guide-content-inner h4 {
    margin-top: 0 !important;
    padding-right: 25px !important;
    color: #0f0f10 !important; /* Darkened for better contrast */
    font-size: 18px !important;
    margin-bottom: 10px !important;
    font-weight: 600 !important;
}

body .chs-guide-content-inner p {
    margin-bottom: 15px !important;
    color: #0f0f10 !important;
}

body .chs-guide-links {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

body .chs-guide-link {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #0056b3 !important; /* Darker blue for better contrast */
    text-decoration: underline !important;
    font-weight: 500 !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    transition: background-color 0.2s ease !important;
}

body .chs-guide-link:hover {
    background-color: #f6f6f6 !important;
    color: #003b7a !important; /* Even darker on hover */
}

body .chs-guide-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Preserve custom icons in guide links */
body .chs-custom-guide-icon img.chs-custom-icon {
    width: 35px !important;
    height: 35px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    background-color: #94f0ff !important;
    border-radius: 50% !important;
    padding: 6px !important;
}

/* FIXED: Guide/Weather close button - improved positioning and visibility */
body .chs-guide-close,
body .chs-weather-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 30px !important;
    height: 30px !important;
    background: #f6f6f6 !important;
    border: 1px solid #ddd !important;
    border-radius: 50% !important;
    font-size: 18px !important;
    line-height: 1 !important; /* FIXED: Improved vertical alignment */
    text-align: center !important;
    color: #333 !important; /* FIXED: Darker for better visibility */
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important; /* FIXED: Added shadow */
    padding: 0 !important;
    margin: 0 !important;
    z-index: 999999 !important; /* FIXED: Ensure button is above content */
}

body .chs-guide-close:hover,
body .chs-weather-close:hover {
    background: #e2e2e2 !important;
    color: #000 !important;
}

/* FIXED: Modal backdrop with proper z-index */
body .chs-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    z-index: 999998 !important; /* FIXED: Just below the popup */
    display: block !important;
}

body.chs-modal-open {
    overflow: hidden !important;
}

/* Weather button */
body .chs-weather-button {
    background-color: transparent !important;
    color: #1b365d !important;
    border: none !important;
    padding: 8px 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    font-size: 14px !important;
    cursor: pointer !important;
    text-decoration: underline !important;
    border-radius: 0 !important;
    min-height: 44px !important;
    min-width: 44px !important;
}

/* Weather content styling */
body .chs-weather-content .wi {
    display: inline-block !important;
    font-size: 3rem !important;
    margin-bottom: 10px !important;
    color: #1b365d !important;
}

body .chs-weather-temp {
    font-size: 2rem !important;
    font-weight: 600 !important;
    margin-bottom: 10px !important;
}

body .chs-weather-info {
    margin: 5px 0 !important;
    text-align: left !important;
}

body .chs-weather-desc {
    margin: 10px 0 !important;
    font-weight: 500 !important;
    font-size: 1.1rem !important;
}

/* ======================================
   6. PAGINATION
   ====================================== */
body .chs-flight-pagination {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 15px !important;
    background-color: white !important;
    margin-top: 20px !important;
}

body .chs-pagination-prev,
body .chs-pagination-next {
    background: none !important;
    border: 1px solid #d5dadf !important;
    border-radius: 0 !important;
    padding: 8px 12px !important;
    margin: 0 10px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    color: #0f0f10 !important;
    transition: all 0.2s ease !important;
    line-height: normal !important;
    min-height: 44px !important;
    min-width: 44px !important;
}

body .chs-pagination-prev:hover,
body .chs-pagination-next:hover {
    background-color: #f6f6f6 !important;
}

body .chs-pagination-prev:disabled,
body .chs-pagination-next:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

body .chs-pagination-info {
    font-size: 14px !important;
    color: #595959 !important; /* Darker for better contrast */
}

/* ======================================
   7. GHOST LOADER & STATE INDICATORS
   ====================================== */
/* No flight results */
body .chs-no-results {
    padding: 30px !important;
    text-align: center !important;
    background-color: #fff !important;
    color: #595959 !important; /* Darker for better contrast */
    font-weight: 500 !important;
    font-size: 16px !important;
    width: 100% !important;
}

/* Error message */
body .chs-error {
    padding: 15px !important;
    text-align: center !important;
    background: white !important;
    color: #D1415B !important;
}

/* Ghost loader */
.chs-ghost-loader {
    width: 100%;
    background-color: #fff;
    overflow: hidden;
    border: 1px solid #d5dadf;
    border-top: none;
    animation: fadeIn 0.3s;
    border-radius: 4px;
}

.chs-ghost-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eaeaea;
    animation: ghostPulse 1.5s infinite;
}

.chs-ghost-result-item:last-child {
    border-bottom: none;
}

.chs-ghost-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.chs-ghost-flight-number {
    width: 80px;
    height: 16px;
    background-color: #e8e8e8;
    border-radius: 3px;
}

.chs-ghost-status {
    width: 60px;
    height: 14px;
    background-color: #e8e8e8;
    border-radius: 3px;
}

.chs-ghost-result-details {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.chs-ghost-origin-dest {
    flex: 1;
    max-width: 70%;
}

.chs-ghost-origin-label {
    width: 30px;
    height: 12px;
    background-color: #e8e8e8;
    border-radius: 3px;
    margin-bottom: 6px;
}

.chs-ghost-origin-value {
    width: 120px;
    height: 14px;
    background-color: #e8e8e8;
    border-radius: 3px;
}

.chs-ghost-time {
    text-align: right;
}

.chs-ghost-time-label {
    width: 50px;
    height: 12px;
    background-color: #e8e8e8;
    border-radius: 3px;
    margin-bottom: 6px;
    margin-left: auto;
}

.chs-ghost-time-value {
    width: 60px;
    height: 14px;
    background-color: #e8e8e8;
    border-radius: 3px;
    margin-left: auto;
}

@keyframes ghostPulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.8; }
    100% { opacity: 0.6; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fix for row visibility during filtering */
body .chs-flight-row.visible-row {
    display: flex !important;
}

body .chs-flight-row.filtered-out,
body .chs-flight-row.is-search-hidden {
    display: none !important;
}

/* Search results visibility */
body .chs-flight-row.search-result,
body .chs-flight-row.is-search-result {
    background-color: #fff !important;
    border-top: 1px solid #d5dadf !important;
    border-bottom: 1px solid #d5dadf !important;
    display: flex !important;
}

body .chs-flight-status-tab-content.in-search-mode .chs-flight-rows-container {
    border-top: 1px solid #d5dadf !important;
}

body .chs-flight-row.search-visible {
    display: flex !important;
}

body .chs-flight-row.search-hidden {
    display: none !important;
}

/* View All link in quick results */
.chs-view-all-container {
    padding: 12px 15px !important;
    border-top: 1px solid #eaeaea !important;
    text-align: center !important;
    background-color: #f9f9f9 !important;
}

.chs-view-all-link {
    color: #1B365D !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    display: inline-block !important;
    padding: 4px 8px !important;
}

.chs-view-all-link:hover {
    color: #0e2944 !important;
}

.chs-view-all-link:focus {
    outline: 2px solid #1b90ff !important;
    outline-offset: 2px !important;
}

/* ======================================
   8. MOBILE STYLES - OPTIMIZED FOR CARDS
   ====================================== */

/* Mobile styles (767px and below) */
@media (max-width: 767px) {
    /* CRITICAL: Hide guide and weather cells on mobile */
    body .chs-cell-guide,
    body .chs-cell-weather {
        display: none !important;
    }
    
    /* Hide table headers on mobile */
    body .chs-flight-status-header {
        display: none !important;
    }
    
    /* Redefine flight row layout for mobile */
    body .chs-flight-row {
        display: block !important;
        padding: 0 !important;
        margin-bottom: 12px !important;
        border-radius: 8px !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
        background-color: #fff !important;
        overflow: hidden !important;
        position: relative !important;
        min-height: 150px !important;
    }
    
    /* Add top accent bar */
    body .chs-flight-row::before {
        content: "";
        display: block;
        height: 6px;
        width: 100%;
        background-color: #1B365D;
        position: absolute;
        top: 0;
        left: 0;
    }
    
    /* Card header - contains airline info and origin/destination */
    body .chs-card-header {
        display: flex !important;
        padding: 12px !important;
        border-bottom: 1px solid #f0f0f0 !important;
        position: relative !important;
        background-color: #f8f8f8 !important;
        padding-top: 18px !important;
    }
    
    body .chs-airline-section {
        display: flex !important;
        align-items: center !important;
        width: 50% !important;
    }
    
    body .chs-route-section {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-end !important;
        width: 50% !important;
        text-align: right !important;
    }
    
    /* Hide original cells */
    body .chs-flight-row .chs-cell {
        display: none !important;
    }
    
    /* Main card content with status, times and gate/claim info */
    body .chs-card-content {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        padding: 15px !important;
        gap: 12px !important;
    }
    
    /* Status section - spans full width */
    body .chs-status-section {
        grid-column: 1 / -1 !important;
        margin-bottom: 5px !important;
    }
    
    /* Time section - contains timeliness indicator and time */
    body .chs-time-section,
    body .chs-gate-section {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    /* Time status indicator */
    body .chs-time-status {
        font-size: 11px !important;
        font-weight: 700 !important;
        margin-bottom: 3px !important;
        white-space: nowrap !important;
        text-transform: uppercase !important;
    }
    
    /* Time value */
    body .chs-time-value {
        font-weight: 600 !important;
        font-size: 16px !important;
        white-space: nowrap !important;
    }
    
    /* Gate/Baggage label styling */
    body .chs-gate-label {
        font-size: 11px !important;
        color: #595959 !important;
        margin-bottom: 3px !important;
        font-weight: 500 !important;
        text-transform: uppercase !important;
    }
    
    /* Gate/Baggage value */
    body .chs-gate-value {
        font-weight: 600 !important;
        font-size: 16px !important;
    }
    
    /* Hide table header and label any data cells in use */
    body .chs-header-cell {
        display: none !important;
    }
    
    /* Ensure any cells that remain visible on mobile have a label */
    body .chs-cell:not([data-label]) {
        position: relative !important;
    }
    
    body .chs-cell:not([data-label]):before {
        content: attr(class);
        display: block !important;
        font-weight: 600 !important;
        font-size: 12px !important;
        color: #595959 !important; 
        text-transform: capitalize !important;
        margin-bottom: 5px !important;
    }
    
    /* FIXED: Mobile popup styling - full screen and better positioned */
    body .chs-guide-content,
    body .chs-weather-content {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 85% !important;
        max-width: 350px !important;
        max-height: 75vh !important;
        overflow-y: auto !important;
        box-shadow: 0 12px 24px rgba(0,0,0,0.3) !important;
        border-radius: 10px !important;
        z-index: 100000 !important;
        padding: 20px !important;
    }
    
    /* Larger close buttons for touch */
    body .chs-guide-close, 
    body .chs-weather-close {
        width: 36px !important;
        height: 36px !important;
        line-height: 1 !important;
        font-size: 24px !important;
        right: 12px !important;
        top: 12px !important;
    }
    
    /* Pagination improvements */
    body .chs-pagination-prev,
    body .chs-pagination-next {
        padding: 10px 14px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 15px !important;
    }
    
    /* Quick results styling for mobile */
    body .chs-quick-results {
        max-height: 60vh !important; /* Allow more space on mobile */
        box-shadow: 0 8px 16px rgba(0,0,0,0.2) !important;
    }
    
    body .chs-quick-result-item {
        padding: 14px !important; /* Larger padding for touch */
    }
}

/* Extra small devices (phones) */
@media (max-width: 480px) {
    /* Even larger buttons for very small screens */
    body .chs-tab-button {
        min-height: 54px !important;
        padding: 16px 0 !important;
        font-size: 18px !important;
    }
    
    body .chs-search-field input[type="text"] {
        height: 58px !important;
    }
    
    body .chs-go-button {
        height: 58px !important;
        line-height: 58px !important;
    }
    
    /* Bigger text for readability */
    body .chs-airline-name {
        font-size: 18px !important;
    }
    
    body .chs-flight-number {
        font-size: 16px !important;
    }
    
    /* Make weather display more visible */
    body .chs-weather-temp {
        font-size: 2.5rem !important;
    }
    
    /* Larger close buttons */
    body .chs-guide-close,
    body .chs-weather-close {
        width: 40px !important;
        height: 40px !important;
        font-size: 26px !important;
    }
}

/* High contrast mode support */
@media (forced-colors: active) {
    body .chs-tab-button.active {
        border: 2px solid ButtonText !important;
    }
    
    body .chs-flight-row:focus,
    body .chs-flight-row:focus-visible {
        outline: 2px solid ButtonText !important;
    }
    
    body .chs-tab-button:focus,
    body .chs-go-button:focus,
    body .chs-search-button:focus,
    body .chs-guide-button:focus,
    body .chs-weather-button:focus,
    body .chs-guide-close:focus,
    body .chs-weather-close:focus,
    body .chs-pagination-prev:focus,
    body .chs-pagination-next:focus {
        outline: 2px solid ButtonText !important;
    }
    
    /* Ensure flight rows are clearly separated in high contrast mode */
    body .chs-flight-row {
        border: 2px solid !important;
    }
    
    /* Ensure buttons are recognizable as buttons */
    body button,
    body .chs-go-button {
        border: 1px solid ButtonText !important;
    }
}

/**
 * ALTERNATING ROW COLORS
 * Only applied on desktop view
 */
@media (min-width: 768px) {
    body .chs-flight-row.even-row {
        background-color: #f9f9f9 !important;
    }

    body .chs-flight-row.odd-row {
        background-color: #ffffff !important;
    }
}

/**
 * CRITICAL MOBILE FLIGHT CARD STYLING 
 */
@media screen and (max-width: 767px) {
    body .chs-origin-dest {
        font-weight: 500 !important;
        font-size: 14px !important;
        color: #0f0f10 !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    body .chs-airport-code {
        font-size: 13px !important;
        color: #595959 !important;
        line-height: 1.4 !important;
    }
    
    /* Properly size the airline logo in card view */
    body .chs-airline-section .chs-airline-logo {
        width: 40px !important;
        height: 40px !important;
        margin-right: 10px !important;
        object-fit: contain !important;
    }
    
    /* Make status stand out */
    body .chs-status-section .chs-status {
        font-size: 16px !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        text-transform: uppercase !important;
    }
    
    /* Enhance accessibility of cards */
    body .chs-flight-row:focus {
        outline: 3px solid #1b90ff !important;
        outline-offset: 0 !important;
        position: relative !important;
        z-index: 2 !important;
    }
}

/**
 * FIX: DESKTOP-MOBILE TRANSITION
 * Fix issues when transitioning between desktop and mobile views
 */
@media (min-width: 768px) {
    /* Reset mobile transformations when viewed on desktop */
    body .chs-flight-row.mobile-transformed .chs-cell {
        display: flex !important;
    }
    
    body .chs-card-header,
    body .chs-card-content {
        display: none !important;
    }
    
    /* Reset any inline styles that might be affecting display */
    body .chs-flight-row {
        display: flex !important;
    }
    
    /* Enforce flex layout for all cells in desktop view */
    body .chs-flight-row .chs-cell-airline,
    body .chs-flight-row .chs-cell-origin,
    body .chs-flight-row .chs-cell-destination,
    body .chs-flight-row .chs-cell-status,
    body .chs-flight-row .chs-cell-estimated,
    body .chs-flight-row .chs-cell-scheduled,
    body .chs-flight-row .chs-cell-gate,
    body .chs-flight-row .chs-cell-claim,
    body .chs-flight-row .chs-cell-guide,
    body .chs-flight-row .chs-cell-weather {
        display: flex !important;
    }
}

/* Table header positioning fix */
body .chs-flight-status-header {
    position: sticky !important;
    top: 105px !important; /* Adjust based on your navigation height */
    z-index: 90 !important; /* Lower than your nav but higher than table content */
}



/* Fix for weather button icons alignment */
body .chs-weather-button {
    background-color: transparent !important;
    color: #1b365d !important;
    border: none !important;
    padding: 8px 12px 8px 0 !important; /* Added horizontal padding */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important; /* Ensure consistent alignment */
    font-size: 14px !important;
    cursor: pointer !important;
    text-decoration: underline !important;
    border-radius: 0 !important;
    min-height: 44px !important;
    min-width: 44px !important;
    white-space: nowrap !important; /* Prevent text wrapping */
    line-height: 1.2 !important; /* Improve vertical alignment */
}

/* Ensure consistent icon styling */
body .chs-weather-button svg {
    display: inline-block !important;
    width: 35px !important;
    height: 35px !important;
    min-width: 35px !important; /* Prevent icon from shrinking */
    margin-right: 10px !important;
    background-color: #94f0ff !important;
    border-radius: 50% !important;
    padding: 6px !important;
    vertical-align: middle !important; /* Align with text */
    position: relative !important; /* Position context for alignment */
    top: -1px !important; /* Fine-tune vertical alignment */
}

/* For modern browsers supporting gap */
@supports (gap: 10px) {
    body .chs-weather-button {
        gap: 10px !important; /* Modern spacing method */
    }
    
    body .chs-weather-button svg {
        margin-right: 0 !important; /* Remove margin when gap is supported */
    }
}

/* General icon alignment class */
.chs-icon-align-fix {
    display: inline-flex !important;
    align-items: center !important;
    vertical-align: middle !important;
}

/* Fix for weather icon containers in table cells */
body .chs-cell-weather {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
}