/* ========================================
   THEME SWITCHER STYLES — Redesigned
   Matches reference image: circles + light/dark buttons
   ======================================== */

/* Theme Variables - Default Orange Theme */
:root {
    --theme-primary: #D06818;
    --theme-secondary: #E87020;
    --theme-gradient: linear-gradient(135deg, #C85D10, #E07A22);
    --theme-light: rgba(208, 104, 24, 0.12);
    --theme-lighter: rgba(208, 104, 24, 0.06);
    --theme-dark: #A55614;
    --theme-text-on-primary: #ffffff;
    --theme-text-on-light: #D06818;
    --theme-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Trigger Button ───────────────────────────────────────── */
.theme-switcher-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.07);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--theme-transition);
    color: var(--theme-primary);
}

.theme-switcher-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--theme-primary);
    transform: scale(1.05);
}

.theme-switcher-btn i {
    font-size: 17px;
    color: var(--theme-primary);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-switcher-btn:hover i {
    transform: rotate(30deg);
}

/* Notification dot on btn */
.theme-switcher-btn::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--theme-primary);
    border: 1.5px solid var(--theme-primary);
    transition: background 0.3s ease;
}

/* Light mode btn */
[data-mode="light"] .theme-switcher-btn {
    background: rgba(7, 20, 35, 0.05);
    border-color: rgba(7, 20, 35, 0.12);
}

[data-mode="light"] .theme-switcher-btn:hover {
    background: rgba(7, 20, 35, 0.09);
}

/* ── Dropdown Panel ───────────────────────────────────────── */
.theme-dropdown {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    background: var(--bg-elevated) !important;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-color) !important;
    border-radius: 20px;
    padding: 0;
    width: 320px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.96);
    transition: var(--theme-transition);
    box-shadow: var(--shadow-xl) !important;
    overflow: hidden;
}

.theme-dropdown::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 14px;
    width: 14px;
    height: 14px;
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border-color) !important;
    border-right: none !important;
    border-bottom: none !important;
    transform: rotate(45deg);
    backdrop-filter: blur(24px);
}

.theme-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Light mode panel */
[data-mode="light"] .theme-dropdown {
    background: rgba(255, 255, 255, 0.97);
    border-color: rgba(30, 41, 59, 0.1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.07);
}

.theme-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-color) !important;
}

.theme-dropdown-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary) !important;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
}

.theme-dropdown-title i {
    color: var(--theme-primary);
    font-size: 14px;
}

[data-mode="light"] .theme-dropdown-title {
    color: rgba(15, 23, 42, 0.9) !important;
}

.theme-dropdown-close {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg-surface-2) !important;
    border: 1px solid var(--border-color) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--theme-transition);
    color: var(--text-secondary) !important;
    font-size: 12px;
}

.theme-dropdown-close:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
    color: #f87171 !important;
}

[data-mode="light"] .theme-dropdown-close {
    background: rgba(30, 41, 59, 0.06) !important;
    border-color: rgba(30, 41, 59, 0.1) !important;
    color: rgba(30, 41, 59, 0.45) !important;
}

[data-mode="light"] .theme-dropdown-close:hover {
    background: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    color: #dc2626 !important;
}

/* ── Theme Color Grid ─────────────────────────────────────── */
.theme-color-section {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-color) !important;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 0;
}

/* Theme Card — big circle style */
.theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
    font-family: 'Outfit', sans-serif;
}

.theme-card:hover {
    transform: translateY(-2px);
}

.theme-card:focus {
    outline: none;
}

.theme-card:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: 3px;
    border-radius: 50%;
}

