/* ================================================================
   Camptime.ca — Split Panel Layout
   Desktop: Panel LEFT | Map RIGHT
   Mobile:  Panel TOP  | Map BELOW | Stops BOTTOM
   ================================================================ */

:root {
    --c-primary: #2D5016;
    --c-accent: #D4863A;
    --c-accent-light: #e09a55;
    --c-bg: #FAF6F0;
    --c-dark: #1C2A14;
    --c-text: #2C2417;
    --c-muted: #6b5e52;
    --c-border: #e4ddd4;
    --c-card: #ffffff;
    --c-green: #3a8a3e;
    --c-red: #c44d3f;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(44,36,23,.08);
    --panel-w: 380px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font);
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR ── */
.topbar {
    height: 48px;
    background: var(--c-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    flex-shrink: 0;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 600;
}
.topbar-brand svg { color: var(--c-accent); }
.topbar-brand b { color: var(--c-accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-tag {
    font-size: .75rem;
    color: rgba(255,255,255,.5);
    letter-spacing: .02em;
}

/* ── APP LAYOUT ── */
.app {
    display: flex;
    height: calc(100vh - 48px);
    overflow: hidden;
}

/* ── LEFT PANEL ── */
.panel {
    width: var(--panel-w);
    flex-shrink: 0;
    background: var(--c-card);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.panel-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    -webkit-overflow-scrolling: touch;
}
.panel-scroll::-webkit-scrollbar { width: 4px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 2px; }

/* ── ROUTE INPUTS (From / To) ── */
.route-inputs {
    position: relative;
    margin-bottom: 12px;
}
.route-field {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}
.route-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid;
}
.dot-green { border-color: var(--c-green); background: rgba(58,138,62,.15); }
.dot-red { border-color: var(--c-red); background: rgba(196,77,63,.15); }

.route-line {
    width: 2px;
    height: 16px;
    background: var(--c-border);
    margin-left: 5px;
}

.route-input-wrap {
    flex: 1;
    position: relative;
}
.route-input-wrap input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius);
    font-size: .95rem;
    background: var(--c-bg);
    color: var(--c-text);
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
.route-input-wrap input:focus {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px rgba(212,134,58,.12);
    background: #fff;
}
.route-input-wrap input::placeholder {
    color: var(--c-muted);
    font-weight: 400;
}

/* ── ADD STOP ── */
.btn-add-stop {
    background: none;
    border: none;
    color: var(--c-accent);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 8px;
    transition: color .2s;
}
.btn-add-stop:hover { color: var(--c-primary); }

.waypoints-list {
    margin-bottom: 8px;
}

/* ── QUICK OPTIONS ── */
.quick-opts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--c-bg);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
}
.opt-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.opt-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    width: 52px;
    flex-shrink: 0;
}
.opt-select, .opt-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
    font-size: .85rem;
    background: var(--c-card);
    color: var(--c-text);
    outline: none;
}
.opt-select:focus, .opt-input:focus {
    border-color: var(--c-accent);
}
.fuel-inline {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}
.fuel-inline input { width: 70px; flex: none; }
.fuel-unit {
    font-size: .75rem;
    color: var(--c-muted);
    font-weight: 500;
}

/* ── GO BUTTON ── */
.btn-go {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--c-accent), var(--c-accent-light));
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 4px 14px rgba(212,134,58,.25);
    margin-bottom: 16px;
}
.btn-go:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212,134,58,.35);
}
.btn-go:active { transform: translateY(0); }

/* ── SERVICES TOGGLE ── */
.svc-details {
    margin-bottom: 16px;
}
.svc-summary {
    font-size: .85rem;
    font-weight: 600;
    color: var(--c-muted);
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}
.svc-summary::before {
    content: '▸';
    transition: transform .2s;
}
.svc-details[open] .svc-summary::before {
    transform: rotate(90deg);
}
.svc-summary::-webkit-details-marker { display: none; }

.svc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 8px 0;
}
.svc-grid label {
    font-size: .8rem;
    color: var(--c-text);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
}
.svc-grid label:hover { background: var(--c-bg); }
.svc-grid input { margin: 0; }

/* ── TRIP SUMMARY ── */
.trip-summary {
    background: var(--c-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--c-border);
}
.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0,0,0,.04);
}
.summary-row:last-child { border-bottom: none; }
.summary-label { font-size: .85rem; color: var(--c-muted); }
.summary-value { font-size: .85rem; font-weight: 700; color: var(--c-primary); }

/* ── STOPS LIST ── */
.stops-list { margin-bottom: 16px; }
.stops-heading {
    font-size: .9rem;
    font-weight: 700;
    color: var(--c-primary);
    margin-bottom: 8px;
}

/* ── NAV ACTIONS (Waze / Google Maps) ── */
.nav-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.btn-nav {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius);
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform .15s;
}
.btn-nav:hover { transform: translateY(-1px); }
.btn-waze {
    background: #33ccff;
    color: #000;
}
.btn-gmaps {
    background: #4285f4;
    color: #fff;
}

/* ── MAP AREA ── */
.map-area {
    flex: 1;
    position: relative;
}
#map {
    width: 100%;
    height: 100%;
}

/* ── MOBILE STOPS (below map) ── */
.mobile-stops {
    display: none;
}

/* ── FOOTER ── */
.app-footer {
    display: none; /* Hidden in app mode — shown in scroll */
}

/* ── PREDICTIVE SEARCH overrides for this layout ── */
.ps-dropdown {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ================================================================
   RESPONSIVE — MOBILE PORTRAIT
   ================================================================ */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    .panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--c-border);
        max-height: none;
        flex-shrink: 0;
    }
    
    .panel-scroll {
        padding: 14px 12px;
        overflow-y: visible;
        max-height: none;
    }
    
    .map-area {
        flex: 1;
        min-height: 300px;
    }
    
    .mobile-stops {
        display: block;
        background: var(--c-card);
        border-top: 1px solid var(--c-border);
        padding: 12px;
        max-height: 35vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Collapse services and options on mobile */
    .quick-opts {
        padding: 8px 10px;
    }
    
    .opt-row {
        flex-wrap: wrap;
    }
    
    .svc-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar-tag {
        display: none;
    }
    
    .route-input-wrap input {
        padding: 10px 12px;
        font-size: .9rem;
    }
    
    .btn-go {
        padding: 12px;
        font-size: .95rem;
    }
    
    .nav-actions {
        flex-direction: column;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .topbar { height: 42px; padding: 0 10px; }
    .topbar-brand { font-size: .95rem; }
    .app { height: calc(100vh - 42px); }
    .panel-scroll { padding: 10px 10px; }
    .route-input-wrap input { padding: 9px 10px; }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .app { flex-direction: row; }
    .panel { width: 320px; border-right: 1px solid var(--c-border); border-bottom: none; }
    .panel-scroll { overflow-y: auto; }
    .mobile-stops { display: none; }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(250,246,240,.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loading-inner { text-align: center; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p { color: var(--c-primary); font-weight: 600; font-size: .9rem; }
