/* Dark Mode Toggle Enhancements - Fix untuk transisi yang mulus */
/* PRIORITY CSS - Override semua transition timing yang lain */

/* Enhanced Dark Mode Toggle */
.dark-mode-toggle {
    cursor: pointer !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    transition: all 0.2s ease !important;
}

.dark-mode-toggle:hover {
    transform: scale(1.02) !important;
}

/* Toggle Container - Force proper transition timing */
.toggle-container {
    width: 70px !important;
    height: 35px !important;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    border-radius: 35px !important;
    position: relative !important;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    border: 2px solid rgba(212, 175, 55, 0.3) !important;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.2),
        inset 0 2px 5px rgba(0, 0, 0, 0.3) !important;
    overflow: hidden !important;
}

/* Toggle Slider - Force proper transition timing */
.toggle-slider {
    width: 27px !important;
    height: 27px !important;
    background: linear-gradient(135deg, #d4af37 0%, #f4e17a 50%, #d4af37 100%) !important;
    border-radius: 50% !important;
    position: absolute !important;
    top: 2px !important;
    left: 2px !important;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(212, 175, 55, 0.4) !important;
    will-change: transform, background, box-shadow !important;
}

/* Toggle Icons - Force proper transition timing */
.toggle-slider i {
    font-size: 12px !important;
    color: #2c3e50 !important;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    position: absolute !important;
    will-change: opacity, transform !important;
}

/* Light Mode State (Default) */
.light-icon {
    opacity: 1 !important;
    transform: scale(1) rotate(0deg) !important;
    transition-delay: 0.1s !important; /* Slight delay for smoother icon transition */
}

.dark-icon {
    opacity: 0 !important;
    transform: scale(0.3) rotate(-180deg) !important;
    transition-delay: 0s !important;
}

/* Dark Mode Active State - FIXED dengan timing yang tepat */
body.dark-mode .toggle-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
    border-color: rgba(212, 175, 55, 0.6) !important;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(212, 175, 55, 0.2) !important;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

body.dark-mode .toggle-slider {
    transform: translateX(33px) !important;
    /* KEEP GOLD COLOR - bukan biru! */
    background: linear-gradient(135deg, #d4af37 0%, #f4e17a 50%, #d4af37 100%) !important;
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(212, 175, 55, 0.6),
        0 0 25px rgba(212, 175, 55, 0.3) !important;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

body.dark-mode .light-icon {
    opacity: 0 !important;
    transform: scale(0.3) rotate(180deg) !important;
    transition-delay: 0s !important;
}

body.dark-mode .dark-icon {
    opacity: 1 !important;
    transform: scale(1) rotate(0deg) !important;
    color: #1a1a1a !important;
    transition-delay: 0.1s !important;
}

body.dark-mode .light-icon {
    opacity: 0 !important;
    transform: scale(0.3) rotate(180deg) !important;
    transition-delay: 0s !important;
}

body.dark-mode .dark-icon {
    opacity: 1 !important;
    transform: scale(1) rotate(0deg) !important;
    color: #1a1a1a !important;
    transition-delay: 0.1s !important; /* Delay untuk icon muncul setelah slider bergerak */
}

/* Hover Effects */
.toggle-container:hover {
    transform: scale(1.05);
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.3),
        inset 0 2px 5px rgba(0, 0, 0, 0.3),
        0 0 25px rgba(212, 175, 55, 0.3);
}

body.dark-mode .toggle-container:hover {
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.5),
        inset 0 2px 5px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(212, 175, 55, 0.4) !important;
}

/* Active/Click State */
.toggle-container:active {
    transform: scale(0.98);
    transition: all 0.1s ease;
}

/* Keyframe animations untuk extra smoothness */
@keyframes slideToLight {
    0% { transform: translateX(33px); }
    100% { transform: translateX(2px); }
}

@keyframes slideToDark {
    0% { transform: translateX(2px); }
    100% { transform: translateX(33px); }
}

/* Apply animations untuk trigger manual jika diperlukan */
.toggle-slider.to-light {
    animation: slideToLight 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.toggle-slider.to-dark {
    animation: slideToDark 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .toggle-container {
        width: 60px;
        height: 30px;
    }
    
    .toggle-slider {
        width: 24px;
        height: 24px;
        top: 1px;
        left: 1px;
    }
    
    body.dark-mode .toggle-slider {
        transform: translateX(28px) !important;
    }
    
    .toggle-slider i {
        font-size: 10px;
    }
}

@media (max-width: 576px) {
    .dark-mode-toggle {
        display: none !important;
    }
}

/* Accessibility enhancements */
.dark-mode-toggle:focus {
    outline: 2px solid rgba(212, 175, 55, 0.5);
    outline-offset: 4px;
}

/* CRITICAL OVERRIDE - Mengatasi konflik dengan dark-mode.css */
/* File dark-mode.css memiliki rule: body.dark-mode * { transition: ... 0.4s ease } */
/* Yang menimpa transition timing toggle kita */

body.dark-mode .toggle-container,
body.dark-mode .toggle-slider,
body.dark-mode .toggle-slider i,
body.dark-mode .light-icon,
body.dark-mode .dark-icon {
    /* Force our timing untuk semua states */
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

/* Specificity tinggi untuk override body.dark-mode * rule */
body.dark-mode .dark-mode-toggle .toggle-container {
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

body.dark-mode .dark-mode-toggle .toggle-slider {
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

body.dark-mode .dark-mode-toggle .toggle-slider i {
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

/* Debug styles - uncomment for testing */
/*
.debug-mode .toggle-container {
    border: 2px solid red !important;
}
.debug-mode .toggle-slider {
    border: 2px solid blue !important;
}
*/

.dark-mode-toggle:focus-visible {
    outline: 2px solid rgba(212, 175, 55, 0.8);
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .toggle-container,
    .toggle-slider,
    .toggle-slider i,
    .light-icon,
    .dark-icon {
        transition: none !important;
        animation: none !important;
    }
}
