/*=========================================================
THEME SELECTOR 2.0 - PREMIUM EDITION
=========================================================*/

#themeSelector{
    position:fixed;
    right:30px;
    bottom:30px;
    z-index:5000;
}

/*=========================================================
BOTÓN FLOTANTE
=========================================================*/

#themeButton{
    width:60px;
    height:60px;
    border:none;
    border-radius:50%;
    cursor:pointer;
    background:var(--secondary);
    color:var(--text-white);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:24px;
    box-shadow:0 8px 25px rgba(255, 127, 42, 0.4), var(--shadow-lg);
    transition:transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
               background 0.3s ease,
               box-shadow 0.3s ease;
}

#themeButton:hover{
    background:var(--secondary-hover);
    transform:translateY(-4px) scale(1.06);
    box-shadow:0 12px 30px rgba(255, 127, 42, 0.55);
}

#themeButton.spin i{
    animation:themeButtonSpin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes themeButtonSpin {
    0% { transform: rotate(0deg) scale(0.85); }
    50% { transform: rotate(180deg) scale(1.25); }
    100% { transform: rotate(360deg) scale(1); }
}

/*=========================================================
PANEL - FONDO SOLIDO CON SOMBRA ELEGANTE (SIN TRANSPARENCIA)
=========================================================*/

#themePanel{
    position:absolute;
    right:0;
    bottom:80px;
    width:290px;
    background-color:#ffffff !important;
    background:#ffffff !important;
    border:1px solid rgba(0, 0, 0, 0.12);
    border-radius:20px;
    box-shadow:0 20px 45px rgba(0, 0, 0, 0.22), 0 4px 14px rgba(0, 0, 0, 0.08);
    overflow:hidden;
    opacity:0;
    visibility:hidden;
    transform:translateY(16px) scale(0.96);
    transition:opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
               visibility 0.28s cubic-bezier(0.16, 1, 0.3, 1),
               transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
               background-color 0.35s ease;
    z-index:5001;
}

#themePanel.active{
    opacity:1 !important;
    visibility:visible !important;
    transform:translateY(0) scale(1) !important;
    background-color:#ffffff !important;
    background:#ffffff !important;
    border:1px solid rgba(0, 0, 0, 0.12) !important;
    box-shadow:0 20px 50px rgba(0, 0, 0, 0.28), 0 6px 18px rgba(0, 0, 0, 0.12) !important;
    z-index:5001 !important;
}

/*=========================================================
ENCABEZADO
=========================================================*/

