/* ── Settings ── */
.settings-form { max-width: 540px; }

.setting-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
}
.setting-section-title {
  padding: 16px 20px;
  font-size: 15px; font-weight: 700; color: var(--text);
  cursor: pointer; list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  transition: color var(--transition);
  user-select: none;
}
.setting-section-title::-webkit-details-marker { display: none; }
.setting-section-title::after {
  content: ''; width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg); transition: transform .25s ease;
  flex-shrink: 0;
}
.setting-section[open] > .setting-section-title::after {
  transform: rotate(45deg);
}
.setting-section-title:hover { color: var(--accent); }
.setting-section-body {
  padding: 0 20px 18px;
}

/* Groups settings sections into labeled categories (Playback & Sound,
   Library & Downloads, Account & App, Admin) so ~11 flat accordions read as
   a structured page instead of one undifferentiated list. Pure presentation
   — sections keep their own IDs/JS untouched inside each group. */
.settings-group { margin-bottom: 28px; }
.settings-group:last-child { margin-bottom: 0; }
.settings-group-label {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1.2px;
  padding-top: 16px; margin-bottom: 12px;
  border-top: 1px solid var(--border);
}
.settings-group:first-child .settings-group-label {
  padding-top: 0; border-top: none;
}
.settings-group .setting-section:last-child { margin-bottom: 0; }

/* Admin group: auth.js toggles #usersSection/#diskUsageSection display via
   inline style for non-admins. Both are set together from the same
   is_admin check, so hide the group label + separator whenever the first
   one is hidden — otherwise non-admins see a bare "Admin" heading with
   nothing under it. Matches both the literal markup default
   ("display:none;") and the CSSOM-serialized form JS produces
   ("display: none;"). */
