/* ==========================================================
   THEME SWITCHER v8 — FX FINAL EDITION (BUGFREE)
========================================================== */

/* Z-index */
:root {
    --z-theme-switcher: 9999;
    --z-floating-sigil: 9100;
}

/* ==========================================================
   DESKTOP SWITCHER
========================================================== */

.theme-switcher {
    position: fixed;
    left: 20px;
    top: 200px;

    display: flex;
    flex-direction: column;
    gap: 16px;

    padding: 16px;
    border-radius: 16px;

    background: var(--panel);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);

    /* FIX: alone doppio rimosso */
    box-shadow: 0 0 14px var(--glow);

    transition: opacity .35s ease, transform .35s ease;
    z-index: var(--z-theme-switcher);
}

.theme-switcher .theme-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.theme-btn {
    width: 50px;
    height: 50px;

    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--panel);

    display: flex;
    align-items: center;
    justify-content: center;

    backdrop-filter: blur(6px);
    box-shadow: 0 0 6px var(--glow);

    cursor: pointer;
    overflow: hidden;

    transition:
        transform .28s cubic-bezier(.15,.8,.25,1.4),
        box-shadow .28s ease,
        border-color .28s ease;
}

.theme-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Hover */
.theme-btn:hover {
    transform: translateY(-3px) scale(1.07);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent);
}

/* Active */
.theme-btn[data-active="1"] {
    border-color: var(--accent2);
    box-shadow: 0 0 26px var(--accent2);

    /* FIX: animazione più stabile */
    transform: scale(1.16);
    animation: themeSnap .28s cubic-bezier(.15,.8,.25,1.4);
}

@keyframes themeSnap {
    0% { transform: scale(.6); opacity:.4; }
    60% { transform: scale(1.22); }
    100%{ transform: scale(1.16); opacity:1; }
}

/* ==========================================================
   COLLAPSE BUTTON
========================================================== */

.theme-collapse-btn {
    width: 42px;
    height: 42px;

    position: absolute;
    top: -26px;
    left: 50%;
    transform: translateX(-50%);

    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--panel);

    display: flex;
    align-items: center;
    justify-content: center;

    cursor: pointer;
    box-shadow: 0 0 10px var(--glow);
    transition: .25s ease;
}

.theme-collapse-btn::before {
    content: "⮟";
    font-size: 1.4rem;
    color: var(--text);
}

.theme-switcher.collapsed .theme-list {
    display: none;
}

.theme-switcher.collapsed .theme-collapse-btn::before {
    content: "⮝";
}

/* ==========================================================
   MOBILE SWITCHER
========================================================== */

.theme-mobile-btn {
    position: fixed;
    left: 20px;
    top: 120px;

    width: 52px;
    height: 52px;

    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--panel);

    display: flex;
    align-items: center;
    justify-content: center;

    backdrop-filter: blur(8px);
    box-shadow: 0 0 16px var(--glow);

    color: var(--text);
    font-size: 1.4rem;
    cursor: pointer;

    z-index: var(--z-theme-switcher);
    transition: transform .25s ease, border-color .25s ease;
}

.theme-mobile-btn::after {
    content: "⮟";
}

.theme-mobile-btn.open::after {
    content: "⮝";
}

.theme-mobile-btn:hover {
    transform: scale(1.06);
    border-color: var(--accent);
    box-shadow: 0 0 22px var(--accent);
}

/* ==========================================================
   MOBILE PANEL — senza display:none (FIX!!)
========================================================== */

.theme-mobile-panel {
    position: fixed;
    left: 20px;
    top: 185px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    flex-direction: column;
    gap: 12px;

    padding: 16px;
    border-radius: 16px;

    background: var(--panel);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);

    box-shadow: 0 0 20px var(--glow);

    transform: translateY(-12px);
    transition: opacity .28s ease, transform .28s ease, visibility .28s ease;

    z-index: var(--z-theme-switcher);
}

.theme-mobile-panel.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.theme-mobile-panel .theme-btn {
    width: 48px;
    height: 48px;
}

/* FORCE vertical list */
.theme-mobile-panel .theme-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

/* ==========================================================
   RESPONSIVE CLEAN
========================================================== */

@media (max-width: 820px) {
    .theme-switcher { display: none !important; }
}

@media (min-width: 821px) {
    .theme-mobile-btn,
    .theme-mobile-panel {
        display: none !important;
    }
}
