/* settings.css — password gate, settings drawer, form controls, crop modal.
 * Accents throughout read from --theme-color, so changing the theme restyles
 * this panel along with everything else.
 */

/* ── password gate ───────────────────────────────────────────────────────── */
.lock-backdrop {
  position: fixed;
  inset: 0;
  z-index: 21000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.lock-box {
  width: min(380px, 96vw);
  padding: 26px;
  border-radius: 18px;
  background: rgba(6, 14, 36, 0.98);
  border: 2px solid var(--theme-color);
  box-shadow: 0 18px 60px var(--theme-glow);
  text-align: center;
}
.lock-icon { display: flex; justify-content: center; color: var(--theme-color); margin-bottom: 10px; }
.lock-box h2 { font-size: 1.25rem; color: var(--theme-color); margin-bottom: 6px; }
.lock-box p { font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }

.lock-box input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--ui-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
  margin-bottom: 10px;
}
.lock-box input:focus { border-color: var(--theme-color); box-shadow: 0 0 0 3px var(--theme-soft); }

.lock-err { color: #f87171; font-size: 12.5px; min-height: 17px; margin-bottom: 8px; }
.lock-btns { display: flex; gap: 9px; }
.lock-btns button { flex: 1; }

/* ── drawer ──────────────────────────────────────────────────────────────── */
.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 19000;
  width: min(400px, 100vw);
  display: flex;
  flex-direction: column;
  background: rgba(5, 11, 30, 0.97);
  border-left: 2px solid var(--theme-color);
  box-shadow: -14px 0 44px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.settings-panel.open { transform: translateX(0); }

/* Docked to the left instead. The whole thing mirrors: which edge it is pinned
   to, which way it slides out, and which side the border and shadow fall on. */
.settings-panel.dock-left {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 2px solid var(--theme-color);
  box-shadow: 14px 0 44px rgba(0, 0, 0, 0.55);
  transform: translateX(-100%);
}
.settings-panel.dock-left.open { transform: translateX(0); }

/* The swap arrows point toward the side the panel would move to. */
.settings-panel.dock-left .sp-swap .ic { transform: scaleX(-1); }

.sp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  padding-top: calc(var(--safe-t) + 16px);
  border-bottom: 1px solid var(--ui-border);
}
.sp-head h2 { font-size: 15px; letter-spacing: 1px; color: var(--theme-color); flex: 1; }
.sp-head-btns { display: flex; gap: 4px; flex: none; }

.sp-close, .sp-swap {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text);
  opacity: 0.7;
}
.sp-close:hover, .sp-swap:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.sp-swap:active { transform: scale(0.92); }

.sp-tabs {
  display: flex;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid var(--ui-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.sp-tabs::-webkit-scrollbar { display: none; }

.sp-tab {
  padding: 11px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s ease;
}
.sp-tab:hover { color: var(--text); }
.sp-tab.active { color: var(--theme-color); border-bottom-color: var(--theme-color); }

.sp-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 18px calc(var(--safe-b) + 24px);
}

/* ── sections and fields ─────────────────────────────────────────────────── */
.sp-section { padding: 16px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.sp-section:last-child { border-bottom: none; }
.sp-section h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--theme-color);
  margin-bottom: 12px;
}

.sp-note { font-size: 12px; line-height: 1.5; color: var(--text-dim); margin-bottom: 12px; }

.sp-field { display: block; margin-bottom: 12px; }
.sp-field > span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.sp-field > span b { color: var(--theme-color); font-weight: 700; }

.sp-field input[type="text"],
.sp-field input[type="password"],
.sp-field select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--ui-border);
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.sp-field input:focus, .sp-field select:focus {
  border-color: var(--theme-color);
  box-shadow: 0 0 0 2px var(--theme-soft);
}
.sp-field select option { background: #0a1430; }

/* Color pickers — strip the native chrome so they read as swatches. */
.sp-color { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sp-color > span { margin-bottom: 0; flex: 1; }
.sp-color input[type="color"] {
  width: 46px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
}
.sp-color input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.sp-color input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
.sp-color input[type="color"]::-moz-color-swatch { border: none; border-radius: 5px; }

.sp-range input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
.sp-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--theme-color);
  cursor: pointer;
}
.sp-range input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border: none; border-radius: 50%;
  background: var(--theme-color);
  cursor: pointer;
}

