/*
 * =====================================================================
 *  Theme Picker Component CSS
 *  Styles for the 4-theme dropdown selector in the navbar
 *  Works across all 4 themes (light, dark, encora, encora-dark)
 *
 *  The dropdown is managed by Stimulus (theme_controller.js),
 *  NOT by Bootstrap's data-bs-toggle JS. The .show class is toggled
 *  by the controller directly — no Bootstrap Dropdown plugin needed.
 * =====================================================================
 */

/* ─── Visibility: Stimulus-controlled via .show ───────────────────── */
#theme-picker-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  z-index: 1050;
}

#theme-picker-menu.show {
  display: block;
}

/* ─── Nav item container — anchors the absolute-position menu ────── */
.theme-picker-nav {
  position: relative;
}

/* ─── Trigger button ──────────────────────────────────────────────── */
.theme-picker-trigger {
  color: inherit;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  transition: background 0.18s ease, color 0.18s ease;
  min-height: 36px;
}

.theme-picker-trigger:hover,
.theme-picker-trigger:focus {
  background: rgba(128, 128, 128, 0.12);
  color: inherit;
}

.theme-picker-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.theme-picker-label {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.theme-picker-caret {
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.theme-picker-trigger[aria-expanded="true"] .theme-picker-caret {
  transform: rotate(-180deg);
}

/* ─── Dropdown container ──────────────────────────────────────────── */
.theme-picker-menu {
  min-width: 240px;
  max-width: 260px;
  border-radius: 13px !important;
  /* Apple-style continuous corner */
  padding: 0.5rem !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22),
    0 2px 8px rgba(0, 0, 0, 0.14),
    0 0 0 0.5px rgba(0, 0, 0, 0.10);
}

/* ─── Section header ──────────────────────────────────────────────── */
.theme-picker-header small {
  color: inherit;
  opacity: 0.45;
}

/* ─── Theme option row ────────────────────────────────────────────── */
.theme-option {
  cursor: pointer;
  border-radius: 10px !important;
  font-size: 0.9375rem;
  font-weight: 400;
  transition: background 0.14s ease;
  position: relative;
}

.theme-option:active {
  transform: scale(0.99);
}

/* ─── Swatch (colour preview circle) ─────────────────────────────── */
.theme-option-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.20);
}

/* ─── Text inside option row ──────────────────────────────────────── */
.theme-option-name {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.theme-option-desc {
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.3;
  opacity: 0.65;
}

/* ─── Active item ─────────────────────────────────────────────────── */
.theme-option-active .theme-option-name {
  opacity: 1;
}

/* ─── Checkmark icon ──────────────────────────────────────────────── */
.theme-option-check {
  flex-shrink: 0;
  stroke-width: 3;
}

/* ─── Divider ─────────────────────────────────────────────────────── */
.theme-picker-menu .dropdown-divider {
  opacity: 0.25;
  margin: 0.25rem 0.25rem;
}

/* ══════════════════════════════════════════════════════════════════
   THEME-SPECIFIC OVERRIDES for the picker itself
   ══════════════════════════════════════════════════════════════════ */

/* ─── LIGHT theme ─────────────────────────────────────────────────── */
body[data-theme="light"] .theme-picker-menu,
body:not([data-theme="dark"]):not([data-theme="encora"]):not([data-theme="encora-dark"]) .theme-picker-menu {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

body[data-theme="light"] .theme-option:hover,
body:not([data-theme="dark"]):not([data-theme="encora"]):not([data-theme="encora-dark"]) .theme-option:hover {
  background: rgba(0, 0, 0, 0.05);
  color: inherit;
}

body[data-theme="light"] .theme-option.theme-option-active,
body:not([data-theme="dark"]):not([data-theme="encora"]):not([data-theme="encora-dark"]) .theme-option.theme-option-active {
  background: rgba(37, 99, 235, 0.08);
}

body[data-theme="light"] .theme-picker-header small {
  color: #64748B;
}

/* ─── DARK (AdminKit) theme ───────────────────────────────────────── */
html[data-theme="dark"] body .theme-picker-menu {
  background: rgba(41, 56, 69, 0.96);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(58, 75, 92, 0.80);
}

html[data-theme="dark"] body .theme-option-name {
  color: #E9ECEF;
}

html[data-theme="dark"] body .theme-option:hover {
  background: rgba(59, 125, 221, 0.15);
  color: #E9ECEF;
}

html[data-theme="dark"] body .theme-option.theme-option-active {
  background: rgba(59, 125, 221, 0.20);
}

html[data-theme="dark"] body .theme-picker-trigger {
  color: #ADB5BD;
}

html[data-theme="dark"] body .theme-picker-trigger:hover {
  color: #E9ECEF;
  background: rgba(255, 255, 255, 0.06);
}

/* ─── ENCORA (Professional / light) theme ────────────────────────── */
html[data-theme="encora"] body .theme-picker-menu {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border: 1px solid #C8D8EE;
}

html[data-theme="encora"] body .theme-option-name {
  color: #0D1B2E;
}

html[data-theme="encora"] body .theme-option:hover {
  background: #EBF3FD;
  color: #1B4F8A;
}

html[data-theme="encora"] body .theme-option.theme-option-active {
  background: rgba(27, 79, 138, 0.08);
}

html[data-theme="encora"] body .theme-picker-trigger {
  color: #6B8BAD;
}

html[data-theme="encora"] body .theme-picker-trigger:hover {
  color: #1B4F8A;
  background: rgba(27, 79, 138, 0.08);
}

/* ─── ENCORA-DARK (Apple dark) theme ─────────────────────────────── */
html[data-theme="encora-dark"] body .theme-picker-menu {
  background: #2C2C2E;
  /* Solid Elevated background for Tahoe */
  border: 0.5px solid #48484A;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.75),
    0 0 0 0.5px rgba(255, 255, 255, 0.08);
}

html[data-theme="encora-dark"] body .theme-option-name {
  color: #FFFFFF;
}

html[data-theme="encora-dark"] body .theme-option-desc {
  color: rgba(235, 235, 245, 0.50);
}

html[data-theme="encora-dark"] body .theme-option:hover {
  background: #0A84FF;
  color: #FFFFFF;
}

html[data-theme="encora-dark"] body .theme-option:hover .theme-option-desc {
  color: rgba(255, 255, 255, 0.70);
}

html[data-theme="encora-dark"] body .theme-option.theme-option-active {
  background: #102B47;
}

html[data-theme="encora-dark"] body .theme-picker-trigger {
  color: #919196;
}

html[data-theme="encora-dark"] body .theme-picker-trigger:hover {
  color: #FFFFFF;
  background: #242426;
}

html[data-theme="encora-dark"] body .theme-picker-header small {
  color: #5A5A5E;
}

html[data-theme="encora-dark"] body .theme-picker-menu .dropdown-divider {
  border-color: #38383A;
}

/* ─── Animations ──────────────────────────────────────────────────── */
@keyframes themepicker-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* NOTE: display:block is already set in the #theme-picker-menu.show rule above.
   This adds the open animation on top of it. */
.theme-picker-menu.show {
  animation: themepicker-in 0.18s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

/* ─── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .theme-picker-menu.show {
    animation: none;
  }

  .theme-picker-caret,
  .theme-picker-trigger {
    transition: none;
  }
}