.theme-header{
    display:flex;
    align-items:center;
    gap:14px;
    padding:18px 20px;
    background:#f7f9f5;
    background:var(--background-soft, #f7f9f5);
    border-bottom:1px solid rgba(0, 0, 0, 0.07);
    transition:background 0.35s ease;
}

.theme-header i{
    font-size:26px;
    color:var(--secondary);
    display:flex;
    align-items:center;
}

.theme-header h6{
    margin:0 0 2px 0;
    font-weight:700;
    font-size:0.98rem;
    color:var(--primary);
}

.theme-header small{
    display:block;
    color:var(--text-light);
    font-size:0.78rem;
}

/*=========================================================
LISTA DE OPCIONES
=========================================================*/

.theme-options{
    padding:14px 16px;
    background-color:#ffffff !important;
    background:#ffffff !important;
}

.theme-item{
    display:flex;
    align-items:center;
    gap:14px;
    padding:11px 14px;
    border-radius:12px;
    cursor:pointer;
    border:1px solid transparent;
    transition:background 0.22s ease,
               transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
               border-color 0.22s ease;
    margin-bottom:6px;
    position:relative;
    overflow:hidden;
}

.theme-item:hover{
    background:var(--background-soft, #f7f8f4);
    transform:translateX(5px);
}

/*=========================================================
NOMBRE Y CHECKMARK
=========================================================*/

.theme-name{
    flex:1;
    font-weight:600;
    font-size:0.92rem;
    color:var(--text-main, #172133);
    transition:color 0.25s ease;
}

.theme-item i{
    opacity:0;
    color:var(--secondary);
    font-size:18px;
    transform:scale(0) rotate(-45deg);
    transition:opacity 0.25s ease, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-item.active{
    background:rgba(111, 143, 58, 0.12);
    border-color:rgba(111, 143, 58, 0.24);
}

.theme-item.active i{
    opacity:1;
    transform:scale(1) rotate(0deg);
    animation:themeCheckBounce 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes themeCheckBounce {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; }
    60% { transform: scale(1.35) rotate(8deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/*=========================================================
CÍRCULOS DE COLOR CON PULSO
=========================================================*/

.theme-dot{
    width:22px;
    height:22px;
    border-radius:50%;
    border:2px solid rgba(0,0,0,.1);
    box-shadow:0 2px 6px rgba(0,0,0,0.12);
    transition:transform 0.25s ease;
}

.theme-item:hover .theme-dot{
    transform:scale(1.15);
}

.theme-item.active .theme-dot{
    animation:themeDotPulse 0.5s ease-out;
}

@keyframes themeDotPulse {
    0% { box-shadow: 0 0 0 0 rgba(111, 143, 58, 0.7); transform: scale(0.9); }
    50% { transform: scale(1.2); }
    100% { box-shadow: 0 0 0 10px rgba(111, 143, 58, 0); transform: scale(1); }
}

/* COLORES */
.theme-dot.geco{
    background:linear-gradient(135deg,#6f8f3a,#ff7f2a);
}

.theme-dot.ambiental{
    background:#43a047;
}

.theme-dot.ingenieria{
    background:#1976d2;
}

.theme-dot.ejecutivo{
    background:#607d8b;
}

.theme-dot.innovacion{
    background:#8e24aa;
}

.theme-dot.oscuro{
    background:linear-gradient(135deg, #1d1d1d, #383838);
}

/*=========================================================
DIVISOR Y PREVIEW
=========================================================*/

.theme-divider{
    border:none;
    border-top:1px solid rgba(0, 0, 0, 0.07);
    margin:6px 18px;
}

.theme-preview{
    padding:16px 18px 20px 18px;
    background:#fbfcf9;
    background:var(--background-soft, #f7f9f5);
    border-top:1px solid rgba(0, 0, 0, 0.05);
}

.theme-preview h6{
    font-weight:700;
    font-size:0.85rem;
    color:var(--primary);
    margin-bottom:12px;
}

.preview-card{
    border-radius:12px;
    overflow:hidden;
    background:#ffffff;
    background:var(--background, #ffffff);
    border:1px solid rgba(0, 0, 0, 0.08);
    box-shadow:0 3px 10px rgba(0, 0, 0, 0.06);
    transition:transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
               background 0.35s ease;
}

.preview-card.morphing{
    animation:previewMorph 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes previewMorph {
    0% { transform: scale(0.96); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.preview-navbar{
    height:28px;
    background:var(--primary);
    transition:background 0.35s ease;
}

.preview-content{
    padding:14px;
}

.preview-title{
    width:70%;
    height:9px;
    background:var(--text, #172133);
    border-radius:20px;
    margin-bottom:12px;
    opacity:.25;
    transition:background 0.35s ease;
}

.preview-button{
    width:48%;
    height:26px;
    border-radius:7px;
    background:var(--secondary);
    transition:background 0.35s ease;
}

/*=========================================================
ADAPTACIÓN MODO OSCURO PARA EL SELECTOR
=========================================================*/

html[data-theme="dark"] #themePanel,
html[data-theme="dark"] #themePanel.active{
    background-color:#1a222c !important;
    background:#1a222c !important;
    border:1px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow:0 25px 60px rgba(0, 0, 0, 0.75), 0 8px 24px rgba(0, 0, 0, 0.5) !important;
}

html[data-theme="dark"] .theme-options{
    background-color:#1a222c !important;
    background:#1a222c !important;
}

html[data-theme="dark"] .theme-header{
    background:#141b24;
    border-bottom:1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .theme-header h6{
    color:#ffffff;
}

html[data-theme="dark"] .theme-header small{
    color:#9ca3af;
}

html[data-theme="dark"] .theme-name{
    color:#f8fafc !important;
}

html[data-theme="dark"] .theme-item:hover{
    background:rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .theme-item.active{
    background:rgba(111, 143, 58, 0.22);
    border-color:rgba(111, 143, 58, 0.45);
}

html[data-theme="dark"] .theme-divider{
    border-top:1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .theme-preview{
    background:#141b24;
    border-top:1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .theme-preview h6{
    color:#e5e7eb;
}

html[data-theme="dark"] .preview-card{
    background:#1e2733;
    border:1px solid rgba(255, 255, 255, 0.1);
}

/*=========================================================
ANIMACIÓN DE TRANSICIÓN SUAVE GLOBAL (THEME CHANGE)
=========================================================*/

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
    transition: background-color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.35s ease,
                border-color 0.4s ease,
                box-shadow 0.4s ease,
                fill 0.4s ease !important;
    transition-delay: 0s !important;
}

/* Onda expansiva de luz al cambiar de tema */
#themeRippleOverlay{
    position:fixed;
    border-radius:50%;
    pointer-events:none;
    z-index:99998;
    transform:translate(-50%, -50%) scale(0);
    opacity:0.65;
    filter:blur(14px);
    transition:transform 0.65s cubic-bezier(0.2, 0.8, 0.2, 1),
               opacity 0.65s ease;
}

#themeRippleOverlay.active{
    transform:translate(-50%, -50%) scale(3.2);
    opacity:0;
}

/*=========================================================
RESPONSIVE
=========================================================*/

@media(max-width:768px){
    #themeSelector{
        right:16px;
        bottom:16px;
        z-index:99990;
    }
    #themeButton{
        width:50px;
        height:50px;
        font-size:22px;
    }
    #themePanel{
        position:fixed !important;
        left:16px !important;
        right:16px !important;
        bottom:76px !important;
        width:auto !important;
        max-width:calc(100vw - 32px) !important;
        max-height:calc(82vh - 80px) !important;
        overflow-y:auto !important;
        -webkit-overflow-scrolling:touch;
        z-index:99999 !important;
        box-shadow:0 15px 45px rgba(0, 0, 0, 0.45) !important;
    }
}