/* =====================================================================
   map.css — shared map surfaces for the Customer Portal
   Map picker, geocoder search sheet, route card, trip timeline and the
   booking OTP sheet. Consumes theme.css tokens only.
   Included by pages/book.php and pages/trips/details.php.
   ===================================================================== */

/* ---------------------------------------------------------- Base utilities */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-8);
    min-height: 44px;
    padding: var(--space-12) var(--space-20);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--brand);
    color: var(--brand-contrast);
    font: inherit;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; filter: none; }
.btn--primary { background: var(--brand); color: var(--brand-contrast); }
.btn--accent  { background: var(--accent-500); color: var(--primary-900); }
.btn--ghost   { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--surface-3); }
.btn--outline { background: transparent; color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.btn--danger  { background: var(--error-500); color: #fff; }
.btn--block   { width: 100%; }
.btn--sm      { min-height: 36px; padding: var(--space-8) var(--space-16); font-size: 0.875rem; }
.btn--lg      { min-height: 52px; padding: var(--space-16) var(--space-24); font-size: 1.0625rem; }

.skeleton {
    display: block;
    border-radius: var(--radius-8);
    background: linear-gradient(90deg, var(--surface-3) 25%, color-mix(in srgb, var(--surface-3) 60%, #fff) 37%, var(--surface-3) 63%);
    background-size: 400% 100%;
    animation: ant-shimmer 1.4s ease infinite;
}
@keyframes ant-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.field { display: grid; gap: var(--space-8); }
.field__label { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.field__input {
    width: 100%;
    min-height: 48px;
    padding: var(--space-12) var(--space-16);
    border: 1px solid var(--border);
    border-radius: var(--radius-14);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
.field__input--area { min-height: 96px; resize: vertical; }
.field__input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
.field__input.is-invalid { border-color: var(--error-500); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-12);
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
}
.chip--estimate { background: var(--primary-50); color: var(--primary-500); }
[data-theme="dark"] .chip--estimate { background: var(--primary-800); color: var(--primary-200); }

/* -------------------------------------------------------------- Map picker */
.map-picker {
    position: relative;
    height: 100%;
    min-height: 320px;
    overflow: hidden;
    border-radius: var(--radius-20);
    background: var(--surface-3);
}
.map-picker__canvas { position: absolute; inset: 0; z-index: 0; }
.map-picker__canvas.leaflet-container { background: var(--surface-3); font: inherit; }

.map-picker__pin {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    transform: translate(-50%, -100%);
    transition: transform 0.18s ease;
    color: var(--map-drop);
    font-size: 1.6rem;
    pointer-events: none;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.map-picker__pin-stem {
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 2px;
    height: 10px;
    transform: translateX(-50%);
    background: currentColor;
    opacity: 0.5;
}
.map-picker.is-dragging .map-picker__pin { transform: translate(-50%, -135%) scale(1.08); }

.map-picker__topbar {
    position: absolute;
    top: var(--space-12);
    left: var(--space-12);
    right: var(--space-12);
    z-index: 4;
    display: flex;
    align-items: center;
    gap: var(--space-8);
}
.map-picker__targets {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--surface);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-2);
}
.map-picker__targets button {
    min-height: 36px;
    padding: var(--space-8) var(--space-16);
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.map-picker__targets button.is-active { background: var(--brand); color: var(--brand-contrast); }
.map-picker__search-btn {
    margin-left: auto;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-2);
    cursor: pointer;
}

.map-picker__glass {
    position: absolute;
    left: var(--space-12);
    right: var(--space-12);
    bottom: var(--space-64);
    z-index: 4;
    display: flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-12) var(--space-16);
    border-radius: var(--radius-14);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    box-shadow: var(--shadow-2);
}
.map-picker__glass-icon { color: var(--accent-500); }
.map-picker__glass-text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9375rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.map-picker__glass-skeleton {
    flex: 1 1 auto;
    height: 1rem;
    border-radius: var(--radius-8);
    background: rgba(255, 255, 255, 0.28);
    display: none;
}
.map-picker__glass.is-loading .map-picker__glass-text { display: none; }
.map-picker__glass.is-loading .map-picker__glass-skeleton { display: block; animation: ant-shimmer 1.4s ease infinite; }

.map-picker__geo-denied {
    position: absolute;
    left: 50%;
    top: var(--space-64);
    z-index: 4;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-8) var(--space-16);
    border-radius: var(--radius-pill);
    background: var(--warning-100);
    color: var(--warning-text);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
}

.map-picker__locate {
    position: absolute;
    right: var(--space-12);
    bottom: var(--space-12);
    z-index: 4;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--brand);
    box-shadow: var(--shadow-2);
    cursor: pointer;
}
.map-picker__locate.is-busy { animation: ant-spin 1s linear infinite; }
@keyframes ant-spin { to { transform: rotate(360deg); } }

.map-picker__chips {
    position: absolute;
    left: var(--space-12);
    right: var(--space-64);
    bottom: var(--space-12);
    z-index: 4;
    display: flex;
    gap: var(--space-8);
    overflow-x: auto;
    padding-bottom: var(--space-4);
    scrollbar-width: none;
}
.map-picker__chips::-webkit-scrollbar { display: none; }
.map-picker__chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    min-height: 36px;
    padding: var(--space-8) var(--space-12);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

/* ----------------------------------------------------- Geocoder search sheet */
.map-search-sheet { position: absolute; inset: 0; z-index: 6; }
.map-search-sheet[hidden] { display: none; }
.map-search-sheet__backdrop { position: absolute; inset: 0; background: rgba(6, 12, 30, 0.45); }
.map-search-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-28) var(--radius-28) 0 0;
    box-shadow: var(--shadow-3);
    animation: customer-sheet-up 0.22s ease;
}
.map-search-sheet__field {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-16) var(--space-16) var(--space-12);
    border-bottom: 1px solid var(--border);
}
.map-search-sheet__field i { color: var(--text-muted); }
.map-search-sheet__field input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}
.map-search-sheet__field input:focus { outline: none; }
.map-search-sheet__field button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
}
.map-search-sheet__results { overflow-y: auto; padding: var(--space-8); }
.map-search-sheet__loading { height: 48px; margin-bottom: var(--space-8); }
.map-search-sheet__result {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    width: 100%;
    min-height: 48px;
    padding: var(--space-12);
    border: 0;
    border-radius: var(--radius-14);
    background: transparent;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.map-search-sheet__result:hover { background: var(--surface-3); }
.map-search-sheet__result i { color: var(--accent-500); }
.map-search-sheet__result-text { min-width: 0; }
.map-search-sheet__empty { padding: var(--space-20); text-align: center; color: var(--text-muted); }

@keyframes customer-sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

/* -------------------------------------------------------------- Route card */
.route-card {
    display: grid;
    gap: var(--space-12);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-20);
    padding: var(--space-12);
    box-shadow: var(--shadow-1);
}
.route-card__title { margin: 0; font-size: 1rem; }
.route-card__map {
    position: relative;
    height: var(--route-card-height, 220px);
    border-radius: var(--radius-14);
    overflow: hidden;
    background: var(--surface-3);
}
.route-card__map.leaflet-container { background: var(--surface-3); font: inherit; }
.route-card__skeleton { position: absolute; inset: 0; }
.route-card__estimate { display: flex; }
.route-card__estimate[hidden] { display: none; }
.route-card__approx { margin-left: var(--space-4); font-weight: 500; opacity: 0.8; }

