/* ═══════════════════════════════════════════════════
   Disney Map — Styles standalone
   Dark theme émeraude (identique à Shiftr v7)
═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600;700&display=swap');

/* ── Variables dark ── */
:root {
  --bg:        #0a0a0b;
  --bg-soft:   #0f1011;
  --surface:   #131416;
  --surface-2: #181a1d;
  --surface-3: #1f2226;
  --line:      #23262b;
  --line-2:    #2c3036;
  --line-3:    #3a3f47;
  --fg:        #f4f5f7;
  --fg-2:      #c8ccd1;
  --fg-3:      #8a9099;
  --fg-4:      #5a6068;
  --acc:       oklch(72% 0.16 156);
  --acc-2:     oklch(78% 0.16 156);
  --acc-soft:  oklch(72% 0.16 156 / .12);
  --acc-line:  oklch(72% 0.16 156 / .28);
  --warn:      oklch(78% 0.13 75);
  --crit:      oklch(70% 0.18 25);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --font-ui:   'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --t: 180ms cubic-bezier(.2,.7,.2,1);
  /* Alias Shiftr compat */
  --card:        var(--surface);
  --card-alt:    var(--surface-2);
  --text:        var(--fg);
  --muted:       var(--fg-3);
  --accent:      var(--acc);
  --line-strong: var(--line-2);
  --topbar-h:    52px;
}

[data-theme="light"] {
  --bg:        #fafaf9;
  --bg-soft:   #f4f4f3;
  --surface:   #ffffff;
  --surface-2: #f7f7f6;
  --surface-3: #efefee;
  --line:      #e7e7e5;
  --line-2:    #dcdcd9;
  --line-3:    #c2c2bf;
  --fg:        #0e0f10;
  --fg-2:      #2a2c2f;
  --fg-3:      #585b60;
  --fg-4:      #8a8d92;
  --acc:       oklch(55% 0.14 156);
  --acc-2:     oklch(48% 0.14 156);
  --acc-soft:  oklch(55% 0.14 156 / .12);
  --acc-line:  oklch(55% 0.14 156 / .25);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; color-scheme: dark; }
[data-theme="light"] html { color-scheme: light; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

/* ── Topbar ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(10,10,11,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2rem;
  z-index: 2000;
}
.topbar-brand {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -.03em;
  color: var(--acc);
}
.topbar-brand span { color: var(--fg-3); font-size: .75rem; font-weight: 500; margin-left: .4rem; letter-spacing: 0; }
.top-actions { display: flex; align-items: center; gap: .5rem; }

/* ── Buttons ── */
.btn, .btn-g, .btn-sm, .icon-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: .8rem; font-weight: 700; padding: .38rem .75rem;
  cursor: pointer; transition: all var(--t); white-space: nowrap; line-height: 1.4;
}
.btn { background: var(--acc); color: #000; border-color: var(--acc); }
.btn:hover { background: var(--acc-2); border-color: var(--acc-2); }
.btn-g { background: var(--surface-2); color: var(--fg); border-color: var(--line-2); }
.btn-g:hover { border-color: var(--acc); color: var(--acc); }
.btn-sm { font-size: .74rem; padding: .28rem .55rem; }
.btn-danger { background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.3); border-radius: var(--r-sm); font-size: .74rem; font-weight: 700; padding: .28rem .55rem; }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.icon-btn { background: var(--surface-2); border: 1px solid var(--line); color: var(--fg-3); padding: .32rem .45rem; }
.icon-btn:hover { border-color: var(--acc); color: var(--acc); }

/* ── Main layout ── */
.main { padding-top: var(--topbar-h); height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; overflow: hidden; }

/* ── Map layout ── */
#map-wrap {
  display: flex;
  gap: .75rem;
  height: calc(100vh - var(--topbar-h) - 1rem);
  padding: .5rem .75rem .5rem .75rem;
}
#map-panel {
  width: 290px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: .5rem;
  overflow-y: auto;
}
#map-container {
  flex: 1;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
  position: relative;
}
#map { width: 100%; height: 100%; }

/* Fullscreen */
#map-wrap:fullscreen, #map-wrap:-webkit-full-screen { height: 100vh; border-radius: 0; padding: 0; }
#map-wrap:fullscreen #map-container, #map-wrap:-webkit-full-screen #map-container { border-radius: 0; height: 100vh; }

/* ── Panel components ── */
.map-tabs { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; }
.map-tab  { flex: 1; padding: .4rem; text-align: center; border-radius: 6px; font-size: .78rem; font-weight: 700; cursor: pointer; border: none; background: none; color: var(--fg-3); transition: all .15s; }
.map-tab.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 4px rgba(0,0,0,.2); }

