/* ============================================================================
   CleverGo – professional map editor styles (dashboard Map page)
   Uses Fluent design tokens when present, with light fallbacks.
   ========================================================================== */

.mp-root {
    --mp-bg: var(--neutral-layer-1, #ffffff);
    --mp-bg-2: var(--neutral-layer-2, #f5f6f8);
    --mp-fg: var(--neutral-foreground-rest, #1f2430);
    --mp-muted: var(--neutral-foreground-hint, #6b7280);
    --mp-border: var(--neutral-stroke-rest, #dfe3e8);
    --mp-accent: var(--accent-fill-rest, #0f6cbd);
    --mp-accent-fg: var(--foreground-on-accent-rest, #ffffff);
    --mp-danger: #d13438;
    --mp-ok: #2e7d32;
    --mp-warn: #f5a524;
    --mp-radius: 12px;
    --mp-shadow: 0 6px 24px rgba(0,0,0,.18);

    position: relative;
    height: calc(100vh - var(--mp-top-offset, 120px));
    min-height: 520px;
    border-radius: var(--mp-radius);
    overflow: hidden;
    border: 1px solid var(--mp-border);
    color: var(--mp-fg);
}

.mp-map { position: absolute; inset: 0; z-index: 1; background: #e9edf1; }
.mp-map.mp-crosshair, .mp-map.mp-crosshair .leaflet-interactive, .mp-map.mp-crosshair.leaflet-grab { cursor: crosshair !important; }

/* ── Side panel ───────────────────────────────────────────────────────────── */
.mp-panel {
    position: absolute; z-index: 1000; top: 12px; left: 12px; bottom: 12px; width: 372px;
    display: flex; flex-direction: column;
    background: var(--mp-bg); border: 1px solid var(--mp-border); border-radius: var(--mp-radius);
    box-shadow: var(--mp-shadow); overflow: hidden;
    transition: transform .22s ease, opacity .22s ease;
}
.mp-panel.mp-collapsed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }

.mp-toggle {
    position: absolute; z-index: 1001; top: 12px; left: 12px;
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--mp-border);
    background: var(--mp-bg); color: var(--mp-fg); box-shadow: var(--mp-shadow); cursor: pointer;
    display: none; align-items: center; justify-content: center; font-size: 16px;
}
.mp-toggle.mp-visible { display: flex; }

.mp-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--mp-border); }
.mp-head h2 { font-size: 15px; font-weight: 700; margin: 0; flex: 1; }
.mp-head .mp-sub { font-size: 12px; color: var(--mp-muted); font-weight: 400; }

.mp-tabs { display: flex; gap: 4px; padding: 8px 10px 0; border-bottom: 1px solid var(--mp-border); }
.mp-tab {
    flex: 1; border: 0; background: transparent; color: var(--mp-muted); padding: 8px 6px 10px; font-weight: 600; font-size: 13px;
    border-bottom: 2px solid transparent; cursor: pointer;
}
.mp-tab.mp-active { color: var(--mp-accent); border-bottom-color: var(--mp-accent); }
.mp-tab .mp-count { background: var(--mp-bg-2); color: var(--mp-muted); border-radius: 10px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }

.mp-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.mp-foot { padding: 10px 14px; border-top: 1px solid var(--mp-border); display: flex; gap: 8px; justify-content: flex-end; background: var(--mp-bg); }

/* ── Controls ─────────────────────────────────────────────────────────────── */
.mp-input, .mp-select {
    width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--mp-border);
    background: var(--mp-bg); color: var(--mp-fg); font-size: 14px; outline: none;
}
.mp-input:focus, .mp-select:focus { border-color: var(--mp-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mp-accent) 25%, transparent); }
.mp-label { display: block; font-size: 12px; font-weight: 600; color: var(--mp-muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.mp-label:first-child { margin-top: 0; }

.mp-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 7px 12px; border-radius: 8px; border: 1px solid var(--mp-border);
    background: var(--mp-bg); color: var(--mp-fg); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.mp-btn:hover:not(:disabled) { background: var(--mp-bg-2); }
.mp-btn:disabled { opacity: .45; cursor: not-allowed; }
.mp-btn.mp-primary { background: var(--mp-accent); border-color: var(--mp-accent); color: var(--mp-accent-fg); }
.mp-btn.mp-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--mp-accent); }
.mp-btn.mp-danger { color: var(--mp-danger); border-color: color-mix(in srgb, var(--mp-danger) 40%, var(--mp-border)); }
.mp-btn.mp-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--mp-danger) 10%, var(--mp-bg)); }
.mp-btn.mp-icon { padding: 7px 9px; }
.mp-btn.mp-sm { padding: 4px 8px; font-size: 12px; }
.mp-btn.mp-on { background: color-mix(in srgb, var(--mp-accent) 14%, var(--mp-bg)); border-color: var(--mp-accent); color: var(--mp-accent); }

