﻿/* GeoCompare — style principal */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface2: #f5f7fa;
  --border: #dde2e9;
  --accent: #0e7490;
  --accent2: #155e75;
  --red: #dc2626;
  --amber: #b45309;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 7px;
  --header-h: 52px;
  --sidebar-w: 300px;
  --viewer-w: 400px;
}

html, body { height: 100%; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 13.5px; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── En-tête ── */
header {
  height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  position: fixed; inset: 0 0 auto 0; z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 16px; letter-spacing: -.2px; flex-shrink: 0; }
.brand img { width: 28px; height: 28px; }
#siteSelect { min-width: 0; max-width: 360px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface2); font-weight: 600; }
.spacer { flex: 1; }
.badge { font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; white-space: nowrap; }

.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius);
       background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface2); border-color: #c5ccd6; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface2); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: #fef2f2; border-color: #fecaca; }
.icon { border: none; background: transparent; cursor: pointer; border-radius: 5px; padding: 3px 6px; font-size: 12px; color: var(--muted); text-decoration: none; line-height: 1.2; }
.icon:hover { background: var(--surface2); color: var(--text); }
.icon.danger:hover { color: var(--red); background: #fef2f2; }
.icon.light { color: #e2e8f0; font-size: 18px; }
.icon.light:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ── Disposition ── */
#layout { position: fixed; top: var(--header-h); bottom: 0; left: 0; right: 0; display: grid;
          grid-template-columns: var(--sidebar-w) 1fr 0; }
#layout.with-viewer { grid-template-columns: var(--sidebar-w) 1fr var(--viewer-w); }
#map { height: 100%; min-width: 0; background: #d9dee5; }

#sidebar { background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; padding: 14px 14px 20px; display: flex; flex-direction: column; gap: 8px; }
#sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 10px; }
.side-title { display: flex; align-items: center; justify-content: space-between; }
.side-title h3 { margin: 10px 0 0; }
.site-name { font-size: 16px; font-weight: 700; }
.site-org { color: var(--muted); font-size: 12px; margin-top: 1px; }
.site-desc { color: var(--muted); margin-top: 6px; line-height: 1.4; }
.empty { color: var(--muted); font-style: italic; padding: 6px 0; line-height: 1.4; }
.warn { color: var(--amber); font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; vertical-align: middle; }

.session { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 8px 5px; background: var(--surface2); }
.session-main { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.session-main input { accent-color: var(--accent); }
.session-text { display: flex; flex-direction: column; min-width: 0; }
.session-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-text small { color: var(--muted); font-size: 12px; }
.session-actions { display: flex; flex-wrap: wrap; gap: 1px; margin: 4px 0 0 22px; }
.session-notes { margin: 4px 0 2px 22px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.check { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.legend { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.legend div { display: flex; align-items: center; gap: 6px; }
.fp-swatch { width: 16px; height: 11px; border: 1.5px solid #475569; background: rgba(71,85,105,.12); display: inline-block; transform: skewX(-12deg); margin: 0 1px; }
.side-logo { margin-top: auto; padding-top: 16px; height: 34px; object-fit: contain; opacity: .75; align-self: flex-start; }

/* ── Marqueurs ── */
.photo-marker { background: none; border: none; }
.photo-marker svg { filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.45)); overflow: visible; }
.photo-marker.selected svg { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.photo-marker.pinned svg { filter: drop-shadow(0 0 3px #facc15) drop-shadow(0 0 3px #facc15) drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.pin-bar { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.96); border: 2px solid #facc15; border-radius: 8px;
           padding: 6px 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25); max-width: min(460px, calc(100vw - 40px)); font: 12.5px system-ui, sans-serif; }
.pin-bar img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; cursor: pointer; flex-shrink: 0; }
.pin-bar span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pin-bar b { display: flex; align-items: center; gap: 6px; }
.pin-bar small { color: var(--muted); line-height: 1.3; }
.client-logo { background: rgba(255,255,255,.9); padding: 4px 6px; border-radius: 6px; }
.client-logo img { max-height: 46px; max-width: 140px; display: block; }

/* ── Visionneuse ── */
#viewer { background: var(--surface); border-left: 1px solid var(--border); overflow-y: auto; min-width: 0; }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title small { color: var(--muted); }
.viewer-img { background: #0f172a; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; }
.viewer-img img { max-width: 100%; max-height: 100%; cursor: zoom-in; display: block; }
.viewer-nav { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; color: var(--muted); }
.compare-box { padding: 4px 12px 10px; }
.compare-box h4, .meta-title { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 4px 0 6px; }
.cmp-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius);
           background: var(--surface2); cursor: pointer; text-align: left; margin-bottom: 6px; }
.cmp-row:hover { border-color: var(--accent); background: #ecfeff; }
.cmp-row.disabled { cursor: default; color: var(--muted); }
.cmp-row.pair { border-color: #facc15; background: #fefce8; }
.cmp-row.pair:hover { border-color: #eab308; background: #fef9c3; }
.compare-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; }
.compare-title h4 { margin: 0; }
#vPin.on { background: #fef9c3; border-color: #eab308; }
.legend-tip { margin-top: 4px; font-style: italic; }
.cmp-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; background: #cbd5e1; flex-shrink: 0; }
.cmp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cmp-text b { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cmp-text small { color: var(--muted); font-size: 12px; }
.cmp-go { color: var(--accent); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.meta { width: calc(100% - 24px); margin: 4px 12px 10px; border-collapse: collapse; font-size: 12.5px; }
table.meta th { text-align: left; font-weight: 500; color: var(--muted); padding: 4px 8px 4px 0; width: 44%; vertical-align: top; }
table.meta td { padding: 4px 0; font-variant-numeric: tabular-nums; }
table.meta tr + tr { border-top: 1px solid var(--surface2); }
.viewer-actions { display: flex; gap: 8px; padding: 0 12px 16px; }

/* ── Plein écran ── */
.overlay { position: fixed; inset: 0; z-index: 2000; }
#lightbox { background: rgba(2,6,23,.94); display: flex; align-items: center; justify-content: center; }
#lightbox img { max-width: 96vw; max-height: 94vh; }
#lbClose { position: absolute; top: 12px; right: 14px; }

#compare { background: #020617; display: flex; flex-direction: column; color: #e2e8f0; }
.cmp-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid #1e293b; }
.cmp-hint { color: #94a3b8; font-size: 12px; }
.cmp-head .btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
.cmp-head .btn:hover { background: #334155; }
.seg { display: inline-flex; border: 1px solid #334155; border-radius: var(--radius); overflow: hidden; }
.seg button { border: none; background: transparent; padding: 6px 12px; cursor: pointer; color: #cbd5e1; font-weight: 550; }
.seg button.on { background: var(--accent); color: #fff; }
.cmp-body { flex: 1; position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; min-height: 0; user-select: none; touch-action: none; cursor: grab; }
.cmp-body:active { cursor: grabbing; }
.cmp-pane { position: relative; overflow: hidden; min-height: 0; background: #000; }
.cmp-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cmp-stage img { max-width: 100%; max-height: 100%; transform-origin: center center; pointer-events: none; -webkit-user-drag: none; }
.cmp-label { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px); background: rgba(2,6,23,.78); padding: 6px 10px; border-radius: 6px;
             font-size: 12.5px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.cmp-line { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-label b { font-size: 13.5px; }
.cmp-label small { color: #94a3b8; }
#paneB .cmp-label { left: auto; right: 10px; text-align: right; align-items: flex-end; }
.swipe-handle { display: none; }
.cmp-body.swipe { display: block; }
.cmp-body.swipe .cmp-pane { position: absolute; inset: 0; }
.cmp-body.swipe .swipe-handle { display: block; position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: #fff; cursor: ew-resize; z-index: 3; box-shadow: 0 0 6px rgba(0,0,0,.6); }
.swipe-handle span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; background: #fff; color: #0f172a;
                     display: flex; align-items: center; justify-content: center; font-weight: 700; box-shadow: 0 1px 6px rgba(0,0,0,.5); }

/* ── Fenêtres ── */
.modal-bg { background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 10px; box-shadow: 0 10px 40px rgba(15,23,42,.3); width: 100%; max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
#modalBody { padding: 16px 18px 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { border: none; background: none; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.inline-form input, .inline-form select, .stack input, .stack textarea { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.inline-form input { flex: 1 1 160px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 550; color: #334155; }
.stack .btn { align-self: flex-start; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.list td { padding: 7px 8px; border-bottom: 1px solid var(--surface2); vertical-align: middle; }
table.list small { color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.row-actions.start { justify-content: flex-start; }
.gauge { display: inline-block; width: 70px; height: 7px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.gauge span { display: block; height: 100%; background: var(--accent); }
.gauge.high span { background: #d97706; }
.gauge.full span { background: var(--red); }
.up-quota { color: var(--muted); margin: 10px 0 0; }
.btn.disabled { opacity: .55; cursor: default; pointer-events: none; }
.stack select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.hint { background: #fefce8; border: 1px solid #fde68a; color: #854d0e; border-radius: var(--radius); padding: 8px 10px; line-height: 1.4; }
.logo-mini { max-height: 26px; max-width: 70px; }
.drop { border: 2px dashed #b6c2d1; border-radius: 10px; padding: 40px 16px; text-align: center; color: var(--muted); line-height: 1.9; transition: background .12s, border-color .12s; }
.drop.over { background: #ecfeff; border-color: var(--accent); }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
#upBar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#upText { margin: 8px 0; font-weight: 600; }
.up-log { list-style: none; max-height: 240px; overflow-y: auto; font-size: 12px; }
.up-log li { padding: 2px 0; }
.up-log .err { color: var(--red); }
.up-log .warn { color: var(--amber); font-weight: 500; }
.up-log .muted { color: var(--muted); }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: #0f172a; color: #fff; padding: 9px 16px; border-radius: 8px;
         opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 3000; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); }
#toast.ok { background: #15803d; }

/* ── Mobile ── */
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  header { gap: 8px; padding: 0 10px; }
  .brand span, .badge, .cmp-hint { display: none; }
  #layout, #layout.with-viewer { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; max-height: 38vh; z-index: 900; border-right: none; border-top: 1px solid var(--border);
             box-shadow: 0 -4px 16px rgba(0,0,0,.08); }
  #viewer { position: fixed; inset: var(--header-h) 0 0 0; z-index: 1000; }
  .cmp-body:not(.swipe) { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}
