/* ========== SETTINGS PAGE ========== */
#settings {
  display: none;
  width: 100%;
  flex-shrink: 0;
}

/* ========== SETTINGS CONTENT (pleine largeur, groupes séparés par filets) ========== */
.settings-content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 clamp(32px, 6vh, 56px);
  overflow-y: visible;
  flex: 1;
  min-height: 0;
}

.settings-section {
  background: transparent;
  border-radius: 0;
  padding: 0 0 clamp(18px, 2.5vw, 24px);
  margin: 0;
  border: none;
}

.settings-content > .settings-section + .settings-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: clamp(20px, 3vw, 28px);
}

.settings-section h3 {
  font-family: 'Satoshi-Regular', 'Satoshi', sans-serif;
  font-size: var(--page-section-sub-font-size, 14px);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 12px;
  color: var(--text-primary);
  line-height: 1.2;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--border-subtle);
  transition: border-color 0.25s ease;
}

.settings-item--stack {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.settings-item--stack .settings-field__title--solo {
  margin: 0;
}

/* Langue / thème — ligne : libellés à gauche, sélecteurs égaux à droite */
.settings-prefs-selects-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-item.settings-item--pref-choice {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: clamp(12px, 3vw, 20px);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-item.settings-item--pref-choice .settings-field {
  flex: 1;
  min-width: 0;
  width: auto;
  max-width: none;
}

.settings-item.settings-item--pref-choice .settings-field__desc {
  max-width: 42ch;
}

.settings-item.settings-item--pref-choice .custom-select {
  flex: 0 0 auto;
  width: clamp(152px, 34vw, 220px);
  max-width: 100%;
}

.settings-item.settings-item--pref-choice .custom-select-trigger {
  width: 100%;
}

.settings-item.settings-item--pref-choice .custom-select-trigger > span:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.settings-item.settings-item--pref-choice .custom-select-options {
  left: 0;
  right: 0;
  width: auto;
  min-width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-item--plain {
  border-bottom: none;
  padding: 0;
}

.settings-item label {
  color: var(--text-primary);
}

.settings-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.settings-field__title {
  font-size: var(--font-size-md, 14px);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.settings-field__title--solo {
  font-size: var(--font-size-sm, 10px);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.settings-field__desc {
  font-size: var(--font-size-base, 12px);
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 42ch;
}

.settings-field__desc--warn {
  color: rgba(220, 38, 38, 0.85);
}

[data-theme="dark"] .settings-field__desc--warn {
  color: rgba(248, 113, 113, 0.9);
}

.settings-muted {
  margin: 0;
  font-size: var(--font-size-md, 14px);
  color: var(--text-muted);
}

.settings-path-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.settings-input-readonly {
  flex: 1;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  font-size: var(--font-size-base, 12px);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.settings-btn-ghost {
  flex: 0 0 auto;
  max-width: 100px;
  padding: 9px 14px !important;
  border: 1px solid var(--border-subtle) !important;
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md, 8px) !important;
  font-weight: 500 !important;
}

.settings-btn-ghost:hover {
  background: var(--hover-overlay) !important;
  border-color: var(--border-color-dark) !important;
}

[data-theme="dark"] .settings-btn-ghost {
  background: var(--bg-tertiary) !important;
  border-color: var(--border-color-dark) !important;
}

[data-theme="dark"] .settings-btn-ghost:hover {
  background: var(--bg-secondary) !important;
  border-color: var(--text-tertiary) !important;
}

.settings-btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  max-width: 200px;
  line-height: 1;
  padding: 10px 20px !important;
  border: 1px solid var(--border-subtle) !important;
  background: transparent !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md, 8px) !important;
  font-family: 'Satoshi-Regular', 'Satoshi', sans-serif !important;
  font-size: var(--font-size-md, 14px) !important;
  font-weight: 400 !important;
  font-synthesis: none !important;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-btn-logout:hover {
  background: var(--surface-hover) !important;
  border-color: var(--text-primary) !important;
}

.settings-item select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: var(--radius-md, 8px);
  font-family: 'Satoshi', sans-serif;
  cursor: pointer;
}

/* ========== CUSTOM SELECT DROPDOWN ========== */
.custom-select {
  position: relative;
}

.custom-select-trigger {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 7px 12px;
  border-radius: var(--radius-md, 8px);
  font-family: 'Satoshi', sans-serif;
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  user-select: none;
}

.custom-select-trigger:hover {
  border-color: var(--border-color-dark);
}

.custom-select-trigger svg {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  transition: transform 0.2s ease;
}

.custom-select.open .custom-select-trigger svg {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  width: max-content;
  min-width: unset;
  max-width: min(220px, 92vw);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
  box-shadow: 0 8px 24px var(--shadow);
}

.custom-select.open .custom-select-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-select-option {
  padding: 7px 16px;
  cursor: pointer;
  font-family: 'Satoshi', sans-serif;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 400;
  white-space: nowrap;
  color: var(--text-primary);
  transition: all 0.15s ease;
  user-select: none;
}

.custom-select-option:hover {
  background: var(--surface-hover);
}

.custom-select-option.selected {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 500;
}

.custom-select-option.selected:hover {
  background: var(--hover-bg);
}

/* Dark mode shadows */
[data-theme="dark"] .custom-select-options {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.settings-section > .settings-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section > h3 + .settings-item {
  padding-top: 0;
}

.settings-item .settings-field {
  flex: 1;
}

.settings-item label:not(.settings-field) {
  flex: 1;
  font-weight: 500;
}

/* Fallback si input readonly sans classe */
.settings-item input[type="text"][readonly]:not(.settings-input-readonly) {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
}

/* Boutons secondaires dans les lignes (cache, danger) — pas les ghost / logout */
.settings-item .btn:not(.settings-btn-ghost):not(.settings-btn-logout):not(.account-cta-btn):not(.account-outline-btn) {
  max-width: 140px;
  padding: 9px 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-md, 8px);
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.settings-item .btn:not(.settings-btn-ghost):not(.settings-btn-logout):not(.account-cta-btn):not(.account-outline-btn):hover {
  background: var(--surface-hover);
  border-color: var(--border-color-dark);
}

[data-theme="dark"] .settings-item .btn:not(.settings-btn-ghost):not(.settings-btn-logout):not(.account-cta-btn):not(.account-outline-btn) {
  background: var(--bg-tertiary);
  border-color: var(--border-color-dark);
}

[data-theme="dark"] .settings-item .btn:not(.settings-btn-ghost):not(.settings-btn-logout):not(.account-cta-btn):not(.account-outline-btn):hover {
  background: var(--bg-secondary);
  border-color: var(--text-primary);
}

/* ========== CACHE MANAGEMENT BUTTONS ========== */
.settings-item .btn-cache,
.settings-item .btn-danger {
  border-width: 1px !important;
  border-radius: var(--radius-md, 8px) !important;
  font-weight: 600 !important;
}

.btn-cache {
  min-width: 120px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-subtle) !important;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-cache:hover {
  background: var(--bg-secondary);
  border-color: var(--text-primary) !important;
}

.btn-danger {
  min-width: 120px;
  background: transparent;
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.55) !important;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.btn-danger:hover {
  background: transparent;
  color: #b91c1c;
  border-color: #f22a2a;
}

/* Dark mode pour cache buttons */
[data-theme="dark"] .btn-cache {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

[data-theme="dark"] .btn-cache:hover {
  background: var(--bg-secondary);
  border-color: var(--text-primary);
}

[data-theme="dark"] .btn-danger {
  background: transparent;
  color: #ff6b6b;
  border-color: #ff6b6b;
}

[data-theme="dark"] .btn-danger:hover {
  background: transparent;
  color: #ff8787;
  border-color: #ff5555;
}

[data-theme="dark"] .settings-btn-logout {
  border-color: var(--border-color-dark) !important;
}

[data-theme="dark"] .settings-btn-logout:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: var(--text-primary) !important;
}

/* ========== PILL-SHAPED TOGGLE SWITCHES ========== */
.settings-item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 52px;
  height: 28px;
  background: #D1D5DB;
  border-radius: 50px;
  position: relative;
  cursor: pointer;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  border: none;
  outline: none;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.settings-item input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  background: white;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.settings-item input[type="checkbox"]:checked {
  background: #282828;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.settings-item input[type="checkbox"]:checked::before {
  transform: translateX(24px);
}

.settings-item input[type="checkbox"]:hover {
  opacity: 0.92;
}

.settings-item input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 3px;
}

/* Dark : OFF = piste sombre + bordure visible ; ON = piste claire + pastille sombre (contraste net) */
[data-theme="dark"] .settings-item input[type="checkbox"] {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .settings-item input[type="checkbox"]::before {
  background: #f3f4f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .settings-item input[type="checkbox"]:checked {
  background: #e8e8ea;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

[data-theme="dark"] .settings-item input[type="checkbox"]:checked::before {
  background: #1a1a1c;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

/* ========== DEVICE MANAGEMENT (settings page) ========== */
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.device-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  background: var(--bg-primary);
  transition: border-color 0.2s ease, background-color 0.25s ease;
}

.device-item:hover {
  border-color: var(--border-color-dark);
}

.device-item.current {
  background: var(--bg-tertiary);
  border-color: var(--border-color-dark);
}

/* Dark mode pour device item */
[data-theme="dark"] .device-item {
  border-color: var(--border-color-dark);
}

[data-theme="dark"] .device-item:hover {
  border-color: var(--text-primary);
}

[data-theme="dark"] .device-item.current {
  background: var(--bg-tertiary);
}

.device-info {
  flex: 1;
}

.device-info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 3px;
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  color: var(--text-primary);
}

.device-info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
}

.badge-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 38px;
  padding: 9px 16px;
  background: var(--bg-primary);
  color: #047857;
  border: 1px solid #10b981;
  border-radius: var(--radius-md, 8px);
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  font-size: var(--font-size-md, 14px);
  font-weight: 600;
  line-height: 1.2;
}

[data-theme="dark"] .badge-current {
  background: var(--bg-tertiary);
  border-color: #34d399;
  color: #6ee7b7;
}

.badge-device-type.badge-browser {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.35);
}

[data-theme="dark"] .badge-device-type.badge-browser {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.35);
}

.btn-remove-device {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 38px;
  padding: 9px 16px;
  background: transparent;
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.55);
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  font-size: var(--font-size-md, 14px);
  font-weight: 600;
  line-height: 1.2;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.btn-remove-device:hover {
  background: rgba(220, 38, 38, 0.06);
  color: #b91c1c;
  border-color: #f22a2a;
}

.btn-remove-device:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

[data-theme="dark"] .btn-remove-device {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
}

[data-theme="dark"] .btn-remove-device:hover {
  background: rgba(248, 113, 113, 0.08);
  color: #fca5a5;
  border-color: #f87171;
}
