/* ─── Zelda Civ Panel — theme BOTW Sheikah ─── */

:root {
  --bg: #0e1219;
  --bg-elev: #161c26;
  --bg-card: #1c2330;
  --border: #2a3342;
  --border-strong: #3a4456;
  --text: #e8eef5;
  --text-dim: #8b95a5;
  --text-muted: #5a6478;
  --accent: #ff9c3b;          /* Hyrule gold */
  --accent-hover: #ffb45e;
  --sheikah: #00d4ff;          /* Sheikah cyan */
  --sheikah-glow: #00d4ff80;
  --danger: #e85a5a;
  --ok: #4ec97f;
  --warn: #ffb454;
  --shadow: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
  --radius: 6px;
  --radius-lg: 10px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --font-display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Trame Sheikah discrète en fond */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 25% 30%, var(--sheikah-glow) 0, transparent 1px),
    radial-gradient(circle at 75% 70%, var(--sheikah-glow) 0, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.03;
  pointer-events: none;
  z-index: 0;
}

/* ─── En-tête ─── */

header {
  background: linear-gradient(135deg, var(--bg-elev) 0%, var(--bg-card) 100%);
  border-bottom: 1px solid var(--border-strong);
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex: none;
}

header h1 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1.2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--sheikah) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}

header h1::before {
  content: '⛭';
  font-size: 21px;
  color: var(--sheikah);
  -webkit-text-fill-color: var(--sheikah);
  text-shadow: 0 0 8px var(--sheikah-glow);
  animation: pulse 3s ease-in-out infinite;
}

header h1 .sub {
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 0;
  -webkit-text-fill-color: var(--text-muted);
  color: var(--text-muted);
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

#conn { display: flex; gap: 8px; align-items: center; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-muted); flex: none;
  transition: var(--transition);
}
.dot.on {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(78,201,127,0.6);
}
.dot.off { background: var(--danger); }

/* ─── Contrôles génériques ─── */

input[type=text], input[type=password], input[type=search] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 11px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  width: 100%;
  transition: var(--transition);
}
input[type=password] { font-family: var(--font-mono); width: 230px; }

input:focus, button:focus-visible {
  outline: none;
  border-color: var(--sheikah);
  box-shadow: 0 0 0 3px var(--sheikah-glow);
}

input[type=file] {
  font-size: 12px; color: var(--text-dim); width: 100%;
}
input[type=file]::file-selector-button {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: 5px 10px; margin-right: 8px; cursor: pointer;
  font-family: var(--font-ui); font-size: 12px;
}

button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}
button:hover:not(:disabled) { background: var(--bg-elev); border-color: var(--border-strong); }
button:disabled { opacity: 0.38; cursor: default; }

button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-color: var(--accent);
  color: #1a1206;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); }

button.ghost {
  background: transparent; border-color: transparent;
  color: var(--accent); padding: 4px 8px; font-size: 12px;
}
button.ghost:hover { background: var(--bg-card); border-color: var(--border); }

input[type=range] { width: 100%; accent-color: var(--accent); }

/* ─── Disposition ─── */

main { display: flex; flex: 1; min-height: 0; position: relative; z-index: 1; }

#sidebar {
  width: 272px; flex: none; overflow-y: auto;
  background: var(--bg-elev);
  border-right: 1px solid var(--border-strong);
  padding-bottom: 24px;
}

#sidebar section {
  padding: 15px 15px 17px;
  border-bottom: 1px solid var(--border);
}

#sidebar h2 {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.1px;
  color: var(--text-muted);
  margin-bottom: 11px;
}

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 9px;
}
.section-head h2 { margin-bottom: 0; }

.row { display: flex; align-items: center; gap: 9px; margin-top: 11px; }
.row label { font-size: 12px; color: var(--text-dim); flex: none; }
.row output {
  font-size: 12px; color: var(--accent); min-width: 36px;
  text-align: right; font-family: var(--font-mono);
}
.row.btns { gap: 6px; }
.row.btns button:first-child { flex: 1; }

.check {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; margin: 8px 0; cursor: pointer; color: var(--text-dim);
}
.check input { accent-color: var(--accent); cursor: pointer; }
.check:hover { color: var(--text); }

.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 9px; line-height: 1.5; }

/* ─── Outils ─── */

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

.tools button {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 44px; padding: 0; font-size: 17px;
}
.tools button em {
  position: absolute; right: 4px; bottom: 2px;
  font-size: 9px; font-style: normal;
  color: var(--text-muted); letter-spacing: 0.3px;
  font-family: var(--font-mono);
}
.tools button.active {
  background: rgba(255,156,59,0.14);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255,156,59,0.2);
}
.tools button.active em { color: var(--accent); }

.undo-row { display: flex; gap: 6px; margin-top: 11px; }
.undo-row button { flex: 1; font-size: 12px; padding: 6px 4px; }

/* ─── Liste des zones ─── */

#zone-list { list-style: none; margin-top: 10px; }

#zone-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--radius);
  cursor: pointer; margin-bottom: 3px;
  border: 1px solid transparent;
  transition: var(--transition);
}
#zone-list li:hover { background: var(--bg-card); }
#zone-list li.active {
  background: rgba(255,156,59,0.12);
  border-color: rgba(255,156,59,0.4);
}

.swatch {
  width: 13px; height: 13px; border-radius: 3px; flex: none;
  border: 1px solid rgba(255,255,255,0.22);
  cursor: pointer; padding: 0;
}
.swatch:hover { border-color: var(--text); }

.zone-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 13px;
}
.zone-count {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono); flex: none;
}
/* Rappel de la touche 1-4 qui sélectionne la température. */
.zone-key {
  font-size: 10px; color: var(--text-muted); flex: none;
  font-family: var(--font-mono);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 3px; padding: 0 4px; line-height: 15px;
}
#zone-list li.active .zone-key { color: var(--text); border-color: rgba(255,255,255,0.35); }

/* ─── Canvas ─── */

#canvas-wrap { flex: 1; position: relative; overflow: hidden; background: #0a0d12; }
#canvas-container { width: 100%; height: 100%; }
#canvas-container canvas { display: block; }

#hud-top { position: absolute; top: 13px; left: 13px; pointer-events: none; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(22,28,38,0.92);
  border: 1px solid var(--border-strong);
  border-radius: 20px; padding: 5px 13px; font-size: 12.5px;
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow);
}
.chip .swatch { width: 10px; height: 10px; cursor: default; }

#status-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 11px;
  padding: 6px 15px; font-size: 12px;
  color: var(--text-dim);
  background: rgba(14,18,25,0.95);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  backdrop-filter: blur(5px);
}
#status-bar .sep { width: 1px; height: 12px; background: var(--border); flex: none; }
#status-bar .grow { flex: 1; }

#save-state.saving { color: var(--warn); }
#save-state.saved  { color: var(--ok); }
#save-state.error  { color: var(--danger); font-weight: 700; }

#toast {
  position: absolute; bottom: 46px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  padding: 10px 15px; border-radius: var(--radius);
  font-size: 13px; box-shadow: var(--shadow-lg);
  max-width: 70%; z-index: 20;
}
#toast.err { border-left-color: var(--danger); }
#toast.ok  { border-left-color: var(--ok); }

.hidden { display: none !important; }

/* ─── Barre de défilement ─── */

#sidebar::-webkit-scrollbar { width: 9px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 940px) {
  #sidebar { width: 218px; }
  .tools { grid-template-columns: repeat(3, 1fr); }
  input[type=password] { width: 150px; }
}
