/*
 * Tech Appointment Map — complete stylesheet.
 *
 * This page renders standalone: no theme CSS is loaded, so everything it needs
 * including the reset is here. Do not assume any Tailwind utility exists.
 *
 * Deliberately modelled on the BBE dispatch tool at bedbugexterminator.org so
 * that office staff see the same thing whichever location they are looking at:
 * same header, same 320px left sidebar in the same order (status, new job
 * address, key, filters, schedule), same map on the right, same marker shape.
 * The chrome and the rust accent are BBE's on purpose — for a tool two teams
 * share, familiarity beats brand-matching.
 *
 * BBS differs from BBE in exactly two ways, both additive:
 *   - colour is the TRUCK, not the tech (BBE has no truck field)
 *   - tech initials follow the time on the marker's second line
 */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body.bbs-map-body {
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #242424;
    background: #fff;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; }

/* ---------------------------------------------------------- password gate */

.bbs-map-lock { max-width: 30rem; margin: 4rem auto; padding: 0 1.25rem; }
.bbs-map-lock h1 { font-size: 1.4rem; color: #003407; margin: 0 0 0.5rem; }
.bbs-map-lock p { color: #5c5c5c; font-size: 0.9rem; margin-bottom: 0.9rem; }

.bbs-map-lock input[type="password"] {
    padding: 0.5rem 0.6rem;
    border: 1px solid #e6e4e4;
    border-radius: 5px;
    font-size: 0.95rem;
}

.bbs-map-lock input[type="submit"] {
    padding: 0.5rem 0.9rem;
    background: #b2400e;
    color: #fff;
    border: 0;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
}

/* ----------------------------------------------------------------- header */

.bbs-map-head {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #e6e4e4;
    background: #fff;
    flex: 0 0 auto;
}

.bbs-map-head h1 {
    font-size: 1.05rem;
    line-height: 1.25;
    font-weight: 700;
    color: #003407;
}

.bbs-map-head p {
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: #5c5c5c;
    line-height: 1.4;
}

/* ----------------------------------------------------------------- layout */

.bbs-map-wrap {
    --bbs-green: #003407;
    --bbs-rust: #b2400e;
    --bbs-ink: #242424;
    --bbs-muted: #5c5c5c;
    --bbs-line: #e6e4e4;
    --bbs-bg: #f5f4ef;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    flex: 1 1 auto;
    min-height: 0;
    border-top: 1px solid var(--bbs-line);
    color: var(--bbs-ink);
}

.bbs-map-side {
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bbs-bg);
    border-right: 1px solid var(--bbs-line);
    padding: 1rem 1rem 3rem;
}

.bbs-map-side h2 {
    font-size: 0.72rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--bbs-muted);
    margin: 1.25rem 0 0.5rem;
    font-weight: 700;
}

.bbs-map-side h2:first-child { margin-top: 0; }

.bbs-map-canvas { height: 100%; width: 100%; z-index: 0; background: #e8e5dd; }

/* ----------------------------------------------------------------- status */

.bbs-map-status {
    font-size: 0.78rem;
    line-height: 1.45;
    padding: 0.6rem 0.7rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.bbs-map-status.is-live { background: #e8f3ea; border: 1px solid #b9dcc1; color: #17391f; }
.bbs-map-status.is-seed { background: #fdf1e7; border: 1px solid #f0c9a8; color: #6b2f08; }

/* --------------------------------------------------------- address search */

.bbs-map-search { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; }

.bbs-map-search input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--bbs-line);
    border-radius: 5px;
    font-size: 0.85rem;
    background: #fff;
    color: var(--bbs-ink);
}

.bbs-map-search input:focus {
    outline: 2px solid var(--bbs-rust);
    outline-offset: -1px;
    border-color: var(--bbs-rust);
}

.bbs-map-btn {
    padding: 0.5rem 0.75rem;
    background: var(--bbs-rust);
    color: #fff;
    border: 0;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.bbs-map-btn:hover { background: #8f3309; }
.bbs-map-btn[disabled] { opacity: 0.55; cursor: default; }

.bbs-map-btn-ghost {
    background: transparent;
    color: var(--bbs-muted);
    border: 1px solid var(--bbs-line);
}

.bbs-map-btn-ghost:hover { background: #ece9e1; color: var(--bbs-ink); }

.bbs-map-note { font-size: 0.76rem; color: var(--bbs-muted); line-height: 1.45; margin: 0.35rem 0 0; }
.bbs-map-note.is-error { color: #a01b1b; }

/* ---------------------------------------------------------------- filters */

.bbs-map-filters { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }

.bbs-map-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--bbs-line);
    border-radius: 999px;
    background: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--bbs-ink);
    font-weight: 600;
}

.bbs-map-chip[aria-pressed="false"] { opacity: 0.4; }

.bbs-map-swatch { width: 20px; height: 20px; border-radius: 2px; display: inline-block; border: 1px solid #5c5c5c; }
.bbs-map-swatch.round { border-radius: 50%; }

.bbs-map-count { font-weight: 400; color: var(--bbs-muted); font-variant-numeric: tabular-nums; }

.bbs-map-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--bbs-line);
    border-radius: 5px;
    background: #fff;
    font-size: 0.8rem;
    color: var(--bbs-ink);
    width: 100%;
}

/* -------------------------------------------------------------------- key */

.bbs-map-legend { font-size: 0.78rem; color: var(--bbs-muted); }

.bbs-map-legend-head,
.bbs-map-legend-row {
    display: grid;
    grid-template-columns: 44px 36px 1fr;
    align-items: center;
    gap: 0.5rem;
}

.bbs-map-legend-head {
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bbs-muted);
    margin-bottom: 0.3rem;
}

.bbs-map-legend-head span { text-align: center; }
.bbs-map-legend-row { margin-bottom: 0.3rem; }
.bbs-map-legend-label { font-weight: 600; color: var(--bbs-ink); font-size: 0.82rem; }

.bbs-map-legend-shape {
    border: 2px solid #5c5c5c;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    justify-self: center;
}

.bbs-map-legend-shape.rect { width: 40px; height: 24px; border-radius: 2px; }
.bbs-map-legend-shape.round { width: 28px; height: 28px; border-radius: 50%; }

.bbs-map-legend-note { margin: 0.5rem 0 0; font-size: 0.74rem; line-height: 1.45; color: var(--bbs-muted); }

/* --------------------------------------------------------------- schedule */

.bbs-map-day { margin-bottom: 0.9rem; }

.bbs-map-day-head {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--bbs-green);
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--bbs-line);
    margin-bottom: 0.35rem;
}

