/* Dark mode switch (common/theme_toggle), loaded in both modes; state comes from aria-checked */

.theme-toggle-nav {
    display: inline-flex !important;
    align-items: center;
    height: 46px;
    padding: 3px 8px 0 !important;
    margin: 0 !important;
    vertical-align: top;
}

.theme-toggle {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    line-height: 1;
}

.theme-toggle:focus {
    outline: none;
}

.theme-toggle:focus-visible .theme-toggle-track {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.theme-toggle-track {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 74px;
    height: 38px;
    padding: 0 10px;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, 0.15);
    border-radius: 999px !important; /* components.css forces 0 !important on spans */
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.65);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.theme-toggle:hover .theme-toggle-track {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.14), 0 0 0 4px rgba(54, 198, 211, 0.08);
}

.theme-toggle[aria-checked="true"] .theme-toggle-track {
    background: rgba(15, 23, 42, 0.78);
    border-color: rgba(255, 255, 255, 0.20);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.theme-toggle[aria-checked="true"]:hover .theme-toggle-track {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22), 0 0 0 4px rgba(54, 198, 211, 0.08);
}

.theme-icon {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    transition: color 0.3s ease;
}

.theme-icon svg {
    width: 100%;
    height: 100%;
}

.theme-sun {
    color: #f59e0b;
}

.theme-moon {
    color: rgba(15, 23, 38, 0.38);
}

.theme-toggle[aria-checked="true"] .theme-sun {
    color: rgba(255, 255, 255, 0.55);
}

.theme-toggle[aria-checked="true"] .theme-moon {
    color: #ffffff;
}

.theme-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 4px;
    z-index: 1;
    width: 30px;
    height: 30px;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #ffffff, #dbeafe);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22), inset 0 1px 1px rgba(255, 255, 255, 0.65);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

.theme-toggle[aria-checked="true"] .theme-toggle-thumb {
    transform: translateX(34px);
    background: linear-gradient(135deg, #3ec8e0, #22b8cf);
}

/* Pre-auth shell */
.theme-toggle-wrap,
.theme-toggle-card {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9999;
}

@media (max-width: 991px) {
    .theme-toggle-card {
        position: static;
        display: flex;
        justify-content: center;
        margin-bottom: 5px;
    }

    .theme-toggle-card .theme-toggle-track {
        width: 52px;
        height: 26px;
        padding: 0 6px;
    }

    .theme-toggle-card .theme-icon {
        width: 12px;
        height: 12px;
    }

    .theme-toggle-card .theme-toggle-thumb {
        top: 2px;
        left: 2px;
        width: 20px;
        height: 20px;
    }

    .theme-toggle-card .theme-toggle[aria-checked="true"] .theme-toggle-thumb {
        transform: translateX(26px);
    }
}

@media (max-width: 767px) {
    .theme-toggle-wrap {
        top: 12px;
        right: 12px;
    }

    .theme-toggle-wrap .theme-toggle-track {
        width: 68px;
        height: 34px;
    }

    .theme-toggle-wrap .theme-toggle-thumb {
        width: 26px;
        height: 26px;
        left: 6px;
    }

    .theme-toggle-wrap .theme-toggle[aria-checked="true"] .theme-toggle-thumb {
        transform: translateX(28px);
    }
}

/* Phones: round button, active icon only */
@media (max-width: 563px) {
    .theme-toggle-wrap .theme-toggle-track {
        width: 52px;
        height: 52px;
        padding: 0;
        justify-content: center;
        border-width: 2px;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.85);
    }

    .theme-toggle-wrap .theme-toggle[aria-checked="true"] .theme-toggle-track {
        background: rgba(15, 23, 42, 0.85);
    }

    .theme-toggle-wrap .theme-toggle-thumb,
    .theme-toggle-wrap .theme-moon,
    .theme-toggle-wrap .theme-toggle[aria-checked="true"] .theme-sun {
        display: none;
    }

    .theme-toggle-wrap .theme-toggle[aria-checked="true"] .theme-moon {
        display: flex;
    }

    .theme-toggle-wrap .theme-icon {
        width: 24px;
        height: 24px;
    }
}

/* App navbar */
.theme-toggle-nav .theme-toggle-track {
    width: 52px;
    height: 26px;
    padding: 0 6px;
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.13);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.theme-toggle-nav .theme-toggle:hover .theme-toggle-track {
    transform: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.20);
}

.theme-toggle-nav .theme-toggle[aria-checked="true"] .theme-toggle-track {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
}

.theme-toggle-nav .theme-toggle[aria-checked="true"]:hover .theme-toggle-track {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: none;
}

.theme-toggle-nav .theme-icon {
    width: 12px;
    height: 12px;
}

.theme-toggle-nav .theme-sun {
    color: #fbbf24;
}

.theme-toggle-nav .theme-moon {
    color: rgba(255, 255, 255, 0.40);
}

.theme-toggle-nav .theme-toggle[aria-checked="true"] .theme-sun {
    color: rgba(255, 255, 255, 0.35);
}

.theme-toggle-nav .theme-toggle[aria-checked="true"] .theme-moon {
    color: #e0e6ed;
}

.theme-toggle-nav .theme-toggle-thumb {
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.90);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.theme-toggle-nav .theme-toggle[aria-checked="true"] .theme-toggle-thumb {
    transform: translateX(26px);
    background: linear-gradient(135deg, #3ec8e0, #22b8cf);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

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

    .theme-toggle:hover .theme-toggle-track {
        transform: none;
    }
}
