/* Aspetto — pannello laterale destro a scomparsa (vetro) */

.theme-fab {
  --theme-glass: rgba(10, 16, 26, 0.18);
  --theme-glass-strong: rgba(12, 20, 32, 0.26);
  --theme-glass-border: rgba(255, 255, 255, 0.07);
  --theme-glass-edge: rgba(255, 255, 255, 0.09);
  --theme-blur: 14px;

  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 240;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 0.55rem;
  padding-right: 0;
  pointer-events: none;
}
.theme-fab > * { pointer-events: auto; }

.theme-fab-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--theme-glass-border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  background: var(--theme-glass);
  backdrop-filter: blur(var(--theme-blur)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--theme-blur)) saturate(1.2);
  color: color-mix(in srgb, var(--heading) 52%, transparent);
  cursor: pointer;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.06), inset 0 1px 0 var(--theme-glass-edge);
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease, border-color 0.22s, transform 0.22s ease;
  opacity: 0.62;
}
.theme-fab-toggle:hover {
  opacity: 1;
  color: var(--heading);
  background: color-mix(in srgb, var(--theme-glass-strong) 85%, rgba(255, 255, 255, 0.08));
  border-color: color-mix(in srgb, var(--heading) 18%, var(--theme-glass-border));
  box-shadow: -4px 0 18px rgba(0, 0, 0, 0.14), inset 0 1px 0 var(--theme-glass-edge);
  transform: translateX(-1px);
}
.theme-fab.is-open .theme-fab-toggle {
  opacity: 0.92;
  background: color-mix(in srgb, var(--emerald) 7%, var(--theme-glass-strong));
  color: color-mix(in srgb, var(--emerald) 75%, var(--heading));
  border-color: color-mix(in srgb, var(--emerald) 20%, var(--theme-glass-border));
}

.theme-fab-toggle-icon {
  font-size: 0.82rem;
  line-height: 1;
  opacity: 0.85;
  transition: transform 0.28s ease, opacity 0.22s ease;
}
.theme-fab-toggle:hover .theme-fab-toggle-icon {
  opacity: 1;
  transform: scale(1.08);
}
.theme-fab.is-open .theme-fab-toggle-icon {
  opacity: 1;
  transform: rotate(180deg);
}
.theme-fab.is-open .theme-fab-toggle:hover .theme-fab-toggle-icon {
  transform: rotate(180deg) scale(1.08);
}

.theme-fab-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 9.5rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--theme-glass-border);
  background: var(--theme-glass-strong);
  backdrop-filter: blur(var(--theme-blur)) saturate(1.35);
  -webkit-backdrop-filter: blur(var(--theme-blur)) saturate(1.35);
  box-shadow: var(--shadow-deep);
  opacity: 0;
  visibility: hidden;
  transform: translateX(12px) scale(0.96);
  transform-origin: right center;
  transition:
    opacity 0.24s ease,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.24s ease;
  pointer-events: none;
}
.theme-fab.is-open .theme-fab-panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.theme-fab-label {
  margin: 0;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.theme-switch--fab {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.theme-switch-btn--fab {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.48rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--theme-glass-border);
  background: var(--theme-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.theme-switch-btn--fab:hover {
  color: var(--heading);
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--theme-glass-strong) 80%, rgba(255, 255, 255, 0.06));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  transform: translateX(-2px);
}

/* Colori tenue dedicati per tema */
.theme-switch-btn--fab[data-theme="light"] {
  border-color: rgba(245, 158, 11, 0.2);
  background: color-mix(in srgb, rgba(255, 251, 235, 0.55) 70%, var(--theme-glass));
}
.theme-switch-btn--fab[data-theme="dark"] {
  border-color: rgba(52, 211, 153, 0.18);
  background: color-mix(in srgb, rgba(6, 24, 20, 0.45) 60%, var(--theme-glass));
}
.theme-switch-btn--fab[data-theme="rest"] {
  border-color: rgba(167, 139, 250, 0.22);
  background: color-mix(in srgb, rgba(40, 32, 72, 0.45) 60%, var(--theme-glass));
}

.theme-switch-btn--fab.is-on {
  color: var(--on-primary);
  border-color: transparent;
  box-shadow: var(--btn-primary-shadow);
  transform: none;
}
.theme-switch-btn--fab[data-theme="light"].is-on {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.85), rgba(251, 191, 36, 0.75));
  color: #1c2430;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.28);
}
.theme-switch-btn--fab[data-theme="dark"].is-on {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.75), rgba(6, 95, 70, 0.85));
  color: #e8f5f0;
  box-shadow: 0 2px 12px rgba(16, 185, 129, 0.25);
}
.theme-switch-btn--fab[data-theme="rest"].is-on {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.7), rgba(99, 102, 241, 0.75));
  color: #eef0ff;
  box-shadow: 0 2px 12px rgba(129, 140, 248, 0.28);
}

.theme-fab-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}
.theme-fab-btn-text {
  font-size: 0.72rem;
  font-weight: 600;
}

html[data-theme="light"] .theme-fab {
  --theme-glass: rgba(255, 255, 255, 0.34);
  --theme-glass-strong: rgba(255, 255, 255, 0.48);
  --theme-glass-border: rgba(28, 36, 46, 0.07);
  --theme-glass-edge: rgba(255, 255, 255, 0.65);
  --theme-blur: 12px;
}
html[data-theme="light"] .theme-fab-toggle {
  opacity: 0.58;
  color: color-mix(in srgb, var(--heading) 45%, transparent);
}
html[data-theme="light"] .theme-fab-toggle,
html[data-theme="light"] .theme-fab-panel,
html[data-theme="light"] .theme-switch-btn--fab {
  backdrop-filter: blur(var(--theme-blur)) saturate(1.25);
  -webkit-backdrop-filter: blur(var(--theme-blur)) saturate(1.25);
}

html[data-theme="rest"] .theme-fab {
  --theme-glass: rgba(24, 30, 56, 0.18);
  --theme-glass-strong: rgba(32, 40, 72, 0.28);
  --theme-glass-border: rgba(140, 160, 220, 0.12);
  --theme-glass-edge: rgba(180, 195, 240, 0.08);
}
html[data-theme="rest"] .theme-fab-toggle {
  color: color-mix(in srgb, #a8c0f0 55%, transparent);
}

html[data-theme="rest"] .theme-fab-toggle.is-on,
html[data-theme="rest"] .theme-fab.is-open .theme-fab-toggle {
  color: #a8c0f0;
  border-color: rgba(140, 160, 220, 0.25);
}

@media (max-width: 768px) {
  .theme-fab {
    top: auto;
    bottom: 5.5rem;
    transform: none;
  }
  .theme-fab-toggle {
    width: 28px;
    height: 28px;
    border-radius: 9px 0 0 9px;
  }
  .theme-fab-toggle-icon { font-size: 0.76rem; }
  .theme-fab-panel {
    min-width: 8.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-fab-panel,
  .theme-fab-toggle-icon { transition: none; }
}