/* ============================================================
 *  Peerly — Sélecteur de thème
 *  v8.2.0 — grille 13 palettes
 * ============================================================ */

.theme-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.theme-subgroup {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.theme-subgroup-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--md-outline);
}

/* ---- Mode toggle ---- */
.theme-mode-toggle {
  display: flex;
  gap: var(--space-1);
  padding: 3px;
  background: var(--md-surface-container);
  border-radius: var(--radius-md);
}

.theme-mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 0 var(--space-2);
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--md-on-surface-variant);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.theme-mode-btn i { font-size: 14px; line-height: 1; }
.theme-mode-btn:hover { color: var(--md-on-surface); }
.theme-mode-btn.active {
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
 *  Grille de palettes
 * ============================================================ */
.theme-palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: var(--space-2);
}

.theme-palette-btn {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  padding: 0;
  background: transparent;
}
.theme-palette-btn:hover {
  transform: scale(1.06);
}
.theme-palette-btn:active {
  transform: scale(0.96);
}
.theme-palette-btn.active {
  border-color: var(--md-on-surface);
  box-shadow: 0 0 0 3px var(--md-primary-soft);
}

.theme-palette-swatch {
  position: absolute;
  inset: 0;
  display: flex;
}
.theme-palette-swatch::before,
.theme-palette-swatch::after {
  content: '';
  flex: 1;
}
.theme-palette-swatch::before { background: var(--theme-preview-light, #888); }
.theme-palette-swatch::after  { background: var(--theme-preview-dark, #222); }

/* ---- Preview par palette (light / dark) ---- */
.theme-palette-btn[data-palette-preview="orange"]  { --theme-preview-light: #FFDCCB; --theme-preview-dark: #FF8A50; }
.theme-palette-btn[data-palette-preview="blue"]    { --theme-preview-light: #D0E2FF; --theme-preview-dark: #6CB4FF; }
.theme-palette-btn[data-palette-preview="green"]   { --theme-preview-light: #BBF7D0; --theme-preview-dark: #5BE594; }
.theme-palette-btn[data-palette-preview="violet"]  { --theme-preview-light: #EDDFFF; --theme-preview-dark: #BC9EFF; }
.theme-palette-btn[data-palette-preview="rose"]    { --theme-preview-light: #FFD6E4; --theme-preview-dark: #FF9CC1; }
.theme-palette-btn[data-palette-preview="red"]     { --theme-preview-light: #FFD4D4; --theme-preview-dark: #FF7B7B; }
.theme-palette-btn[data-palette-preview="amber"]   { --theme-preview-light: #FFE9B8; --theme-preview-dark: #FFC24A; }
.theme-palette-btn[data-palette-preview="teal"]    { --theme-preview-light: #B8F0EA; --theme-preview-dark: #52DDD4; }
.theme-palette-btn[data-palette-preview="indigo"]  { --theme-preview-light: #DDE0FF; --theme-preview-dark: #8B9EFF; }
.theme-palette-btn[data-palette-preview="fuchsia"] { --theme-preview-light: #F8D4FA; --theme-preview-dark: #E97BEE; }
.theme-palette-btn[data-palette-preview="lime"]    { --theme-preview-light: #E4F8B5; --theme-preview-dark: #B4EA5E; }
.theme-palette-btn[data-palette-preview="cyan"]    { --theme-preview-light: #B8E8F5; --theme-preview-dark: #4DD4F7; }
.theme-palette-btn[data-palette-preview="brick"]   { --theme-preview-light: #FFDCCF; --theme-preview-dark: #E8856B; }

/* ============================================================
 *  Transition lors du changement
 * ============================================================ */
html.theme-transitioning,
html.theme-transitioning * {
  transition:
    background-color 250ms var(--ease-out),
    color 250ms var(--ease-out),
    border-color 250ms var(--ease-out) !important;
}