/* ==========================================
     EPDE TEST VIEW — WINDOW 2: STYLESHEET
     Google-style redesign
     v12 — decorative mobile overview now hidden by default; real map
     shows immediately on mobile instead (pairs with epde-script-v12.js).
     v11 — FIX: #osm-map no longer relies on height:100% (percentage
     heights need every ancestor in the chain to have an explicit
     height, and any single break resolves to 0). Instead #osm-map
     is now position:absolute; inset:0 inside .garage-map, which is
     already position:relative/sticky with a real height at every
     breakpoint. Absolute positioning with inset:0 sizes against the
     nearest positioned ancestor's padding box directly — no
     percentage-chain to break.
     ========================================== */

.garage-layout {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 25px;
    width: 100%;
    box-sizing: border-box;
    padding: 16px 12px 0 12px;
}

/* DESKTOP: list on the left, map fixed/sticky on the right.
   (Map is first in the DOM for mobile-ordering convenience,
   so on desktop we push it visually to the right with order.) */
.garage-list-wrapper {
    flex: 0 0 50%;
    max-width: 50%;
    box-sizing: border-box;
    order: 1;
}

.garage-map {
    flex: 0 0 48%;
    max-width: 48%;
    position: sticky;
    top: 20px;
    height: 650px;
    box-sizing: border-box;
    overflow: hidden;
    order: 2;
    transition: height 0.25s ease;
}

.garage-map.expanded-desktop {
    height: 850px;
}

/* FIX: absolute + inset instead of width/height:100%. .garage-map is
   already position:sticky (a positioned element) with a real height
   at every breakpoint, so #osm-map now sizes directly against it —
   no percentage-height chain to break. */
#osm-map {
    position: absolute !important;
    inset: 0 !important;
    display: block !important;
    border-radius: 8px;
    border: 1px solid #ccc;
    z-index: 1;
}

/* Expand / Collapse / Recenter buttons — top-right on both desktop
   and mobile, for a consistent affordance */
.map-expand-btn,
.map-collapse-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1001;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #d1d5db;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-recenter-btn {
    position: absolute;
    bottom: 16px;
    right: 12px;
    z-index: 1001;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #d1d5db;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    color: #4f46e5;
}

/* Decorative overview (mobile default, before first expand) —
   plain count bubble, NO circular boundary ring (would wrongly imply
   a coverage radius), plus a few non-geographic decorative pins for
   visual texture only */
