/* Compact Sticky Booking Form Widget - Modern UI Refinement */

/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===== CONTAINER ===== */
.compact-widget-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #4285f4, #2b579a);
    color: white;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== MOBILE SUMMARY BAR ===== */
.journey-summary-widget {
    display: none;
    padding: 12px 16px;
    justify-content: space-between;
    align-items: center;
}

.widget-details {
    display: flex;
    flex-direction: column;
}

.widget-route {
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.widget-meta {
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
}

.widget-edit-btn {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 6px 15px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
}

/* ===== DESKTOP FORM BODY ===== */
.compact-form-body {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    align-items: center !important;
    padding: 12px 15px !important;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    background: transparent;
}

/* Desktop Header (Hidden) */
.compact-mobile-header {
    display: none;
}

.compact-close-btn {
    display: none !important;
}

/* ===== ROW LOGIC ===== */
/* BUG 17 & 1: display: contents ONLY on desktop */
@media (min-width: 769px) {
    .compact-row {
        display: contents !important;
    }
}

/* BUG 5 & 15: Return Row logic fix */
#compact-return-row.hidden {
    display: none !important;
}

#compact-return-row:not(.hidden) {
    display: contents !important;
}

/* FORM FIELDS ratios - BUG 2 & 7 & 12 */
.compact-field {
    flex: 1.2 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Specific ratio for Trip Selector - BUG 7 */
.compact-field:has(#compact-trip-selector) {
    flex: 0 0 200px !important;
    max-width: 200px !important;
}

/* Specific ratios for FROM/TO - BUG 2 & 12 */
.compact-field:has(#from-location),
.compact-field:has(#to-location),
.compact-field:has(#airport-pickup),
.compact-field:has(#airport-drop),
.compact-field:has(#hourly-city),
.compact-field:has(#hourly-package) {
    flex: 2 1 auto !important;
}

/* Search Button ratio - BUG 2 */
.compact-field:has(.compact-search-btn) {
    flex: 0 0 160px !important;
}

.compact-lbl {
    font-size: 0.625rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    padding-left: 2px;
}

.compact-input,
.compact-select {
    background-color: #ffffff !important;
    color: #1a1a1a !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 0 12px !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    width: 100% !important;
    height: 42px !important;
    box-sizing: border-box;
    transition: padding-left 0.2s ease;
}

/* Hourly package hidden by default */
#hourly-package {
    display: none;
}

/* ===== GLOBAL ICON STYLING ===== */
.field-icon {
    position: absolute;
    color: #3b82f6;
    /* Modern Blue */
    pointer-events: none;
    z-index: 2;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Desktop Icon Position (Input is 42px, Label is above) */
@media (min-width: 769px) {
    .field-icon {
        left: 12px;
        bottom: 12px;
        /* Centered in 42px input box */
        font-size: 1rem;
    }

    .compact-field.with-icon .compact-input,
    .compact-field.with-icon .compact-select {
        padding-left: 36px !important;
    }
}

/* Search Button */
.compact-search-btn {
    background: #1a73e8;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    text-transform: uppercase;
    width: 100%;
    height: 42px;
    transition: background 0.2s;
}

.compact-search-btn:hover {
    background: #1557b0;
}

/* BUG 13: Stop Popup Desktop styles */
.stop-popup-desktop {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 280px;
    z-index: 2005;
    margin-top: 8px;
    color: #333;
}

.stop-popup-desktop.active {
    display: block;
}

.stop-popup-header {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    font-weight: 700;
    font-size: 0.85rem;
    color: #444;
}

.stop-popup-input-wrapper {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stop-popup-input {
    flex: 1;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    font-size: 0.9rem !important;
    color: #333 !important;
    background: white !important;
}

.stop-popup-close {
    cursor: pointer;
    font-size: 1.5rem;
    color: #888;
    line-height: 1;
}

/* Absolute STOP Link for Desktop */
#compact-stops-area {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 5;
}

.add-stop-link-compact {
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: background 0.2s;
}

/* Airport Toggle Group */
.compact-trip-type-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 2px;
    height: 42px;
}

.compact-trip-radio {
    flex: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compact-trip-radio input {
    display: none;
}

.compact-trip-radio span {
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    padding: 0 8px;
}

.compact-trip-radio input:checked+span {
    background: #ffffff;
    color: #1a73e8;
    border-radius: 3px;
}

/* =============================== */
/* ===== MOBILE UI (Boxed Blue) ===== */
/* =============================== */
@media (max-width: 768px) {
    .journey-summary-widget {
        display: flex !important;
    }

    .compact-form-body {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-height: 100vh !important;
        padding: 0 !important;
        /* BUG 22: Remove side padding */
        margin: 0 !important;
        flex-direction: column !important;
        gap: 15px !important;
        background: linear-gradient(135deg, #4285f4 0%, #2b579a 100%) !important;
        /* Airport Style Light Blue Gradient */
        overflow-y: auto !important;
        z-index: 2001 !important;
        border-radius: 0 0 24px 24px !important;
        align-items: stretch !important;
        padding-top: 10px !important;
        padding-bottom: 40px !important;
        /* Extra padding at bottom */
    }

    /* BUG 22: Stretch children */

    .compact-form-body.active {
        display: flex !important;
    }

    .compact-mobile-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 12px 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
        margin-bottom: 5px !important;
    }

    .mobile-brand-area {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .brand-name {
        color: #ffffff !important;
        font-weight: 800 !important;
        font-size: 1.05rem !important;
        letter-spacing: -0.01em !important;
        white-space: nowrap !important;
    }

    .mobile-logo {
        height: 28px !important;
        width: auto !important;
        object-fit: contain !important;
    }

    .compact-close-btn {
        display: flex !important;
        align-items: center;
        gap: 6px;
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.85rem;
        font-weight: 600;
        cursor: pointer;
        background: rgba(255, 255, 255, 0.1);
        padding: 6px 14px;
        border-radius: 50px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(4px);
    }

    /* BUG 17: Rows must use flex, not contents on mobile */
    .compact-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        width: 100% !important;
        padding: 0 15px !important;
        box-sizing: border-box;
        order: 3;
        margin-top: 28px !important;
        /* Space for labels above boxes */
    }

    /* Assign orders */
    .compact-row:has(#compact-trip-selector) {
        order: 1 !important;
    }

    /* Direction Toggle BELOW Trip Type */
    /* Ensure the direction field is wrapped properly if injected */
    .airport-direction-field {
        order: 2 !important;
        flex: 1 1 100% !important;
        width: 100% !important;
        margin: 0 15px 10px !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
        border-radius: 12px !important;
        padding: 10px 16px !important;
        min-height: 65px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    }

    .compact-row:has(#from-location),
    .compact-row:has(#airport-pickup),
    .compact-row:has(#hourly-city) {
        order: 3;
        /* Destination Fields */
    }

    #compact-stops-area {
        order: 4;
        /* STOP button row */
        position: static !important;
        width: 100% !important;
        padding: 0 15px !important;
        margin: 5px 0 0 !important;
        display: none;
        align-items: center !important;
        justify-content: flex-start !important;
        box-sizing: border-box !important;
    }

    .compact-row:has(#departure-date),
    .compact-row:has(#pickup-time),
    .compact-row:has(#airport-date) {
        order: 6 !important;
        /* Date Fields */
    }

    #compact-return-row {
        order: 7;
        /* Return Fields */
    }

    .compact-row:has(.compact-search-btn) {
        order: 999 !important;
        /* Search Button - Must be last */
    }

    .compact-field:has(#compact-trip-selector) {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        background: #ffffff !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
        min-height: 54px !important;
        max-height: 54px !important;
        margin-top: 28px !important;
        position: relative !important;
        overflow: visible !important;
        display: flex !important;
        align-items: center !important;
        padding: 8px 15px !important;
    }

    .compact-lbl {
        position: absolute !important;
        top: -24px !important;
        left: 0 !important;
        color: #ffffff !important;
        font-weight: 800 !important;
        font-size: 0.75rem !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
        opacity: 1 !important;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        width: 100%;
        white-space: nowrap;
        pointer-events: none;
        z-index: 5;
    }


    .compact-field {
        background: #ffffff !important;
        border-radius: 12px !important;
        padding: 8px 15px !important;
        /* Reduced padding since label is OUTSIDE */
        width: 100% !important;
        flex: 1 1 auto !important;
        min-height: 54px !important;
        /* Matching trip type look */
        max-height: 54px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
        box-sizing: border-box;
        transition: transform 0.2s ease;
        position: relative !important;
        overflow: visible !important;
        display: flex !important;
        align-items: center !important;
    }

    /* Field boxes with selectors/inputs must fill the container */
    .compact-field .compact-input,
    .compact-field .compact-select,
    .compact-field #hourly-package {
        flex: 1 !important;
        width: 100% !important;
    }

    .compact-field:active {
        transform: scale(0.98);
    }

    /* Side-by-side fields (City/Package, Date/Time, From/To) */
    .compact-row .compact-field:not(:only-child):not(:has(#compact-trip-selector)):not(:has(.compact-search-btn)) {
        width: calc(50% - 6px) !important;
        flex: 1 1 calc(50% - 6px) !important;
        min-width: calc(50% - 6px) !important;
    }

    .compact-input,
    .compact-select {
        background: #ffffff !important;
        color: #111 !important;
        height: 28px !important;
        min-height: 28px !important;
        line-height: 28px !important;
        font-size: 1rem !important;
        font-weight: 700 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        display: block;
        /* !important removed: Let JS control visibility */
        box-sizing: border-box !important;
        appearance: none !important;
        -webkit-appearance: none !important;
    }

    /* Custom Arrow for selects to look premium and match input style */
    .compact-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%234b5563'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 0 center !important;
        background-size: 16px !important;
        padding-right: 20px !important;
    }

    /* Global Icon alignment for card-style fields */
    .field-icon {
        position: absolute;
        left: 15px;
        top: 50% !important;
        bottom: auto !important;
        transform: translateY(-50%) !important;
        color: #3b82f6;
        font-size: 1rem;
        pointer-events: none;
        z-index: 2;
        opacity: 0.95;
    }

    .compact-field.with-icon .compact-input,
    .compact-field.with-icon .compact-select {
        padding-left: 32px !important;
    }

    /* Specific adjustment for selector icons if needed */
    .compact-field:has(#compact-trip-selector) .field-icon {
        left: 18px !important;
    }



    /* STOP Area Style */
    /* STOP Area Refinement */
    .add-stop-link-compact {
        background: rgba(255, 255, 255, 0.15) !important;
        color: white !important;
        padding: 10px 20px !important;
        border-radius: 50px !important;
        font-weight: 700 !important;
        font-size: 0.75rem !important;
        text-decoration: none !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        backdrop-filter: blur(8px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.05em !important;
        margin-top: 5px;
        margin-bottom: 10px;
    }

    /* Extra stops styling */
    .compact-stop-item {
        background: white !important;
        border-radius: 12px !important;
        padding: 10px 16px !important;
        margin-bottom: 8px !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    }

    .compact-stop-input {
        background: transparent !important;
        border: none !important;
        color: #333 !important;
        font-weight: 700 !important;
        font-size: 1rem !important;
        flex: 1;
    }

    .compact-remove-stop {
        color: #ff4d4d !important;
        font-size: 1.4rem !important;
        font-weight: bold;
        cursor: pointer;
    }

    /* Search Button */
    .compact-field:has(.compact-search-btn) {
        flex: 1 1 100% !important;
        width: 100% !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        min-height: auto !important;
    }

    .compact-search-btn {
        background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
        height: 56px !important;
        line-height: 56px !important;
        font-size: 1.1rem !important;
        font-weight: 800 !important;
        border-radius: 12px !important;
        margin-top: 15px !important;
        box-shadow: 0 8px 20px rgba(234, 88, 12, 0.35) !important;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        letter-spacing: 0.03em;
        border: none !important;
        color: white !important;
    }

    /* Return fields logic */
    #compact-return-row.hidden {
        display: none !important;
    }

    #compact-return-row:not(.hidden) {
        display: flex !important;
    }

    .compact-trip-type-toggle {
        background: #f1f3f4 !important;
        border-radius: 8px !important;
        height: 48px !important;
        padding: 3px !important;
    }

    .compact-trip-radio span {
        font-size: 0.825rem !important;
        color: #555 !important;
    }

    .compact-trip-radio input:checked+span {
        background: #3e7ee1 !important;
        color: white !important;
        border-radius: 6px !important;
    }

    .compact-extra-stops {
        order: 5 !important;
        width: 100% !important;
        padding: 0 15px !important;
        box-sizing: border-box !important;
    }

    .stop-popup-desktop {
        display: none !important;
    }
}

/* ===== DESKTOP MEDIA QUERY ===== */
@media (min-width: 769px) {
    .compact-form-body {
        display: flex !important;
    }

    .journey-summary-widget {
        display: none !important;
    }
}