.msec { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-3); margin: .5rem 0 .3rem; }
.mcard { background: var(--surface-2); border-radius: 8px; border: 1px solid var(--line); padding: .4rem .55rem; margin-bottom: .25rem; display: flex; align-items: center; gap: .4rem; }
.mcard-name { flex: 1; font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-sub  { font-size: .68rem; color: var(--fg-3); }
.tag-on  { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: #6ee7b7; }
.tag-bs  { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: #fde68a; }
.tag-bus { font-size: .65rem; font-weight: 800; text-transform: uppercase; color: #93c5fd; }

.minput  { background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: .35rem .5rem; color: var(--fg); font-size: .82rem; width: 100%; }
.mselect { background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: .35rem .5rem; color: var(--fg); font-size: .82rem; width: 100%; }

.route-result { background: var(--surface-2); border-radius: 8px; border: 1px solid var(--acc); padding: .6rem .7rem; margin-top: .4rem; }
.route-seg { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; border-bottom: 1px solid var(--line); font-size: .78rem; }
.route-seg:last-child { border: none; }
.route-total { font-size: .8rem; font-weight: 700; margin-bottom: .3rem; }
.route-info  { font-size: .73rem; color: var(--fg-3); margin-bottom: .35rem; }

.zf-bar { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .4rem; }
.zf-btn { font-size: .63rem; font-weight: 700; padding: .18rem .38rem; border-radius: 5px; border: 1px solid var(--line); background: var(--bg); color: var(--fg-3); cursor: pointer; white-space: nowrap; line-height: 1.4; }
.zf-btn.active { background: var(--acc); color: #000; border-color: var(--acc); }

.stop-row { display: flex; align-items: center; gap: .3rem; margin-bottom: .25rem; }
.stop-icon { font-size: .8rem; flex-shrink: 0; width: 18px; text-align: center; }
.stop-rm { background: none; border: 1px solid var(--line); border-radius: 4px; color: var(--fg-3); cursor: pointer; font-size: .7rem; padding: .15rem .35rem; flex-shrink: 0; line-height: 1; }
.stop-rm:hover { border-color: #f87171; color: #f87171; }
.btn-gps { background: none; border: 1px solid var(--line); border-radius: 4px; color: var(--fg-3); cursor: pointer; font-size: .72rem; padding: .15rem .3rem; flex-shrink: 0; line-height: 1; transition: border-color .15s, color .15s; }
.btn-gps:hover { border-color: #60a5fa; color: #60a5fa; }
.btn-gps.active { border-color: #4ade80; color: #4ade80; background: rgba(74,222,128,.1); }
.gps-label { flex: 1; font-size: .78rem; color: #4ade80; background: rgba(74,222,128,.08); border: 1px solid rgba(74,222,128,.3); border-radius: 6px; padding: .22rem .5rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.map-ctrl-btn { position: absolute; z-index: 1001; background: rgba(15,20,35,.88); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 6px; padding: .32rem .48rem; color: var(--fg); cursor: pointer; font-size: .8rem; line-height: 1; transition: border-color .15s; }
.map-ctrl-btn:hover { border-color: var(--acc); }
.map-ctrl-btn.active { border-color: #4ade80; box-shadow: 0 0 0 1px rgba(74,222,128,.35); }
#btn-fullscreen { top: 10px; right: 10px; }
#btn-locate     { top: 44px; right: 10px; }
#btn-prefetch   { top: 78px; right: 10px; }

#map-legend { position: absolute; bottom: 10px; right: 10px; z-index: 1000; background: rgba(15,20,35,.88); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; font-size: .72rem; }
.leg-row { display: flex; align-items: center; gap: .4rem; color: var(--fg-3); margin-bottom: .12rem; }
.leg-row:last-child { margin-bottom: 0; }
.leg-toggle { cursor: pointer; user-select: none; transition: opacity .15s, color .15s; }
.leg-toggle:hover { color: var(--fg); }
.leg-row.off { opacity: .35; text-decoration: line-through; }
.ll-on  { width: 18px; height: 3px; background: #4ade80; border-radius: 2px; flex-shrink: 0; }
.ll-bs  { width: 18px; border-top: 3px dashed #fb923c; flex-shrink: 0; }
.ll-bus { width: 18px; height: 3px; background: #a78bfa; border-radius: 2px; flex-shrink: 0; }
.ll-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.leg-sep { border-top: 1px solid var(--line); margin: .25rem 0; }

.bus-stop-nav-lbl { background: rgba(15,20,35,.92)!important; border: 1px solid #a78bfa!important; border-radius: 6px!important; padding: .2rem .5rem!important; font-size: .72rem!important; color: var(--fg)!important; white-space: nowrap; pointer-events: none; line-height: 1.4!important; text-align: center!important; box-shadow: 0 2px 8px rgba(0,0,0,.6)!important; }

#nav-history { margin-top: .5rem; }
.hist-entry { display: flex; align-items: center; gap: .35rem; padding: .3rem .45rem; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); margin-bottom: .22rem; cursor: pointer; transition: border-color .15s; }
.hist-entry:hover { border-color: var(--acc); }
.hist-label { flex: 1; font-size: .74rem; color: var(--fg); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hist-meta  { font-size: .66rem; color: var(--fg-3); white-space: nowrap; flex-shrink: 0; }
.hist-rm    { background: none; border: none; color: var(--fg-3); cursor: pointer; font-size: .75rem; padding: .05rem .2rem; flex-shrink: 0; line-height: 1; }
.hist-rm:hover { color: #f87171; }

.fav-entry { display: flex; align-items: center; gap: .35rem; padding: .22rem .4rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); margin-bottom: .2rem; cursor: pointer; transition: border-color .12s; }
.fav-entry:hover { border-color: #fbbf24; }
.fav-entry-name { flex: 1; font-size: .78rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fav-star { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: .88rem; padding: .05rem .15rem; flex-shrink: 0; line-height: 1; transition: color .12s; }
.fav-star.active { color: #fbbf24; }
.fav-star:hover { color: #fbbf24; }

.route-stop-row { display: flex; align-items: center; gap: .35rem; font-size: .78rem; padding: .15rem .25rem; border-radius: 5px; cursor: pointer; transition: background .12s; }
.route-stop-row:hover { background: rgba(255,255,255,.06); }
.route-seg.clickable { cursor: pointer; }
.route-seg.clickable:hover { background: rgba(255,255,255,.05); border-radius: 4px; }

.loc-search-wrap { position: relative; margin-bottom: .4rem; }
.loc-search-wrap .minput { padding-left: 1.8rem; }
.loc-search-wrap .srch-icon { position: absolute; left: .52rem; top: 50%; transform: translateY(-50%); font-size: .75rem; pointer-events: none; color: var(--fg-3); }

@keyframes gps-pulse { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(2); opacity: 0; } }
.gps-pulse-ring { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid #3b82f6; animation: gps-pulse 1.8s ease-out infinite; position: absolute; top: -4px; left: -4px; pointer-events: none; }
.gps-dot { width: 14px; height: 14px; background: #3b82f6; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5); position: relative; }
.gps-pulse-ring.green { border-color: #4ade80; }
.gps-dot.green { background: #4ade80; }

.leaflet-container { background: #1a2235; }
.leaflet-popup-content-wrapper { background: var(--surface)!important; color: var(--fg)!important; border: 1px solid var(--line)!important; border-radius: 10px!important; box-shadow: 0 4px 20px rgba(0,0,0,.5)!important; }
.leaflet-popup-tip { background: var(--surface)!important; }
.leaflet-popup-content { margin: .6rem .85rem!important; font-size: .84rem; }
.pop-btn { display: block; width: 100%; text-align: left; padding: .3rem .6rem; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; background: var(--surface-2); font-size: .78rem; margin-top: .3rem; }
.pop-btn:hover { border-color: var(--acc); }
.pop-img  { display: block; width: 100%; max-height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); margin: .35rem 0; cursor: zoom-in; }
.pop-desc { font-size: .76rem; color: var(--fg-2); margin: .25rem 0 .1rem; line-height: 1.45; }

/* Toast flash */
#toast-wrap { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: .4rem; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 8px; padding: .5rem 1rem; font-size: .82rem; color: var(--fg); box-shadow: 0 4px 20px rgba(0,0,0,.5); animation: toast-in .18s ease; white-space: nowrap; }
.toast.ok    { border-color: var(--acc); color: var(--acc); }
.toast.error { border-color: #f87171; color: #f87171; }
.toast.info  { border-color: #60a5fa; color: #60a5fa; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Crumbs */
.crumbs { font-size: .8rem; color: var(--fg-3); display: flex; align-items: center; gap: .3rem; }
.crumbs .sep { opacity: .4; }
.crumbs strong { color: var(--fg); }

/* ── Bottom sheet mobile ── */
#sheet-handle { display: none; }

@media (max-width: 768px) {
  #map-wrap { padding: 0; gap: 0; height: calc(100vh - var(--topbar-h)); position: relative; }
  #map-container { position: absolute; inset: 0; border-radius: 0; border: none; }
  #map-panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
    width: 100%; height: 78vh; max-height: 78vh;
    background: var(--bg);
    border-top: 1px solid var(--line-2);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.45);
    padding: 0 .9rem calc(1rem + env(safe-area-inset-bottom));
    transform: translateY(calc(100% - 138px));   /* état replié : poignée + recherche visibles */
    transition: transform .28s cubic-bezier(.2,.7,.2,1);
    overflow-y: hidden;
  }
  #map-panel.open { transform: translateY(0); overflow-y: auto; }
  #sheet-handle {
    display: flex; justify-content: center;
    padding: .6rem 0 .45rem;
    position: sticky; top: 0; z-index: 2;
    background: var(--bg);
    cursor: grab; touch-action: none;
  }
  .sheet-grip { width: 44px; height: 4px; border-radius: 2px; background: var(--line-3); }
  #map-legend { bottom: calc(150px + env(safe-area-inset-bottom)); font-size: .66rem; }
}

/* ── Indicateur de chargement du réseau (routes chargées par zone) ── */
#net-status {
  position: absolute; top: .6rem; left: 50%; transform: translateX(-50%);
  z-index: 700; display: flex; align-items: center; gap: .4rem;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 999px;
  padding: .3rem .7rem; font-size: .72rem; color: var(--fg-3);
  box-shadow: 0 4px 16px rgba(0,0,0,.4); pointer-events: none;
}
#net-status .net-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--acc);
  animation: net-pulse 1s ease-in-out infinite;
}
@keyframes net-pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #net-status .net-dot { animation: none; } }