.map-decorative {
    display: none; /* shown only on mobile via media query below */
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.map-count-bubble {
    background: #4f46e5;
    color: #fff;
    font-weight: 800;
    font-size: 30px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.map-count-label {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.decorative-pin {
    position: absolute;
    font-size: 20px;
    opacity: 0.55;
}

.dp-1 { top: 18%; left: 20%; }
.dp-2 { top: 30%; right: 22%; }
.dp-3 { bottom: 26%; left: 30%; }
.dp-4 { bottom: 18%; right: 28%; }

/* Fixed city-name badge — always top-left of the map, regardless of
   zoom/pan, so users stay oriented on what area they're viewing */
.map-city-label {
    position: absolute;
    top: 18px;
    left: 55px;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 16px;
    color: #1e293b;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Live filtered-result count, shown on the real (non-decorative) map
   so the map itself stays relevant to whatever's currently filtered —
   sits just under the city label */
.map-live-count {
    position: absolute;
    top: 58px;
    left: 55px;
    z-index: 999;
    background: #4f46e5;
    color: #fff;
    padding: 4px 12px;
    border-radius: 5px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

.garage-list {
    /* No internal scroll — the list scrolls with the whole page.
       Only the map (on desktop) stays fixed/sticky. */
}

/* Listings: no boxes — separated by a horizontal line, plus zebra
   striping starting from the FIRST listing (not the second), so
   there's no "empty" plain-white feeling before the pattern kicks in */
.garage-item {
    padding: 18px 16px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}

.garage-item:nth-child(odd) {
    background: #f9fafb;
}

.garage-item:hover {
    background: #eef2ff;
}

.garage-item:first-child {
    padding-top: 4px;
}

.garage-title {
    font-size: 17px;
    margin-bottom: 6px;
    padding-right: 90px; /* keep clear of the top-right discount badge */
}

.garage-discount-badge {
    position: absolute;
    top: 16px;
    right: 4px;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.garage-meta {
    font-size: 15px;
    color: #444;
    margin-bottom: 6px;
}

.garage-established-row {
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 6px;
}

.garage-timing-row {
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 10px;
}

.status-badge {
    margin-left: 8px;
    font-weight: bold;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

/* Action button rows — two light-bordered rows, small icons */
.action-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.action-btn {
    flex: 1;
    text-align: center;
    padding: 7px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    text-decoration: none;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}

.action-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.view-photo-link {
    color: #6b46c1;
}

/* View Tab Bar: All | List */
.view-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
}

.view-tab {
    background: none;
    border: none;
    padding: 12px 22px;
    font-weight: 700;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.view-tab:hover {
    color: #1e293b;
}

.view-tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
}

/* Filter bar */
.filter-bar-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.distance-filter-dropdown {
    position: relative;
    display: inline-block;
}

.distance-toggle-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.distance-toggle-btn .chevron {
    display: inline-block;
    margin-left: 4px;
}

.distance-filter-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    padding: 6px;
    min-width: 160px;
    z-index: 500;
    flex-direction: column;
    gap: 4px;
}

.distance-filter-menu.open {
    display: flex;
}

.filter-btn {
    background: #f8f9fa;
    color: #1e293b;
    border: none;
    padding: 8px 10px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.2s;
}

.filter-btn:hover {
    background: #edf2f7;
}

.filter-btn.active {
    background: #4f46e5;
    color: #fff;
    font-weight: 600;
}

.simple-toggle-btn {
    background: #f8f9fa;
    color: #1e293b;
    border: 2px solid #dcdcdc;
    padding: 7px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    align-self: flex-start;
    transition: all 0.2s;
}

#openclose-filter-toggle.active {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

#offer-filter-toggle.active {
    background: #fef2f2;
    border-color: #dc3545;
    color: #b91c1c;
}

#all-filter-toggle.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}

.filter-reset-link {
    background: none;
    border: none;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 4px;
    text-decoration: underline;
}

.filter-reset-link:hover {
    color: #4f46e5;
}

#list-view-toggle.active {
    background: #ede9fe;
    border-color: #6b46c1;
    color: #5b21b6;
}

/* ===== LIST VIEW (compact rows + accordion) ===== */

/* Compact row: hidden by default (Card view is default) */
.compact-row {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.compact-name {
    font-weight: 700;
    font-size: 15px;
    color: #1e293b;
}

.compact-area {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}

/* When List view is active (class added to #garage-list by JS):
   show compact rows, hide full detail by default, tighten row padding */
.garage-list.list-view .compact-row {
    display: flex;
}

.garage-list.list-view .full-detail {
    display: none;
}

.garage-list.list-view .garage-item {
    padding: 12px 16px;
}

/* Accordion: only the expanded item's full-detail shows, with a
   little top spacing to separate it from the compact row above it */
.garage-list.list-view .garage-item.expanded .full-detail {
    display: block;
    margin-top: 12px;
}

.garage-list.list-view .garage-item.expanded .compact-name {
    color: #4f46e5;
}

/* Empty state */
.no-results-message {
    text-align: center;
    padding: 50px 20px;
    background: #f8f9fc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    margin-bottom: 18px;
}

.no-results-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.no-results-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 6px 0;
}

.no-results-subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 18px 0;
}

.no-results-reset-btn {
    background: #4f46e5;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.no-results-reset-btn:hover {
    background: #4338ca;
}

/* View Photo modal — small, centered, NOT full-screen */
.photo-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-modal-box {
    background: #fff;
    border-radius: 10px;
    padding: 30px 25px;
    width: 260px;
    max-width: 85vw;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.photo-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #64748b;
}

.photo-modal-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.photo-modal-text {
    font-size: 14px;
    color: #475569;
    font-weight: 600;
    margin: 0;
}

/* ===== MOBILE: map on top (fixed, modest height), list below, whole page scrolls ===== */
@media (max-width: 900px) {
    .garage-layout {
        flex-direction: column;
    }

    .garage-list-wrapper,
    .garage-map {
        flex: 0 0 100%;
        max-width: 100%;
        order: initial; /* DOM order takes over: map first, then list */
    }

    .garage-map {
        position: relative;
        height: 220px;
        min-height: 220px;
        flex-shrink: 0;
        margin-bottom: 15px;
        width: 100%;
    }

    /* #osm-map no longer needs its own height rules here — it's
       position:absolute; inset:0 (set above, outside the media query)
       and just follows whatever height .garage-map currently has. */

    /* v12: the real map now shows immediately on mobile (see JS
       change), so the decorative overview is hidden by default
       instead of shown — kept as a class or fallback (not deleted)
       in case a decorative-only mode is wanted again later.
       City label / live-count badge now show immediately too, since
       there's a real map underneath them to sit on top of. */
    .map-decorative {
        display: none;
    }

    /* Expanded mobile state (class added by JS on tapping expand) */
    .garage-map.expanded-mobile {
        height: 65vh;
        min-height: 65vh;
        position: relative;
    }

    .garage-map.expanded-mobile .map-decorative {
        display: none;
    }

    .garage-map.expanded-mobile .map-city-label,
    .garage-map.expanded-mobile .map-live-count {
        display: block;
    }
}