/* ── toggle switch ───────────────────────────────────────────────────────── */
.sp-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  cursor: pointer;
  user-select: none;
}
.sp-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sp-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.18);
  transition: background .2s ease;
}
.sp-switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s ease;
}
.sp-toggle input:checked + .sp-switch { background: var(--theme-color); }
.sp-toggle input:checked + .sp-switch::after { transform: translateX(18px); }
.sp-toggle input:focus-visible + .sp-switch { box-shadow: 0 0 0 3px var(--theme-soft); }

.sp-inline { display: flex; gap: 18px; flex-wrap: wrap; }

/* A group gated by an override switch. */
.sp-subgroup { transition: opacity .2s ease; }
.sp-subgroup.disabled { opacity: 0.35; pointer-events: none; }

/* ── swatches ────────────────────────────────────────────────────────────── */
.sp-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sp-swatch {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: transform .12s ease;
}
.sp-swatch:hover { transform: scale(1.12); }
.sp-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5); }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-ghost, .btn-danger {
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: filter .15s ease, background .15s ease;
}
.btn-primary { background: var(--theme-color); color: #05101f; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-ghost { background: rgba(255, 255, 255, 0.09); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.16); }
.btn-danger { background: rgba(220, 38, 38, 0.22); color: #fca5a5; border: 1px solid rgba(220, 38, 38, 0.45); }
.btn-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.36); color: #fff; }
.btn-primary:disabled, .btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.block { width: 100%; margin-bottom: 12px; }

.sp-btn-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.sp-count { flex: 1; font-size: 12px; color: var(--text-dim); }

.sp-msg { font-size: 12px; margin: 8px 0; min-height: 16px; opacity: 0; transition: opacity .2s ease; }
.sp-msg.visible { opacity: 1; }
.sp-msg.ok { color: #4ade80; }
.sp-msg.err { color: #f87171; }

/* ── player style picker ─────────────────────────────────────────────────── */
.sp-style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 9px;
}
.sp-style {
  padding: 9px 7px;
  border-radius: 10px;
  border: 1.5px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.sp-style:hover { background: rgba(255, 255, 255, 0.09); }
.sp-style.active { border-color: var(--theme-color); background: var(--theme-soft); }
.sp-style-name { display: block; font-size: 11.5px; font-weight: 600; margin-top: 6px; }

/* Miniature of each player layout, so the choice is visual not just a name. */
.sp-style-preview {
  display: block;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--theme-color);
  background: rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}
.sp-style-preview::before,
.sp-style-preview::after { content: ''; position: absolute; background: var(--theme-color); }

.preview-classic::before { left: 4px; top: 5px; width: 11px; height: 11px; border-radius: 2px; }
.preview-classic::after  { left: 4px; bottom: 5px; right: 4px; height: 3px; border-radius: 2px; opacity: .55; }

.preview-cube::before { left: 0; right: 0; top: 0; height: 8px; }
.preview-cube::after  { left: 4px; top: 13px; width: 10px; height: 10px; border-radius: 2px; }

.preview-minimal::before { left: 4px; top: 12px; width: 10px; height: 10px; border-radius: 50%; }
.preview-minimal::after  { right: 4px; top: 13px; width: 8px; height: 8px; border-radius: 50%; }

.preview-neon::before { inset: 3px; border: 1px solid var(--theme-color); background: none; border-radius: 4px; }
.preview-neon::after  { left: 7px; top: 14px; right: 7px; height: 3px; border-radius: 2px; }

.preview-vinyl::before {
  left: 50%; top: 4px; width: 16px; height: 16px;
  transform: translateX(-50%); border-radius: 50%;
  background: none; border: 2px solid var(--theme-color);
}
.preview-vinyl::after { left: 50%; bottom: 5px; width: 20px; height: 3px; transform: translateX(-50%); border-radius: 2px; opacity: .6; }

.preview-wave::before { left: 4px; top: 5px; width: 9px; height: 9px; border-radius: 2px; }
.preview-wave::after {
  left: 0; right: 0; bottom: 6px; height: 9px; opacity: .4;
  clip-path: polygon(0 60%, 15% 20%, 30% 60%, 45% 20%, 60% 60%, 75% 20%, 90% 60%, 100% 40%, 100% 100%, 0 100%);
}

.preview-glass::before {
  left: 50%; top: 5px; width: 14px; height: 14px;
  transform: translateX(-50%); border-radius: 4px; opacity: .8;
}
.preview-glass::after { left: 8px; right: 8px; bottom: 6px; height: 3px; border-radius: 2px; opacity: .5; }

/* ── requests list ───────────────────────────────────────────────────────── */
.rq-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.rq-item {
  position: relative;
  padding: 10px 38px 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ui-border);
}
.rq-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rq-user { font-size: 12px; font-weight: 700; color: var(--theme-color); }
.rq-when { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.rq-song { font-size: 13px; line-height: 1.4; word-break: break-word; }

.rq-del {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: #f87171;
  opacity: 0.7;
}
.rq-del:hover { opacity: 1; background: rgba(220, 38, 38, 0.22); }
.rq-del:disabled { opacity: 0.3; }

.rq-empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ── crop modal ──────────────────────────────────────────────────────────── */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 22000;
  display: flex;
  flex-direction: column;
  background: rgba(3, 7, 18, 0.97);
}

.crop-top, .crop-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  flex: none;
  flex-wrap: wrap;
}
.crop-top { border-bottom: 1px solid var(--ui-border); }
.crop-bottom { border-top: 1px solid var(--ui-border); padding-bottom: calc(var(--safe-b) + 14px); }
.crop-top h3 { font-size: 15px; color: var(--theme-color); }
.crop-btns, .crop-controls { display: flex; gap: 9px; }
.crop-hint { font-size: 12px; color: var(--text-dim); }