/* ----------------------------------------------------------- Trip timeline */
.trip-timeline { display: grid; gap: var(--space-8); }
.trip-timeline__title { margin: var(--space-8) 0 0; font-size: 0.9375rem; }
.trip-timeline__list { list-style: none; margin: 0; padding: 0; display: grid; }
.trip-timeline__item {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: var(--space-12);
    position: relative;
    padding-bottom: var(--space-16);
}
.trip-timeline__item:last-child { padding-bottom: 0; }
.trip-timeline__item::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 26px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}
.trip-timeline__item:last-child::before { display: none; }
.trip-timeline__marker {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--primary-500);
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1;
}
.trip-timeline__item--pickup .trip-timeline__marker { background: var(--success-100); color: var(--map-pickup); }
.trip-timeline__item--drop .trip-timeline__marker { background: var(--error-100); color: var(--map-drop); }
.trip-timeline__item--stop .trip-timeline__marker,
.trip-timeline__item--destination .trip-timeline__marker { background: var(--warning-100); color: var(--map-stop); }
.trip-timeline__body { display: grid; gap: 2px; padding-top: 2px; }
.trip-timeline__label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.trip-timeline__text { color: var(--text); }
.trip-timeline__meta { display: flex; gap: var(--space-8); font-size: 0.8125rem; color: var(--text-muted); }