.mp-row { display: flex; align-items: center; gap: 8px; }
.mp-row.mp-wrap { flex-wrap: wrap; }
.mp-grow { flex: 1; min-width: 0; }
.mp-space { height: 10px; }

.mp-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.mp-swatch {
    width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--mp-bg); box-shadow: 0 0 0 1px var(--mp-border); cursor: pointer; padding: 0;
}
.mp-swatch.mp-active { box-shadow: 0 0 0 2px var(--mp-accent); }
.mp-color-input { width: 34px; height: 28px; padding: 0; border: 1px solid var(--mp-border); border-radius: 6px; background: transparent; cursor: pointer; }

.mp-range { width: 100%; accent-color: var(--mp-accent); }
.mp-range-val { min-width: 38px; text-align: right; font-size: 12px; color: var(--mp-muted); font-variant-numeric: tabular-nums; }

.mp-preview { height: 34px; border-radius: 8px; background: var(--mp-bg-2); display: flex; align-items: center; padding: 0 12px; }
.mp-preview span { display: block; width: 100%; border-radius: 4px; }

/* ── Lists ────────────────────────────────────────────────────────────────── */
.mp-list { list-style: none; margin: 8px 0 0; padding: 0; }
.mp-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 10px; cursor: pointer;
    border: 1px solid transparent;
}
.mp-item:hover { background: var(--mp-bg-2); }
.mp-item.mp-selected { background: color-mix(in srgb, var(--mp-accent) 10%, var(--mp-bg)); border-color: color-mix(in srgb, var(--mp-accent) 45%, var(--mp-border)); }
.mp-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--mp-bg), 0 0 0 3px var(--mp-border); }
.mp-item-main { flex: 1; min-width: 0; }
.mp-item-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-item-meta { font-size: 12px; color: var(--mp-muted); }
.mp-item-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.mp-item:hover .mp-item-actions, .mp-item.mp-selected .mp-item-actions { opacity: 1; }
.mp-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
    background: var(--mp-bg-2); border: 1px solid var(--mp-border); color: var(--mp-fg);
}
.mp-chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.mp-chip.mp-warn { color: #8a5a00; background: color-mix(in srgb, var(--mp-warn) 22%, var(--mp-bg)); border-color: color-mix(in srgb, var(--mp-warn) 50%, var(--mp-border)); }
.mp-empty { text-align: center; color: var(--mp-muted); padding: 28px 8px; font-size: 13px; }

.mp-check { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.mp-check:hover { background: var(--mp-bg-2); }
.mp-check input { width: 16px; height: 16px; accent-color: var(--mp-accent); flex: none; }
.mp-checklist { max-height: 260px; overflow-y: auto; border: 1px solid var(--mp-border); border-radius: 10px; padding: 4px; }

.mp-box { background: var(--mp-bg-2); border: 1px solid var(--mp-border); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.mp-box.mp-info { border-color: color-mix(in srgb, var(--mp-accent) 40%, var(--mp-border)); background: color-mix(in srgb, var(--mp-accent) 7%, var(--mp-bg)); }
.mp-kbd { font-family: ui-monospace, Consolas, monospace; font-size: 11px; padding: 1px 5px; border: 1px solid var(--mp-border); border-bottom-width: 2px; border-radius: 4px; background: var(--mp-bg); }
.mp-stat { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mp-stat small { display: block; font-size: 11px; font-weight: 600; color: var(--mp-muted); text-transform: uppercase; letter-spacing: .03em; }

.mp-error { color: var(--mp-danger); font-size: 13px; margin-top: 8px; }

/* ── Floating bits on the map ─────────────────────────────────────────────── */
.mp-toast {
    position: absolute; z-index: 1100; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: #1f2430; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--mp-shadow);
}
.mp-toast.mp-bad { background: var(--mp-danger); }
.mp-hint {
    position: absolute; z-index: 1000; top: 14px; left: 50%; transform: translateX(-50%);
    background: var(--mp-bg); color: var(--mp-fg); border: 1px solid var(--mp-accent); border-radius: 999px;
    padding: 7px 16px; font-size: 13px; font-weight: 600; box-shadow: var(--mp-shadow); white-space: nowrap;
}
.mp-layers {
    position: absolute; z-index: 1000; top: 12px; right: 58px; display: flex; gap: 6px;
}

/* modal confirm */
.mp-modal-back { position: absolute; inset: 0; z-index: 1200; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; }
.mp-modal { width: min(420px, 92%); background: var(--mp-bg); border-radius: var(--mp-radius); padding: 18px; box-shadow: var(--mp-shadow); border: 1px solid var(--mp-border); }
.mp-modal h3 { font-size: 16px; margin: 0 0 8px; }
.mp-modal p { font-size: 14px; color: var(--mp-muted); margin: 0 0 16px; }
.mp-modal .mp-row { justify-content: flex-end; }

/* ── Leaflet overlays: stops ──────────────────────────────────────────────── */
.mp-stop-wrap, .mp-vertex-wrap, .mp-endpoint-wrap, .mp-bus-wrap { background: transparent !important; border: 0 !important; }

.mp-stop { position: relative; width: 16px; height: 16px; --mp-stop: #2e7d32; }
.mp-stop-dot {
    position: absolute; inset: 0; border-radius: 50%; background: var(--mp-stop); border: 2.5px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.45); box-sizing: border-box; transition: transform .12s;
}
.mp-stop:hover .mp-stop-dot { transform: scale(1.25); }
.mp-stop-label {
    position: absolute; left: 20px; top: -4px; display: none; white-space: nowrap; font: 600 11px/1.2 'Segoe UI', system-ui, sans-serif;
    background: rgba(255,255,255,.92); color: #1f2430; padding: 2px 6px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.25); pointer-events: none;
}
.mp-labels-on .mp-stop-label { display: block; }

.mp-stop-ok { --mp-stop: #2e7d32; }
.mp-stop-free .mp-stop-dot { background: #fff; border-color: var(--mp-warn); border-width: 3px; }
.mp-stop-dim { opacity: .35; }
.mp-stop-dim .mp-stop-dot { background: #9aa3ad; }
.mp-stop-focus .mp-stop-dot { background: var(--mp-stop); }
.mp-stop-idle .mp-stop-dot { background: #fff; border-color: #6b7280; }
.mp-stop-picked .mp-stop-dot { background: var(--mp-stop); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mp-stop) 35%, transparent), 0 1px 4px rgba(0,0,0,.45); transform: scale(1.2); }
.mp-stop-selected .mp-stop-dot { border-color: #0f6cbd; box-shadow: 0 0 0 4px rgba(15,108,189,.35), 0 1px 4px rgba(0,0,0,.45); transform: scale(1.3); }
.mp-stop-selected .mp-stop-label { display: block; }
.mp-stop-draft .mp-stop-dot { background: var(--mp-warn); border-color: #fff; animation: mp-pulse 1.2s ease-out infinite; }
@keyframes mp-pulse { 0% { box-shadow: 0 0 0 0 rgba(245,165,36,.65); } 100% { box-shadow: 0 0 0 14px rgba(245,165,36,0); } }

/* ── Leaflet overlays: line endpoints, vertices, buses ────────────────────── */
.mp-endpoint {
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center; font: 700 11px/1 'Segoe UI', system-ui, sans-serif;
}
.mp-vertex { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--mp-line, #1E90FF); box-shadow: 0 1px 3px rgba(0,0,0,.4); box-sizing: border-box; cursor: grab; }
.mp-vertex-start { background: #2e7d32; border-color: #fff; width: 18px; height: 18px; margin: -2px 0 0 -2px; }
.mp-vertex-end { background: #d13438; border-color: #fff; width: 18px; height: 18px; margin: -2px 0 0 -2px; }

.mp-bus { display: flex; flex-direction: column; align-items: center; }
.mp-bus-plate { background: rgba(44,62,80,.85); color: #ecf0f1; padding: 2px 8px; border-radius: 10px; font: 600 11px/1.3 'Segoe UI', system-ui, sans-serif; margin-bottom: 3px; white-space: nowrap; }
.mp-bus-icon { background: #3498db; border-radius: 50%; padding: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.35); display: flex; border: 2px solid #fff; }
.mp-bus-icon img { width: 20px; height: 20px; }

.leaflet-tooltip.mp-tooltip { font: 600 12px 'Segoe UI', system-ui, sans-serif; border-radius: 6px; padding: 3px 8px; }
.mp-map .leaflet-control-attribution { font-size: 10px; }

@media (max-width: 760px) {
    .mp-panel { width: calc(100% - 24px); bottom: auto; max-height: 62%; }
    .mp-layers { display: none; }
}

/* Arabic / mixed-direction names render in their natural order */
.mp-stop-label, .leaflet-tooltip.mp-tooltip { unicode-bidi: plaintext; }
