/* ═══════════════════════════════════════════════════
   Modules — Modals, GPS, Stop Cards, Trip Builder,
   Toast, Bus Popup
   ═══════════════════════════════════════════════════ */

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    animation: modalBgIn .25s ease;
}
@keyframes modalBgIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to   { opacity: 1; backdrop-filter: blur(4px); }
}
.modal-box {
    background: var(--surface);
    border-radius: var(--r3);
    box-shadow: var(--shadow-lg);
    width: 95%; max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    animation: modalSlideIn .3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-box::-webkit-scrollbar       { width: 5px; }
.modal-box::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; }
.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: var(--bg2); border: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3); font-weight: 700;
    transition: background .15s, transform .15s;
}
.modal-close:hover { background: var(--border); transform: rotate(90deg); }
.modal-title {
    font-size: 18px; font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-1);
    font-family: var(--font);
}

/* New modal structure (modal > modal-hd + modal-bd) */
.modal {
    background: var(--surface);
    border-radius: var(--r3);
    box-shadow: var(--shadow-lg);
    width: 95%; max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn .3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal::-webkit-scrollbar       { width: 5px; }
.modal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; }
.modal-hd {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 28px 0;
}
.modal-hd .modal-title { margin-bottom: 0; }
.modal-hd .modal-close { position: static; }
.modal-bd { padding: 20px 28px 28px; }

/* ── GPS Button ── */
.btn-gps {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff; border: none;
    padding: 8px 16px; border-radius: 8px;
    font-size: 12px; font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    display: inline-flex; align-items: center; gap: 6px;
    transition: all .2s;
}
.btn-gps:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-gps:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-gps .spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
.gps-accuracy {
    font-size: 11px; color: var(--green);
    font-weight: 700; margin-top: 4px;
}
.gps-accuracy.poor { color: var(--amber); }
.gps-accuracy.bad  { color: var(--red); }

/* ── Stop Cards (Geo-Mapping) ── */
.stop-card {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all .15s var(--ease-out);
}
.stop-card:hover  { border-color: var(--blue); background: var(--blue-bg); transform: translateX(2px); }
.stop-card.active { border-color: var(--blue); background: var(--blue-bg); box-shadow: 0 0 0 2px rgba(59, 130, 246, .15); }
.stop-card-name   { font-weight: 700; font-size: 13px; }
.stop-card-meta   { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.stop-card-coords { font-size: 11px; color: var(--teal); font-family: var(--mono); margin-top: 3px; }

/* ── Trip Builder ── */
.trip-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}
.trip-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--navy);
    color: #fff;
    font-size: 13px; font-weight: 700;
    font-family: var(--font);
}
.trip-header .badge { font-size: 10px; }
.trip-body { padding: 12px; }

.trip-stops-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.trip-stops-table th {
    text-align: left; padding: 6px 8px;
    font-size: 10px; font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-family: var(--font);
}
.trip-stops-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.trip-stops-table input,
.trip-stops-table select {
    font-size: 12px; padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-family: var(--font-body);
    outline: none; width: 100%;
    transition: border-color .2s, box-shadow .2s;
}
.trip-stops-table input:focus,
.trip-stops-table select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, .1);
}
.trip-stops-table .stop-name-input { min-width: 130px; }
.trip-stops-table .time-input      { width: 80px; min-width: 70px; }
.trip-stops-table .km-input        { width: 60px; min-width: 50px; }
.trip-stops-table .type-select     { width: 100px; min-width: 90px; }
.trip-stops-table .halt-dur {
    font-size: 11px; font-weight: 700;
    color: var(--teal); white-space: nowrap;
    min-width: 50px;
}
.trip-stops-table .row-remove {
    width: 24px; height: 24px;
    border: none; background: var(--red-bg);
    color: var(--red); border-radius: 50%;
    cursor: pointer; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.trip-stops-table .row-remove:hover { background: var(--red); color: #fff; }

.trip-summary {
    display: flex; gap: 16px;
    padding: 10px 16px;
    font-size: 12px; font-weight: 600;
    color: var(--text-2);
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .6);
}
.trip-summary span { color: var(--teal); font-weight: 800; }
.trip-saved-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--green); font-weight: 700;
    padding: 3px 10px;
    background: var(--green-bg);
    border: 1px solid var(--green-bdr);
    border-radius: 20px;
}

/* ── Trip Choice Popup ── */
.trip-choice-popup {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    text-align: center;
}
.trip-choice-popup .modal-title { font-size: 15px; margin-bottom: 14px; }
.trip-choice-btn {
    display: block; width: 100%;
    padding: 12px 16px; margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-family: var(--font);
    font-size: 13px; font-weight: 600;
    cursor: pointer; text-align: left;
    transition: all .15s var(--ease-out);
}
.trip-choice-btn:hover { border-color: var(--blue); background: var(--blue-bg); transform: translateX(2px); }
.trip-choice-btn .trip-choice-desc {
    font-size: 11px; color: var(--text-3);
    font-weight: 400; margin-top: 2px;
}
.route-modal-wide { max-width: 900px; }

/* ── Toast Notification ── */
#toast-container {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 9999;
    display: flex; flex-direction: column; gap: 12px;
}
.toast {
    background: var(--surface);
    border-left: 4px solid var(--red);
    box-shadow: var(--shadow-lg);
    padding: 16px; border-radius: 8px;
    width: 320px;
    display: flex; gap: 12px;
    transform: translateX(120%);
    transition: transform 0.4s var(--ease-spring);
}
.toast.show { transform: translateX(0); }
.toast-icon { font-size: 20px; }
.toast-body { flex: 1; }
.toast-title {
    font-size: 13px; font-weight: 800;
    color: var(--text-1); margin-bottom: 4px;
    font-family: var(--font);
}
.toast-desc {
    font-size: 11.5px;
    color: var(--text-3);
    line-height: 1.4;
}
