/* WorldPainter — interfata. Cromatica inchisa, ca harta colorata sa fie eroul. */

:root {
  --bg: #070b14;
  --panel: rgba(15, 22, 38, 0.88);
  --panel-solid: #101728;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #e8edf7;
  --muted: #90a0bb;
  --accent: #ffd23f;
  --primary: #4f8cff;
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --topbar-h: 60px;
  --palette-h: 236px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* Panourile folosesc display:flex/grid, care ar invinge atributul `hidden`. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--primary); }

#map { position: fixed; inset: 0; }
.maplibregl-ctrl-bottom-right { margin-bottom: calc(var(--palette-h) + 8px); transition: margin-bottom .25s ease; }
body.palette-collapsed .maplibregl-ctrl-bottom-right { margin-bottom: 56px; }

.map-labels { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.map-label {
  position: absolute; top: 0; left: 0; white-space: nowrap;
  padding: 0 4px; border-radius: 4px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .2px; color: #1b2434;
  /* Fundalul abia se vede peste uscat, dar face numele lizibil peste ocean. */
  background: rgba(244, 246, 250, .62);
  text-shadow: 0 0 3px rgba(255, 255, 255, .9);
}

/* ---------- bara de sus ---------- */

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: linear-gradient(180deg, rgba(7, 11, 20, 0.95), rgba(7, 11, 20, 0.72) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.brand-mark { font-size: 20px; }
.brand-name { font-size: 15px; }

.search { position: relative; flex: 1; max-width: 560px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
#search-input {
  width: 100%; height: 38px; padding: 0 34px 0 36px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
#search-input::placeholder { color: var(--muted); }
#search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18); }
#search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 18px; line-height: 1;
}
.search-clear:hover { background: var(--line); color: var(--text); }

.search-popover {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 30;
  background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.suggestions {
  margin: 0; padding: 6px; list-style: none;
  max-height: min(52vh, 420px); overflow-y: auto;
}
.suggestion {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.suggestion[aria-selected="true"], .suggestion:hover { background: rgba(79, 140, 255, 0.16); }
.suggestion-icon { font-size: 16px; width: 20px; text-align: center; flex: none; }
.suggestion-text { min-width: 0; }
.suggestion-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-name mark { background: rgba(255, 210, 63, 0.28); color: inherit; border-radius: 3px; padding: 0 1px; }
.suggestion-ctx { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-kind { margin-left: auto; flex: none; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.suggestion-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.suggestions-empty { padding: 14px; color: var(--muted); text-align: center; }

.search-filters {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .03);
}
.filter-chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap;
}
.filter-chip[aria-pressed="true"] { color: var(--text); border-color: var(--primary); background: rgba(79, 140, 255, 0.18); }

.actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; min-width: 34px; padding: 0 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover:not(:disabled) { background: rgba(79, 140, 255, 0.18); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.active { background: rgba(79, 140, 255, 0.22); border-color: var(--primary); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.2); border-color: rgba(255, 107, 107, .5); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--line); }

/* ---------- unelte (stanga) ---------- */

.tools {
  position: fixed; left: 14px; top: calc(var(--topbar-h) + 10px); z-index: 15; width: 208px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(12px); padding: 12px;
}
.tools-title, .active-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
}
.tools-title { margin-bottom: 8px; }
.levels { display: grid; gap: 4px; }
.level {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 7px 9px; border: 1px solid transparent; border-radius: 9px; background: transparent;
  transition: background .15s, border-color .15s;
}
.level:hover { background: var(--line); }
.level[aria-checked="true"] { background: rgba(79, 140, 255, 0.2); border-color: var(--primary); }
.level-icon { font-size: 15px; }
.level-name { font-weight: 550; }
.level-clicks {
  margin-left: auto; font-size: 11px; color: var(--muted);
  background: rgba(255, 255, 255, .07); border-radius: 6px; padding: 1px 6px;
}

.active-color {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  padding: 9px; border: 1px solid var(--line); border-radius: 10px;
}
.chip { width: 34px; height: 34px; border-radius: 8px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.active-hex { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

.progress { margin-top: 10px; padding: 8px 9px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.progress-name { font-size: 12px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-dots { display: flex; gap: 5px; margin-top: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dot.on { background: var(--accent); }

.toggles { display: grid; gap: 2px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.toggle { display: flex; align-items: center; gap: 8px; padding: 4px 2px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toggle:hover { color: var(--text); }
.toggle input { accent-color: var(--primary); width: 14px; height: 14px; }

/* ---------- paleta ---------- */

.palette-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; height: var(--palette-h);
  display: flex; flex-direction: column;
  background: var(--panel); border-top: 1px solid var(--line-strong);
  backdrop-filter: blur(12px); transition: height .25s ease;
}
body.palette-collapsed .palette-panel { height: 48px; }
body.palette-collapsed .palette-body { opacity: 0; pointer-events: none; }

.palette-head { display: flex; align-items: center; gap: 12px; padding: 7px 14px; flex: none; }
.palette-toggle {
  display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0;
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 4px;
}
.palette-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .25s; }
.palette-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.palette-toggle:hover { color: var(--text); }

.recent { display: flex; gap: 4px; align-items: center; min-height: 22px; }
.recent:empty::after { content: "fără culori recente"; color: var(--muted); font-size: 12px; }
.custom-color { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; margin-left: auto; }
.custom-color input {
  width: 30px; height: 26px; padding: 0; border: 1px solid var(--line-strong); border-radius: 7px;
  background: transparent; cursor: pointer;
}
.custom-color input::-webkit-color-swatch-wrapper { padding: 2px; }
.custom-color input::-webkit-color-swatch { border: 0; border-radius: 5px; }
#btn-eraser span { font-size: 12px; }

.palette-body { flex: 1; overflow: auto; padding: 0 14px 12px; transition: opacity .2s; }
.palette-row { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 3px; margin-bottom: 3px; }
.swatch {
  height: 15px; border: 0; border-radius: 3px; padding: 0; cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.swatch:hover { transform: scale(1.45); border-radius: 4px; box-shadow: 0 3px 10px rgba(0, 0, 0, .6); z-index: 2; position: relative; }
.swatch.selected { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); z-index: 3; position: relative; }
.recent .swatch { width: 20px; height: 20px; border-radius: 5px; }

/* ---------- panouri laterale ---------- */

.panel {
  position: fixed; right: 14px; top: calc(var(--topbar-h) + 10px); z-index: 19; width: 320px;
  max-height: calc(100vh - var(--topbar-h) - var(--palette-h) - 24px);
  display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.help-panel { width: 380px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.panel-head .close { font-size: 20px; line-height: 1; width: 28px; height: 28px; padding: 0; }
.panel-body { padding: 12px 14px; overflow-y: auto; }

.stat-total { display: flex; gap: 14px; margin-bottom: 12px; }
.stat-total div { flex: 1; background: rgba(255,255,255,.05); border-radius: 9px; padding: 8px 10px; }
.stat-total b { display: block; font-size: 19px; }
.stat-total span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.stat-swatch { width: 18px; height: 18px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.stat-hex { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.stat-bar { flex: 1; height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.stat-bar i { display: block; height: 100%; border-radius: 3px; }
.stat-count { font-size: 12px; min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.stat-empty { color: var(--muted); text-align: center; padding: 20px 0; }

.help-steps { margin: 0 0 16px; padding-left: 20px; }
.help-steps li { margin-bottom: 8px; }
.panel-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 16px 0 8px; }
.help-keys { list-style: none; margin: 0; padding: 0; }
.help-keys li { padding: 3px 0; color: var(--muted); }
kbd {
  display: inline-block; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; background: rgba(255,255,255,.06); color: var(--text);
  font: 500 11px/1.5 ui-monospace, Menlo, monospace;
}

/* ---------- tooltip, notificari, incarcare ---------- */

.tooltip {
  position: fixed; z-index: 25; pointer-events: none;
  padding: 5px 9px; border-radius: 8px; font-size: 12.5px; white-space: nowrap;
  background: rgba(10, 15, 26, .94); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  transform: translate(12px, 14px);
}
.tooltip-ctx { color: var(--muted); font-size: 11px; }

.toasts { position: fixed; left: 50%; bottom: calc(var(--palette-h) + 16px); transform: translateX(-50%); z-index: 40; display: grid; gap: 8px; justify-items: center; }
body.palette-collapsed .toasts { bottom: 64px; }
.toast {
  padding: 9px 15px; border-radius: 10px; background: var(--panel-solid);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: rise .22s ease both;
}
.toast.error { border-color: rgba(255, 107, 107, .6); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.loading { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--bg); transition: opacity .4s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading-card { display: grid; gap: 14px; justify-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line-strong); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--muted); }

@media (max-width: 900px) {
  :root { --palette-h: 190px; }
  .brand-name { display: none; }
  .tools { width: 170px; padding: 10px; }
  .panel { width: min(320px, calc(100vw - 28px)); }
}
@media (max-width: 620px) {
  /* Pe ecrane inguste bara de sus trece pe doua randuri: altfel campul de
     cautare s-ar strange pana la latimea pictogramei. */
  :root { --topbar-h: 98px; }
  .topbar { flex-wrap: wrap; align-content: center; gap: 8px 10px; padding: 8px 10px; }
  .actions .sep { display: none; }
  .actions { margin-left: auto; gap: 4px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .tools { left: 8px; width: 148px; }
}