/* Cropper.js needs a bounded parent, so this must not be a flex-auto height. */
.crop-stage { flex: 1; min-height: 0; overflow: hidden; }
.crop-stage img { display: block; max-width: 100%; }

/* ── responsive ──────────────────────────────────────────────────────────── */

/* Touch: taller controls so the panel is usable with a thumb. */
@media (hover: none), (pointer: coarse) {
  .sp-tab { padding: 14px 14px; }
  .btn-primary, .btn-ghost, .btn-danger { padding: 13px 18px; }
  .sp-color input[type="color"] { width: 54px; height: 38px; }
  .sp-range input[type="range"] { height: 6px; }
  .sp-range input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }
  .sp-range input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; }
  .sp-swatch { width: 40px; height: 40px; }
  .sp-swatch:hover { transform: none; }
  .rq-del { width: 36px; height: 36px; }
  .sp-close { width: 40px; height: 40px; }
}

/* Tablet: a wider drawer, since there is room for it. */
@media (min-width: 641px) and (max-width: 1024px) {
  .settings-panel { width: min(460px, 82vw); }
}

/* Phone: full screen drawer. */
@media (max-width: 640px) {
  .settings-panel { width: 100vw; border-left: none; }
  .sp-style-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
  .crop-top, .crop-bottom { padding: 11px 13px; }
  .crop-hint { display: none; }
  .lock-box { padding: 22px 18px; }
}

/* Phone held sideways: the drawer header and tabs would eat most of a ~390px
   viewport, so tighten them and let the body take what is left. */
@media (orientation: landscape) and (max-height: 500px) {
  .settings-panel { width: min(420px, 60vw); }
  .sp-head { padding: 9px 14px; padding-top: calc(var(--safe-t) + 9px); }
  .sp-tab { padding: 9px 11px; }
  .sp-section { padding: 11px 0; }
  .crop-top, .crop-bottom { padding: 8px 12px; }
  .crop-hint { display: none; }
}