.bbs-map-item {
    display: grid;
    grid-template-columns: 22px 1fr;
    gap: 0.5rem;
    align-items: start;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 0.4rem 0.25rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--bbs-ink);
}

.bbs-map-item:hover { background: #ece9e1; }
.bbs-map-item.is-active { background: #e3ded1; }

.bbs-map-seq {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.bbs-map-item-name { font-weight: 600; }
.bbs-map-item-meta { color: var(--bbs-muted); font-size: 0.76rem; }
.bbs-map-item-note { color: #9a3412; font-size: 0.74rem; }
.bbs-map-drive { color: var(--bbs-rust); font-weight: 700; font-size: 0.76rem; }
.bbs-map-empty { font-size: 0.82rem; color: var(--bbs-muted); padding: 0.5rem 0; }

/* ------------------------------------------------------------ not on map */

.bbs-map-unmapped {
    margin-top: 1rem;
    padding: 0.7rem 0.75rem;
    background: #fdf1e7;
    border: 1px solid #f0c9a8;
    border-radius: 6px;
    font-size: 0.78rem;
    color: #6b2f08;
    line-height: 1.45;
}

.bbs-map-unmapped strong { display: block; margin-bottom: 0.25rem; }
.bbs-map-unmapped li { padding: 0.25rem 0; border-top: 1px solid #f5ddc6; }
.bbs-map-unmapped .why { display: block; color: #a16207; font-size: 0.72rem; }

/* ---------------------------------------------------------------- markers */

.bbs-pin { background: none; border: 0; }

/*
 * Day and date on the first line, time on the second — the same block shape
 * and dimensions as BBE, so the two maps read identically.
 */
.bbs-pin-box {
    position: relative;
    display: inline-block;
    padding: 5px 8px;
    min-height: 44px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    color: #fff;
    white-space: nowrap;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    text-align: center;
}

/* Rectangle = heat. Rounded = inspection / spray / respray. */
.bbs-pin-rect { border-radius: 2px; }
.bbs-pin-round { border-radius: 11px; }

/* Approximate geocode: dashed border, so nobody trusts the exact position. */
.bbs-pin-approx { border-style: dashed; }

.bbs-pin-truck { margin-right: 4px; font-weight: 900; }
.bbs-pin-sub { display: block; font-size: 12px; font-weight: 600; }
.bbs-pin-time { opacity: 1; }

/* Keep the initials easy to pick out without turning the marker into a badge. */
.bbs-pin-techs {
    display: inline-block;
    margin-left: 1px;
    padding: 0 2px;
    border-radius: 2px;
    background: transparent;
    border: 1px solid currentColor;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.25;
}

/* Contact and booking title disagree about who is going. */
.bbs-pin-conflict::after {
    content: "!";
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 14px;
    height: 14px;
    font-size: 9px;
    font-weight: 800;
    line-height: 12px;
    text-align: center;
    color: #7c2d12;
    background: #fcd34d;
    border: 1px solid #fff;
    border-radius: 999px;
}

.bbs-pin-origin .bbs-pin-box {
    background: #111;
    border-color: #ffd400;
    border-radius: 3px;
    font-size: 11px;
}

/* ----------------------------------------------------------------- popups */

.bbs-map-popup { font-size: 0.82rem; line-height: 1.5; }
.bbs-map-popup strong { display: block; font-size: 0.9rem; margin-bottom: 0.15rem; }
.bbs-map-popup .bbs-map-popup-addr { color: #5c5c5c; }
.bbs-map-popup .bbs-map-drive { display: block; margin-top: 0.3rem; }
.bbs-map-popup .bbs-map-popup-hint { display: block; margin-top: 0.3rem; color: #9b9b9b; }
.bbs-map-popup em { color: #9a3412; }

.leaflet-popup-content { margin: 10px 12px; }
.leaflet-container { font: inherit; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 860px) {
    .bbs-map-wrap { grid-template-columns: 1fr; flex: 0 0 auto; }
    .bbs-map-side { border-right: 0; border-bottom: 1px solid var(--bbs-line); max-height: 46vh; }
    .bbs-map-canvas { height: 62vh; }
}
