/* style.css — éditeur web Supervario, miroir du chrome de l'app.
   Scène sombre (langage Doxymore), cadre d'iPhone, pills opaques,
   sheets type modale de l'app. */

* { box-sizing: border-box; margin: 0; }

:root {
  --bg: #0a0a0a;
  --panel: #171717;
  --panel2: #202020;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f2f2f4;
  --muted: rgba(235, 235, 245, 0.55);
  --accent: #0a84ff;
  --danger: #ff453a;
  --pill-light: rgba(255, 255, 255, 0.13);
  font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

html, body, #app { height: 100%; }
body { background: var(--bg); color: var(--text); overflow: hidden; }
#app { display: flex; flex-direction: column; }

/* ── Barre desktop ─────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; font-size: 15px; }
.brand span { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 13px; }
.spacer { flex: 1; }

.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
  transition: background 0.12s;
}
.btn:hover { background: #2b2b2b; }
.btn.primary, .btn.accent { background: var(--accent); border-color: transparent; color: white; font-weight: 600; }
.btn.primary:hover, .btn.accent:hover { background: #2b95ff; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }

.control {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; font-size: 13px;
}

/* ── Scène & appareil ──────────────────────────────────────────── */

#scene {
  flex: 1; display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 22px;
}
#device {
  background: #050506;
  border: 1px solid #2c2c31;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), inset 0 0 0 3px #101013;
  position: relative;
}
#screen { position: absolute; inset: 9px; overflow: hidden; }
#canvas { position: absolute; inset: 0; }
#island {
  position: absolute; background: #000; border-radius: 99px;
  z-index: 5; pointer-events: none; border: 1px solid rgba(255, 255, 255, 0.06);
}

#screen.drop-target::after {
  content: "Déposer le fichier JSON"; position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 132, 255, 0.18); border: 2px dashed var(--accent);
  border-radius: inherit; font-weight: 600; color: white; pointer-events: none;
}

/* ── Grille & widgets ──────────────────────────────────────────── */

.grid-overlay {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity 0.15s; z-index: 1;
}
#canvas.dragging .grid-overlay, #canvas.show-grid .grid-overlay { opacity: 1; }