.settings-group--admin:has(#usersSection[style*="display:none"]),
.settings-group--admin:has(#usersSection[style*="display: none"]) {
  display: none;
}

.setting-group {
  margin-bottom: 16px;
}
.setting-group:last-child { margin-bottom: 0; }
.setting-label {
  display: block; font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;
  font-weight: 600;
}
.setting-input, .setting-select {
  width: 100%; padding: 12px 16px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; outline: none; transition: all var(--transition);
  font-family: inherit;
}
.setting-select { appearance: none; cursor: pointer; }
.setting-input:focus, .setting-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.setting-input::placeholder { color: var(--text-dim); }

.btn-save {
  padding: 14px 36px; background: var(--accent); color: #000;
  border: none; border-radius: 12px; font-size: 14px;
  font-weight: 700; cursor: pointer; transition: all var(--transition);
  font-family: inherit;
}
.btn-save:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.btn-save:active { transform: translateY(0); }
.btn-save:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.save-status { display: inline-block; margin-left: 12px; font-size: 13px; color: var(--accent); font-weight: 500; }

/* ── User Management ── */
.users-section { margin-top: 40px; max-width: 540px; }
.users-section h3 { font-size: 18px; margin-bottom: 16px; font-weight: 700; letter-spacing: -0.3px; }
.user-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.user-row .user-name { flex: 1; font-size: 14px; font-weight: 500; }
.user-row .user-badge {
  font-size: 10px; text-transform: uppercase; color: var(--accent);
  background: var(--accent-dim); padding: 3px 10px; border-radius: 20px; font-weight: 700;
  letter-spacing: 0.5px;
}
.user-row .btn-delete-user {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 18px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all var(--transition);
}
.user-row .btn-delete-user:hover { color: var(--red); background: rgba(239,68,68,.1); }
.add-user-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.add-user-form input {
  padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  outline: none; flex: 1; min-width: 120px; font-family: inherit;
  transition: border-color var(--transition);
}
.add-user-form input:focus { border-color: var(--accent); }
.btn-add-user {
  padding: 10px 20px; background: var(--accent); color: #000;
  border: none; border-radius: var(--radius-sm); font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all var(--transition);
}
.btn-add-user:hover { box-shadow: var(--shadow-glow); }
.perm-section {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.perm-section-title {
  padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}
.perm-section-title::-webkit-details-marker { display: none; }
.perm-section-title::after {
  content: ''; width: 6px; height: 6px;
  border-right: 1.5px solid var(--text-dim); border-bottom: 1.5px solid var(--text-dim);
  transform: rotate(-45deg); transition: transform .2s;
}
.perm-section[open] > .perm-section-title::after { transform: rotate(45deg); }
.perm-section-body {
  padding: 0 14px 10px; display: flex; flex-direction: column; gap: 6px;
}
.perm-check {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.perm-check span { min-width: 64px; }
.perm-check input { accent-color: var(--accent); }
.user-row { flex-wrap: wrap; }
.user-perms {
  width: 100%; display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
}
.user-perm-tag {
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted); white-space: nowrap;
}
.user-perm-edit {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; font-size: 11px; padding: 2px 10px; border-radius: 10px;
  font-family: inherit; transition: all var(--transition);
}
.user-perm-edit:hover { border-color: var(--accent); color: var(--accent); }

/* ── Device List ── */
.device-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
}
.device-row.current { border-color: var(--accent); }
.device-row .device-name { flex: 1; font-weight: 500; }
.device-row .device-mode { color: var(--text-muted); font-size: 11px; }
.device-row .btn-delete-device {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 16px; padding: 2px 6px; border-radius: 50%; transition: all var(--transition);
}
.device-row .btn-delete-device:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ── Disk Usage ── */
.disk-usage-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.disk-usage-row:last-child { border-bottom: none; }
.disk-usage-name { flex: 1; font-weight: 600; font-size: 14px; }
.disk-usage-name.expandable { cursor: pointer; }
.disk-usage-name.expandable::before { content: '\25B6'; font-size: 10px; margin-right: 6px; display: inline-block; transition: transform 0.2s; }
.disk-usage-name.expandable.expanded::before { transform: rotate(90deg); }
.disk-usage-stats { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.disk-usage-bar { width: 80px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.disk-usage-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.btn-delete-dir { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; padding: 4px 10px; cursor: pointer; }
.btn-delete-dir:hover { border-color: #e74c3c; color: #e74c3c; }
.disk-usage-subs { display: none; padding-left: 24px; }
.disk-usage-subs.open { display: block; }
.disk-usage-subs .disk-usage-row { padding: 6px 0; }
.disk-usage-subs .disk-usage-name { font-weight: 500; font-size: 13px; color: var(--text-muted); }

/* ── Range slider with live value badge ── */
.setting-range-row {
  display: flex; align-items: center; gap: 12px;
}
.setting-range {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 3px; background: var(--border);
  outline: none; cursor: pointer; margin: 0;
}
.setting-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
  transition: box-shadow var(--transition);
}
.setting-range::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px var(--accent-dim); }
.setting-range::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
}
.setting-range-val {
  min-width: 48px; text-align: center; font-size: 13px; font-weight: 600;
  color: var(--accent); background: var(--accent-dim);
  padding: 4px 8px; border-radius: 8px; white-space: nowrap;
}

/* ── Toggle switch (matches .perm-check accent) ── */
.setting-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 14px; color: var(--text);
}
.setting-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.setting-toggle .switch {
  position: relative; flex-shrink: 0;
  width: 40px; height: 22px; border-radius: 22px;
  background: var(--border); transition: background var(--transition);
}
.setting-toggle .switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-dim); transition: transform var(--transition), background var(--transition);
}
.setting-toggle input:checked + .switch { background: var(--accent-dim); }
.setting-toggle input:checked + .switch::after { transform: translateX(18px); background: var(--accent); }

/* ── Section icon in summary title ── */
.setting-section-icon {
  flex-shrink: 0; width: 18px; height: 18px;
  margin-right: 10px; color: var(--text-muted);
  vertical-align: middle;
}
.setting-section-title:hover .setting-section-icon { color: var(--accent); }
/* Title text sits between icon and the chevron (::after) */
.setting-section-title > .setting-section-label { flex: 1; }

/* ── Inline help text (replaces scattered inline styles) ── */
.setting-help {
  font-size: 11px; color: var(--text-dim);
  margin-top: 4px; line-height: 1.4;
}

/* ── Password reveal (eye) button ── */
.input-reveal-wrap { position: relative; }
.input-reveal-wrap .setting-input { padding-right: 44px; }
.btn-reveal {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: 6px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; transition: color var(--transition);
}
.btn-reveal:hover { color: var(--accent); }

/* ── Connection status pill (Save & Test result) ── */
.conn-status {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px; margin-left: 10px;
  white-space: nowrap;
}
.conn-status.ok { color: var(--accent); background: var(--accent-dim); }
.conn-status.err { color: var(--red); background: rgba(239,68,68,.12); }