/* ----------------------------------------------------------- Leaflet markers */
/* Pin labels next to the standard Leaflet pin (same pin as Admin / Driver). */
.leaflet-tooltip.ant-pin-tip {
    padding: 2px 8px;
    border: 0;
    border-radius: var(--radius-pill, 999px);
    background: rgba(17, 24, 39, 0.86);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.leaflet-tooltip.ant-pin-tip::before { display: none; }

.ant-map-marker { background: transparent; border: 0; }
.ant-map-marker__dot {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-pill);
    background: var(--marker, var(--brand));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: var(--shadow-2);
}

/* -------------------------------------------------------------- OTP sheet */
.otp-sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.otp-sheet[hidden] { display: none; }
.otp-sheet__backdrop { position: absolute; inset: 0; background: rgba(6, 12, 30, 0.55); backdrop-filter: blur(2px); }
.otp-sheet__panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    padding: var(--space-16) var(--space-20) var(--space-24);
    background: var(--surface);
    border-radius: var(--radius-28) var(--radius-28) 0 0;
    box-shadow: var(--shadow-3);
    text-align: center;
    animation: customer-sheet-up 0.22s ease;
}
.otp-sheet__grabber { display: block; width: 44px; height: 4px; margin: 0 auto var(--space-16); border-radius: var(--radius-pill); background: var(--neutral-300); }
.otp-sheet__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-12);
    border-radius: var(--radius-pill);
    background: var(--primary-50);
    color: var(--brand);
    font-size: 1.4rem;
}
[data-theme="dark"] .otp-sheet__icon { background: var(--primary-800); color: var(--primary-200); }
.otp-sheet__title { margin: 0 0 var(--space-4); font-size: 1.25rem; }
.otp-sheet__subtitle { margin: 0 0 var(--space-20); color: var(--text-muted); }
.otp-input { display: flex; gap: var(--space-8); justify-content: space-between; margin-bottom: var(--space-12); }
.otp-input__box {
    flex: 1 1 0;
    min-width: 0;
    height: 56px;
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: var(--radius-14);
    background: var(--surface);
    color: var(--text);
}
.otp-input__box:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
.otp-sheet__error { min-height: 1.2em; margin: 0 0 var(--space-12); color: var(--error-text); font-size: 0.875rem; }
.otp-sheet__verify { width: 100%; }
.otp-sheet__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); margin-top: var(--space-16); }
.otp-sheet__resend { border: 0; background: transparent; color: var(--brand); font: inherit; font-weight: 600; cursor: pointer; }
.otp-sheet__resend:disabled { color: var(--text-muted); cursor: not-allowed; }
.otp-sheet__timer { opacity: 0.7; }
.otp-sheet__edit { border: 0; background: transparent; color: var(--text-muted); font: inherit; cursor: pointer; }
.otp-sheet.is-shake .otp-sheet__panel { animation: ant-shake 0.4s ease; }
@keyframes ant-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

body.has-sheet { overflow: hidden; }

@media (min-width: 640px) {
    .map-picker { min-height: 420px; }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .map-picker__pin { transition: none; }
    .otp-sheet__panel,
    .map-search-sheet__panel { animation: none; }
    .otp-sheet.is-shake .otp-sheet__panel { animation: none; }
    .map-picker__locate.is-busy { animation: none; }
}