.widget {
  position: absolute; overflow: hidden; cursor: grab;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.widget:active { cursor: grabbing; }
.widget.ghost-outline { outline: 1px dashed rgba(128, 128, 140, 0.4); outline-offset: -1px; }
.widget.selected { outline: 2px solid var(--accent); outline-offset: 0; z-index: 3; }
.widget.co-selected { outline: 2px dashed var(--accent); outline-offset: 0; z-index: 3; }

.handle {
  position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: white; border: 2.5px solid var(--accent); z-index: 4;
}
.handle.nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle.ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle.sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle.se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* ── Previews de widgets ───────────────────────────────────────── */

.pv-value {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: center; pointer-events: none; line-height: 1.06;
}
.pv-value-row { display: flex; align-items: baseline; gap: 0.18em; }
.pv-label { letter-spacing: 0.02em; }
.pv-fill { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; }
.pv-map-chip {
  position: absolute; background: rgba(20, 20, 24, 0.8); color: white;
  border-radius: 8px; padding: 2px 7px; font-size: 11px; font-weight: 600;
  pointer-events: none;
}
.pv-chip-green {
  background: #22b14c; color: #05230d; font-weight: 700;
  border-radius: 99px; padding: 0.1em 0.55em; white-space: nowrap;
}

/* ── Chrome d'édition (même disposition que l'app) ─────────────── */

.chrome-top, .chrome-bottom {
  position: absolute; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  pointer-events: none;
}
.chrome-top { top: 10px; justify-content: space-between; }
.chrome-bottom { bottom: 10px; }
.chrome-group { display: flex; gap: 8px; }
.chrome-top > *, .chrome-bottom > * { pointer-events: auto; }
.chrome-bottom .spacer { pointer-events: none; }

.pill {
  height: 38px; min-width: 38px; padding: 0 14px;
  border-radius: 99px; border: none; cursor: pointer;
  background: var(--pill-bg, var(--pill-light)); color: var(--pill-fg, white);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  backdrop-filter: blur(6px); transition: filter 0.12s;
}
.pill:hover { filter: brightness(1.25); }
.pill.icon { width: 38px; padding: 0; font-size: 16px; }
.pill.accent { background: var(--accent); color: white; }
.pill.active { box-shadow: inset 0 0 0 2px var(--accent); }
.pill.dots { gap: 7px; padding: 0 12px; cursor: default; }
.pill.dots .dot {
  width: 7px; height: 7px; border-radius: 50%; cursor: pointer;
  background: var(--pill-fg, white); opacity: 0.35; transition: opacity 0.12s;
}
.pill.dots .dot.active { opacity: 1; }

/* ── Sheets (modales façon app) ────────────────────────────────── */

#sheetScrim { position: absolute; inset: 0; z-index: 18; }

.sheet {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: min(420px, calc(100% - 24px)); max-height: 74%;
  background: rgba(23, 23, 23, 0.97); border: 1px solid var(--line);
  border-radius: 20px; z-index: 20; display: flex; flex-direction: column;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  color: var(--text);
}
.sheet-handle {
  width: 38px; height: 4.5px; border-radius: 3px; background: rgba(255, 255, 255, 0.25);
  margin: 8px auto 2px;
}
.sheet-title { font-weight: 700; font-size: 14.5px; text-align: center; padding: 6px 16px 8px; }
.sheet-title .muted { color: var(--muted); font-weight: 500; }
.sheet-body { overflow-y: auto; padding: 4px 16px 16px; }

.field {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.field:last-of-type { border-bottom: none; }
.field label { flex: 0 0 92px; font-size: 13px; color: var(--muted); }
.field .control { flex: 1; min-width: 0; }
.field input[type="range"] { flex: 1; accent-color: var(--accent); }
.field .value { flex: 0 0 34px; text-align: right; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.color-field { flex: 1; display: flex; align-items: center; gap: 10px; }
.color-field input[type="range"] { flex: 1; accent-color: var(--accent); }
.color-field input[type="color"] {
  width: 34px; height: 28px; border: 1px solid var(--line); border-radius: 8px;
  background: none; padding: 1px; cursor: pointer;
}

.switch { position: relative; display: inline-block; width: 44px; height: 26px; margin-left: auto; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; z-index: 2; cursor: pointer; margin: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.16);
  transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 21px; height: 21px;
  border-radius: 50%; background: white; transition: transform 0.15s;
}
.switch input:checked + .track { background: #30d158; }
.switch input:checked + .track::after { transform: translateX(18px); }

.row-buttons { display: flex; gap: 8px; padding-top: 12px; justify-content: center; flex-wrap: wrap; }

/* Bibliothèque */
.library { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lib-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); padding: 10px 4px; font-size: 11.5px; cursor: pointer;
}
.lib-item:hover { background: #2b2b2b; }
.lib-item .icon { font-size: 21px; }

/* Gestion des pages */
.page-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
  border-radius: 8px;
}
.page-row:hover { background: rgba(255, 255, 255, 0.05); }
.page-row.current { color: var(--accent); font-weight: 700; }
.page-row .pr-name { flex: 1; font-size: 13.5px; }
.page-row .pr-meta { font-size: 12px; color: var(--muted); }
.page-row .pr-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 3px 5px; border-radius: 6px;
}
.page-row .pr-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

/* Organiser */
.arrange-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.empty-note { color: var(--muted); font-size: 12.5px; padding: 4px 0 10px; text-align: center; }

/* ── Divers ────────────────────────────────────────────────────── */

.hint {
  padding: 8px 16px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); text-align: center; background: var(--panel);
}
kbd {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 0 5px; font-size: 11px; font-family: inherit;
}

#toast {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%) translateY(16px);
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 18px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 100; max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--danger); color: #ff8a80; }
