/* =========================================
   1. BASE LAYOUT
   ========================================= */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f8f9fa;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

/* =========================================
   2. COLLAPSIBLE DRAWER SYSTEM
   ========================================= */
.floating-planner {
    position: absolute;
    z-index: 20;
    background-color: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* MOBILE: Top Sheet */
@media (max-width: 767px) {
    .floating-planner {
        top: 0;
        left: 0;
        width: 100vw;
        max-height: 85vh;
        border-radius: 0 0 1.5rem 1.5rem;
    }

    #planner-logo-main {
        width: clamp(110px, 48vw, 200px) !important;
        max-width: 100%;
        height: auto;
        object-fit: contain;
        flex-shrink: 1;
    }

    /* Collapsed state for mobile — slides up, leaving only the header */
    .floating-planner.collapsed {
        transform: translateY(calc(-100% + 40px));
    }
}

/* DESKTOP: Floating Box — collapse disabled */
@media (min-width: 768px) {
    .floating-planner {
        top: 20px;
        left: 20px;
        width: 500px;
        max-height: calc(100vh - 40px);
        border-radius: 1rem;
    }

    /* Override any collapsed state — always fully open on desktop */
    .floating-planner.collapsed {
        max-height: calc(100vh - 40px);
        transform: none;
    }

    /* Header is not a trigger on desktop */
    .planner-header {
        cursor: default;
        pointer-events: none;
    }

    /* Hide the collapse chevron on desktop — card is always open */
    .floating-planner .drawer-arrow {
        display: none;
    }

    /* Ensure body is always visible on desktop */
    .floating-planner .planner-body {
        display: block !important;
        overflow-y: auto;
    }
}

/* The Header (collapse trigger — now sits at the bottom of the card) */
.planner-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(0,0,0,0.05);
    background: white;
    user-select: none;
    flex-shrink: 0;
}

/* The Scrollable Body */
.planner-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    -webkit-overflow-scrolling: touch;
}

/* Toggle Arrow — points UP when expanded (tap to collapse), DOWN when collapsed (tap to expand) */
.drawer-arrow {
    transition: transform 0.4s;
    font-size: 1.2rem;
    color: #6c757d;
    transform: rotate(180deg);
}

.collapsed .drawer-arrow {
    transform: rotate(0deg);
}

/* Map controls bar — sits just below mainPlanner on mobile (top set by JS) */
#map-controls-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    z-index: 25;
    pointer-events: none;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#map-controls-bar > * {
    pointer-events: auto;
}

/* On desktop the bar reverts to absolute inside contmap, top-right */
@media (min-width: 768px) {
    #map-controls-bar {
        position: absolute;
        top: 10px !important;
        left: auto;
        right: 10px;
        width: auto;
        flex-direction: column;
        align-items: flex-end;
        padding: 0;
        transition: none;
    }

    #layer-switcher {
        order: 1;
    }

    #btnTripOverlayToggle {
        order: 2;
    }

    #btnGeolocate {
        order: 3;
    }
}

/* Handle for mobile — sits at bottom of card since sheet drops from top */
.pull-handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 10px;
    margin: -10px auto 8px;
    display: none;
}

@media (max-width: 767px) {
    .pull-handle {
        display: block;
    }
}

.btn-swap {
    width: 48px;
    height: 48px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s;
}

.btn-swap:hover {
    background-color: #e9ecef;
}

/* 1. Normal state (Not checked) */
.btn-outline-custom {
    color: #bdc454 !important;
    border-color: #bdc454 !important;
    background-color: #ffffff;
}

/* Ensure the icon matches the text color */
.btn-outline-custom i {
    color: inherit;
}

/* 2. Hover state (Mouse over, but not checked) */
.btn-outline-custom:hover {
    color: #bdc454 !important;
    background-color: rgb(219, 219, 219) !important;
    border-color: #bdc454 !important;
}

/* 3. Active / Checked state (When selected) */
.btn-check:checked + .btn-outline-custom {
    color: #ffffff !important;
    background-color: #bdc454 !important;
    border-color: #bdc454 !important;
}

.planner-realtime-clock {
    min-width: 108px;
    padding: 0.15rem 0.45rem;
    border: 1px solid #bdc454;
    border-radius: 0.35rem;
    background-color: #ffffff;
    color: #bdc454;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
}

/* Ensure the icon turns white when selected */
.btn-check:checked + .btn-outline-custom i {
    color: #ffffff !important;
}

/* =========================================
   3. TRIP RESULT & ANIMATED ARROW
   ========================================= */
.text-line-1 {
    color: #e06666;
    font-size: 0.95rem;
}

.text-line-2 {
    color: #b30000;
    font-size: 0.95rem;
    line-height: 1.4;
}

.custom-progress {
    height: 10px;
    border-radius: 0;
}

.bg-bar-grey {
    background-color: #8a8a8a;
}

.bg-bar-dark {
    background-color: #343a40;
}

.go-ready-logo {
    font-size: 0.85rem;
    color: #6c8ebf;
    letter-spacing: 0.5px;
}

/* Smooth rotation for the toggle arrow */
.toggle-arrow {
    transition: transform 0.3s ease;
}

/* When Bootstrap adds the 'collapsed' class to the header, flip the arrow */
.card-header.collapsed .toggle-arrow {
    transform: rotate(180deg);
}