/* Circle swatch */
.theme-preview-circle {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-card:hover .theme-preview-circle {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Active ring around circle */
.theme-card.active .theme-preview-circle {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15), 0 0 0 5px var(--theme-preview-color, #6820A8), 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Check icon on active */
.theme-check-icon {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--theme-preview-color, #6820A8);
    align-items: center;
    justify-content: center;
    color: var(--theme-preview-color, #6820A8);
    font-size: 9px;
    font-weight: 900;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-card.active .theme-check-icon {
    display: flex;
}

/* Theme name label */
.theme-name {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary) !important;
    margin: 0;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
}

.theme-name-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.theme-card.active .theme-name {
    color: var(--text-primary) !important;
}

[data-mode="light"] .theme-name {
    color: rgba(15, 23, 42, 0.6) !important;
}

[data-mode="light"] .theme-card.active .theme-name {
    color: rgba(15, 23, 42, 0.9) !important;
}

/* ── Appearance / Mode Toggle ─────────────────────────────── */
.mode-toggle-section {
    padding: 14px 20px 18px;
}

.mode-toggle-label {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary) !important;
    margin-bottom: 11px;
    letter-spacing: -0.01em;
}

[data-mode="light"] .mode-toggle-label {
    color: rgba(15, 23, 42, 0.8);
}

.mode-toggle-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mode-toggle-btn {
    padding: 10px 14px;
    border-radius: 12px;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--theme-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: rgba(248, 250, 252, 0.55);
    letter-spacing: -0.01em;
}

.mode-toggle-btn i {
    font-size: 13px;
}

.mode-toggle-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(248, 250, 252, 0.85);
    background: rgba(255, 255, 255, 0.08);
}

.mode-toggle-btn.active {
    border-color: var(--theme-primary);
    background: var(--theme-lighter, rgba(104, 32, 168, 0.12));
    color: var(--theme-primary);
}

[data-mode="light"] .mode-toggle-btn {
    background: rgba(30, 41, 59, 0.04);
    border-color: rgba(30, 41, 59, 0.12);
    color: rgba(30, 41, 59, 0.5);
}

[data-mode="light"] .mode-toggle-btn:hover {
    background: rgba(30, 41, 59, 0.07);
    border-color: rgba(30, 41, 59, 0.2);
    color: rgba(30, 41, 59, 0.8);
}

[data-mode="light"] .mode-toggle-btn.active {
    border-color: var(--theme-primary);
    background: var(--theme-lighter, rgba(104, 32, 168, 0.07));
    color: var(--theme-primary);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .theme-dropdown {
        position: fixed;
        top: 68px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100dvh - 80px);
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform-origin: top right;
    }

    .theme-dropdown::before {
        display: none;
    }

    .theme-color-section {
        padding-inline: 14px;
    }

    .theme-grid {
        gap: 14px 8px;
    }

    .theme-preview-circle {
        width: 54px;
        height: 54px;
    }
}

/* ── Theme Application — Global Styles ────────────────────── */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.btn-primary,
.btn.btn-primary {
    background: var(--theme-gradient) !important;
    border-color: var(--theme-primary) !important;
    transition: var(--theme-transition);
}

.btn-outline-primary {
    background: transparent !important;
    color: var(--theme-primary) !important;
}

.btn-outline-primary:hover {
    background: var(--theme-gradient) !important;
    color: white !important;
}

.progress-bar,
.sg-progress-bar-fill {
    background: var(--theme-gradient) !important;
}

.nav-link-layout.active,
.sidebar-link.active {
    color: var(--theme-primary) !important;
    background: var(--theme-lighter) !important;
    border-left: 3px solid var(--theme-primary);
}

.badge.bg-primary {
    background: var(--theme-primary) !important;
}

a.text-primary,
.text-primary {
    color: var(--theme-primary) !important;
}

.accent-icon {
    color: var(--theme-primary) !important;
}

.card-accent {
    border-top: 3px solid var(--theme-primary) !important;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

.navbar {
    border-bottom: 2px solid rgba(255, 255, 255, 0.07) !important;
}

.sg-card {
    transition: var(--theme-transition);
}

.sg-card:hover {
    border-color: var(--theme-light) !important;
}

.theme-card.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ── Keyboard Focus Styles ────────────────────────────────── */
.theme-card:focus-visible .theme-preview-circle {
    outline: 3px solid var(--theme-primary);
    outline-offset: 3px;
}