/* Theme toggle + smooth theme transitions (dashboard + storefront) */

html {
    transition: color 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    transition:
        background-color 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* View Transitions API — smoother crossfade (ignored if unsupported) */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.55s;
    animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Toggle control ── */
.mgt-theme-toggle {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.9);
    color: #64748b;
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.35s ease,
        background 0.35s ease,
        border-color 0.35s ease,
        color 0.3s ease;
}

.mgt-theme-toggle:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 24px rgba(211, 47, 47, 0.15);
    border-color: #d32f2f;
    background: #ffffff;
    color: #d32f2f;
}

.mgt-theme-toggle:active {
    transform: scale(0.96);
}

.mgt-theme-toggle:focus-visible {
    outline: 2px solid #d32f2f;
    outline-offset: 3px;
}

/* Dark mode: inverted glass */
.mgt-theme-toggle.is-dark {
    background: linear-gradient(145deg, #1e293b, #070b14);
    color: #ef4444;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.mgt-theme-toggle.is-dark:hover {
    color: #ff5252;
    box-shadow:
        0 8px 28px rgba(239, 68, 68, 0.15),
        0 2px 10px rgba(0, 0, 0, 0.4);
}

.mgt-theme-toggle__icon {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    transition:
        opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

/* Light UI: show moon (go dark) */
.mgt-theme-toggle:not(.is-dark) .mgt-theme-toggle__icon--sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.mgt-theme-toggle:not(.is-dark) .mgt-theme-toggle__icon--moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Dark UI: show sun (go light) */
.mgt-theme-toggle.is-dark .mgt-theme-toggle__icon--moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.mgt-theme-toggle.is-dark .mgt-theme-toggle__icon--sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Dashboard header: match db-header-action sizing area */
.dashboard-body .mgt-theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
}

.dashboard-body .mgt-theme-toggle__icon {
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
}

/* Storefront: cluster with cart */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
