/* ============================================================
   Radio Tech — Theme Customizer
   Permite utilizatorului să suprascrie culorile site-ului.
   Se încarcă DUPĂ style.css / pages.css / members.css.
   Valorile sunt injectate ca variabile CSS pe <html data-theme>.
   ============================================================ */

/* ---------- Panou ---------- */
/* Ancorare: FAB-ul stă mereu deasupra barei mobile (dacă e vizibilă) și a
   mini-playerului. --rt-dock-h se recalculează din JS (js/theme.js) pe baza
   înălțimii reale a elementelor fixe, ca butonul să nu mai „fugă”. */
:root {
  --rt-dock-h: 0px;
  --rt-fab-gap: 18px;
  --rt-fab-size: 46px;
}
.theme-fab {
  position: fixed; right: 18px;
  bottom: calc(var(--rt-dock-h) + var(--rt-fab-gap));
  z-index: 9000;
  width: var(--rt-fab-size); height: var(--rt-fab-size); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-0);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  transition: transform .18s ease, background .18s ease, border-color .18s ease,
              bottom .22s cubic-bezier(.22, 1, .36, 1);
  will-change: bottom;
}
.theme-fab:hover { transform: translateY(-2px) rotate(-12deg); border-color: var(--accent); color: var(--accent); }
.theme-fab svg { width: 21px; height: 21px; }
.theme-fab__dot {
  position: absolute; top: 4px; right: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface-2);
  opacity: 0; transition: opacity .18s;
}
html[data-theme="custom"] .theme-fab__dot { opacity: 1; }

.theme-panel {
  position: fixed; z-index: 9001;
  right: 18px;
  bottom: calc(var(--rt-dock-h) + var(--rt-fab-gap) + var(--rt-fab-size) + 10px);
  width: min(360px, calc(100vw - 36px));
  max-height: min(74vh, 660px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform-origin: bottom right;
  animation: themePanelIn .18s ease;
  transition: bottom .22s cubic-bezier(.22, 1, .36, 1);
}
.theme-panel[hidden] { display: none; }
@keyframes themePanelIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.theme-panel__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.theme-panel__title {
  margin: 0; font-size: .92rem; font-weight: 700; color: var(--text-0);
  letter-spacing: -.01em;
}
.theme-panel__sub { margin: 2px 0 0; font-size: .72rem; color: var(--text-2); }
.theme-panel__close {
  margin-left: auto; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  transition: background .15s, color .15s;
}
.theme-panel__close:hover { background: rgba(255,255,255,.06); color: var(--text-0); }

.theme-panel__body {
  padding: 14px 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.theme-panel__body::-webkit-scrollbar { width: 8px; }
.theme-panel__body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

/* ---------- Preset-uri ---------- */
.theme-presets {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 18px;
}
.theme-preset {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 4px 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text-2);
  font-size: .64rem; font-weight: 600; letter-spacing: .02em;
  transition: border-color .15s, color .15s, transform .15s;
}
.theme-preset:hover { transform: translateY(-1px); color: var(--text-0); border-color: var(--line-strong); }
.theme-preset.is-active { border-color: var(--accent); color: var(--text-0); }
.theme-preset__swatch {
  width: 100%; height: 22px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  overflow: hidden; display: flex;
}
.theme-preset__swatch i { flex: 1; display: block; }

/* ---------- Grupuri de culoare ---------- */
.theme-group { margin-bottom: 16px; }
.theme-group__title {
  margin: 0 0 8px;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-2); font-weight: 500;
}
.theme-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.theme-row:last-child { border-bottom: none; }
.theme-row__label {
  flex: 1; min-width: 0;
  font-size: .82rem; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.theme-row__hex {
  font-family: var(--mono); font-size: .68rem; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .02em;
}

/* Swatch = input color nativ, stilizat */
.theme-swatch {
  position: relative; flex: none;
  width: 34px; height: 26px; border-radius: 7px;
  border: 1px solid var(--line-strong);
  overflow: hidden; cursor: pointer;
  background: transparent;
  transition: transform .15s, border-color .15s;
}
.theme-swatch:hover { transform: scale(1.06); border-color: var(--accent); }
.theme-swatch input[type="color"] {
  position: absolute; inset: -6px;
  width: calc(100% + 12px); height: calc(100% + 12px);
  padding: 0; border: none; background: none;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.theme-swatch input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.theme-swatch input[type="color"]::-webkit-color-swatch { border: none; border-radius: 0; }
.theme-swatch input[type="color"]::-moz-color-swatch { border: none; }

/* ---------- Acțiuni ---------- */
.theme-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.theme-actions .btn { width: 100%; justify-content: center; }
.theme-note {
  margin: 10px 0 0; font-size: .7rem; color: var(--text-2);
  text-align: center; line-height: 1.5;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  :root { --rt-fab-gap: 14px; --rt-fab-size: 42px; }
  .theme-fab { right: 12px; }
  .theme-panel {
    right: 10px; left: 10px; width: auto;
    max-height: 68vh;
  }
  .theme-presets { grid-template-columns: repeat(4, 1fr); }
}
