/* ============================================================
   TRAMWAY CASABLANCA - styles
   ============================================================ */
:root {
    --blue-1: #1e3c72;
    --blue-2: #2a5298;
    --orange: #ff9800;
    --green: #4caf50;
    --red: #f44336;
    --text: #263042;
    --muted: #6b7686;
    --line: #e3e7ee;
    --sidebar-w: 400px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
html, body { height: 100%; }
body { overflow: hidden; color: var(--text); background: #eef1f6; }
#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- Sidebar ---------- */
#sidebar { width: var(--sidebar-w); background: #fff; box-shadow: 2px 0 12px rgba(0,0,0,.12); display: flex; flex-direction: column; z-index: 1000; min-height: 0; }
#sidebar-header { background: linear-gradient(135deg, var(--blue-1), var(--blue-2)); color: #fff; padding: 18px 20px; display: flex; align-items: center; gap: 12px; }
#sidebar-header .titles { flex: 1; min-width: 0; }
#sidebar-header h1 { font-size: 20px; margin-bottom: 3px; }
#sidebar-header p { font-size: 13px; opacity: .9; }
#sheet-toggle { display: none; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); color: #fff; width: 36px; height: 36px; border-radius: 10px; font-size: 16px; cursor: pointer; }
#sidebar-content { flex: 1; overflow-y: auto; padding: 18px 20px; overscroll-behavior: contain; }
#sidebar-footer { padding: 8px 14px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; background: #fafbfd; }
#sidebar-footer a { color: var(--blue-2); text-decoration: none; font-weight: 600; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.form-group input, .form-group select {
    width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px;
    font-size: 14px; background: #fff; color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--blue-2); }

.od-block { position: relative; }
.od-block .swap {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 5;
    width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: #fff;
    color: var(--blue-2); font-size: 16px; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.12);
    transition: transform .25s, background .15s;
}
.od-block .swap:hover { background: #f0f4ff; transform: translateY(-50%) rotate(180deg); }
.od-block input { padding-right: 52px; }

.autocomplete-wrapper { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 2px solid var(--line); border-top: none; border-radius: 0 0 8px 8px; max-height: 240px; overflow-y: auto; display: none; z-index: 100; box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.autocomplete-list.show { display: block; }
.autocomplete-item { padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f0f2f6; display: flex; align-items: center; gap: 8px; }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: #eef3ff; }
.autocomplete-item .station-name { font-weight: 600; flex: 1; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1.6; }

.btn { width: 100%; padding: 12px; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.btn-primary { background: linear-gradient(135deg, var(--blue-1), var(--blue-2)); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(30,60,114,.3); }
.btn-secondary { background: #f0f2f6; color: var(--text); margin-top: 8px; }
.btn-secondary:hover { background: #e3e7ee; }
.btn-success { background: linear-gradient(135deg, #11998e, #38ef7d); color: #fff; margin-top: 8px; }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(17,153,142,.3); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { margin-top: 8px; }
.btn:focus-visible, .swap:focus-visible, #sheet-toggle:focus-visible { outline: 3px solid #8fb3ff; outline-offset: 2px; }

/* ---------- Résultat ---------- */
#result { margin-top: 18px; display: none; }
#result.show { display: block; }
.result-header { background: #e8f5e9; padding: 14px; border-radius: 10px; margin-bottom: 12px; }
.result-header.error { background: #ffebee; }
.result-header h3 { color: #2e7d32; font-size: 15px; margin-bottom: 8px; }
.result-header.error h3 { color: #c62828; }
.result-stats { display: flex; gap: 14px; font-size: 12.5px; color: #4a5568; flex-wrap: wrap; }
.route-pills { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }

.step { background: #f8f9fc; padding: 12px; border-radius: 10px; margin-bottom: 10px; border-left: 5px solid #ccc; }
.step.ride { border-left-color: var(--c, #2196f3); }
.step.transfer { border-left-color: var(--orange); background: #fff6e8; }
.step-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.step-title .zoom { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 11.5px; padding: 3px 8px; cursor: pointer; color: var(--blue-2); font-weight: 600; }
.step-title .zoom:hover { background: #eef3ff; }
.step-detail { font-size: 12.5px; color: #596579; margin-top: 6px; line-height: 1.5; }
.stations-list { margin-top: 8px; font-size: 12px; max-height: 190px; overflow-y: auto; padding: 2px 0 2px 4px; position: relative; }
.station-item { padding: 3px 0 3px 18px; display: flex; align-items: center; position: relative; cursor: pointer; border-radius: 4px; }
.station-item:hover { background: rgba(30,60,114,.07); }
.station-item::before { content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 3px; background: var(--c, #bbb); }
.station-item:first-child::before { top: 50%; }
.station-item:last-child::before { bottom: 50%; }
.station-dot { position: absolute; left: 0; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 3px solid var(--c, #999); z-index: 1; }
.station-item.start .station-dot { border-color: var(--green); background: var(--green); }
.station-item.end .station-dot { border-color: var(--red); background: var(--red); }


/* ---------- Carte ---------- */
#map { flex: 1; z-index: 1; min-width: 0; background: #dfe5ee; }
#map3d { flex: 1; z-index: 1; min-width: 0; background: #dfe5ee; display: none; position: relative; }
.btn-whatsapp { background: #25d366; color: #fff; margin-top: 8px; }
.btn-whatsapp:hover { background: #1ebe5a; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(37,211,102,.35); }

/* Stations */
.st-icon { background: transparent !important; border: none !important; }
.st { position: relative; width: 0; height: 0; }
.st .dot { position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #333; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: transform .15s, opacity .2s; }
.st:hover .dot { transform: scale(1.35); }
.st .lbl { position: absolute; left: 11px; top: -9px; background: rgba(255,255,255,.95); padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; color: #333; white-space: nowrap; border: 1px solid #ddd; box-shadow: 0 1px 3px rgba(0,0,0,.2); pointer-events: none; transition: opacity .2s; }
.st.corr .dot { left: -12px; top: -12px; width: 24px; height: 24px; background: var(--orange); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(255,152,0,.6); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; line-height: 1; }
.st.corr .dot::after { content: '\21C4'; }
.st.corr .lbl { left: 16px; background: var(--orange); color: #fff; border-color: var(--orange); }
.zoom-lo .st .lbl { display: none; }
.zoom-lo .st.corr .lbl { display: none; }
.zoom-lo .st.on-route.key .lbl { display: block; }   /* de loin : seulement départ / arrivée / correspondances */
.zoom-lo .st.on-route:not(.key) .lbl { display: none; }
.zoom-lo .st.on-route.key.corr .lbl { display: block; }

/* Mode "itinéraire actif" */
.route-on .st:not(.on-route) .dot { opacity: .35; transform: scale(.8); }
.route-on .st:not(.on-route) .lbl { display: none; }
.route-on .st.on-route .dot { border-color: var(--c, #333); border-width: 3px; width: 14px; height: 14px; left: -7px; top: -7px; }
.route-on .st.on-route.corr .dot { border-color: #fff; width: 24px; height: 24px; left: -12px; top: -12px; }
.route-on .st.on-route .lbl { border-color: var(--c, #ddd); font-weight: 700; z-index: 10; }

.route-flow { animation: flow 1.1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -15; } }
@media (prefers-reduced-motion: reduce) { .route-flow { animation: none; } .correspondance-pulse { animation: none; } }

.pin-icon { background: transparent !important; border: none !important; }
.pin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 800; transform: translate(-14px,-14px); }
.pin.start { background: var(--green); }
.pin.end { background: var(--red); }
.pin-tag { color: #222; position: absolute; left: 18px; top: -26px; background: #fff; border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.3); white-space: nowrap; }
.walk-icon { background: transparent !important; border: none !important; }
.walk { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid var(--orange); display: flex; align-items: center; justify-content: center; font-size: 14px; transform: translate(-13px,-13px); box-shadow: 0 2px 6px rgba(0,0,0,.3); }

/* Popup */
.leaflet-popup-content { margin: 10px; }
.pop { min-width: 220px; }
.pop-head { color: #fff; padding: 8px 12px; margin: -10px -10px 10px; border-radius: 4px 4px 0 0; font-weight: 700; font-size: 13px; background: var(--blue-1); }
.pop-head.corr { background: var(--orange); }
.pop-lines { margin-bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.pop-corr { margin-top: 8px; padding-top: 8px; border-top: 1px solid #eee; font-size: 11.5px; color: #555; }
.pop-corr b.t { display: block; color: var(--orange); margin-bottom: 4px; }
.pop-actions { display: flex; gap: 6px; margin-top: 10px; }
.pop-actions button { flex: 1; border: none; border-radius: 6px; padding: 7px 4px; font-size: 12px; font-weight: 700; color: #fff; cursor: pointer; }
.pop-actions .a-start { background: var(--green); }
.pop-actions .a-end { background: var(--red); }
.pop-gps { font-size: 10px; color: #999; margin-top: 8px; }

/* Légende */
#legend { position: absolute; bottom: 20px; right: 20px; background: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.18); z-index: 900; font-size: 12px; max-width: 300px; }
#legend h4 { margin-bottom: 8px; font-size: 13px; }
#legend .legend-title { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0; user-select: none; }
#legend .legend-title::after { content: '\2212'; font-size: 16px; color: var(--muted); }
#legend.collapsed .legend-title::after { content: '+'; }
#legend .legend-body { margin-top: 8px; }
#legend.collapsed .legend-body { display: none; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; cursor: pointer; user-select: none; padding: 2px 4px; border-radius: 4px; }
.legend-item:hover { background: #f0f4ff; }
.legend-item.off { opacity: .4; text-decoration: line-through; }
.legend-color { width: 22px; height: 5px; border-radius: 3px; flex-shrink: 0; }
.legend-hint { font-size: 10px; color: var(--muted); margin-top: 4px; }
.legend-sub { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.legend-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 11px; }
.l-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid #333; }
.l-corr { width: 18px; height: 18px; border-radius: 50%; background: var(--orange); border: 2px solid #fff; box-shadow: 0 0 0 1px #ddd; color: #fff; font-size: 10px; text-align: center; line-height: 14px; }

/* Panneau auteur */
#author-panel { position: absolute; top: 20px; right: 20px; background: linear-gradient(135deg, rgba(30,60,114,.96), rgba(42,82,152,.96)); color: #fff; padding: 18px 22px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 900; min-width: 340px; backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.15); transition: transform .3s, box-shadow .3s; }
#author-panel:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
#author-panel .author-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.2); }
#author-panel .author-avatar { width: 50px; height: 50px; border-radius: 50%; background: linear-gradient(135deg, #38ef7d, #11998e); display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; border: 2px solid rgba(255,255,255,.3); flex-shrink: 0; }
#author-panel .author-info h3 { font-size: 14px; margin: 0 0 3px; font-weight: 700; letter-spacing: .3px; }
#author-panel .author-info p { font-size: 9.5px; color: rgba(255,255,255,.85); line-height: 1.5; }
#author-panel .author-info p:first-of-type { font-weight: 600; color: #38ef7d; margin-bottom: 3px; }
#author-panel .author-location { font-size: 11px; color: rgba(255,255,255,.8); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
#author-panel .social-links { display: flex; gap: 8px; flex-wrap: wrap; }
#author-panel .social-links a { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; background: rgba(255,255,255,.12); color: #fff; text-decoration: none; font-size: 15px; transition: transform .2s, background .2s; border: 1px solid rgba(255,255,255,.15); }
#author-panel .social-links a:hover { transform: translateY(-2px) scale(1.1); }
#author-panel .social-links a.linkedin:hover { background: #0077b5; border-color: #0077b5; }
#author-panel .social-links a.github:hover { background: #333; border-color: #333; }
#author-panel .social-links a.twitter:hover { background: #000; border-color: #000; }
#author-panel .social-links a.website:hover { background: #38ef7d; border-color: #38ef7d; color: var(--blue-1); }
#author-panel .social-links a.email:hover { background: #ea4335; border-color: #ea4335; }
#author-panel .social-links a.phone:hover { background: #25d366; border-color: #25d366; }
#author-panel .author-close { position: absolute; top: 8px; right: 10px; background: rgba(255,255,255,.15); border: none; color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: background .2s, transform .2s; }
#author-panel .author-close:hover { background: rgba(255,255,255,.35); transform: rotate(90deg); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 5000; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1200px) { #author-panel { display: none; } }

/* ---------- Mobile : panneau en bas ---------- */
@media (max-width: 820px) {
    #app { flex-direction: column-reverse; }
    #sidebar { width: 100%; height: 48dvh; height: 48vh; box-shadow: 0 -4px 14px rgba(0,0,0,.2); border-radius: 16px 16px 0 0; transition: height .25s; }
    #sidebar.collapsed { height: 66px; }
    #sidebar.collapsed #sidebar-content, #sidebar.collapsed #sidebar-footer { display: none; }
    #sidebar-header { padding: 12px 16px; border-radius: 16px 16px 0 0; }
    #sidebar-header h1 { font-size: 17px; }
    #sidebar-header p { display: none; }
    #sheet-toggle { display: block; }
    #sidebar-content { padding: 14px 16px; }
    #map, #map3d { flex: 1; }
    #legend { display: none; }
    #toast { bottom: 80px; }
}
