/**
 * 🎨 DARK MODE & THEME SWITCHER
 * Advanced theming system với smooth transitions
 */

:root {
    /* Light mode colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #2c3e50;
    --text-secondary: #666666;
    --border-color: #e1e8ed;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Brand colors */
    --brand-primary: #ff6b9d;
    --brand-secondary: #4ecdc4;
    --brand-accent: #45b7d1;
    
    /* Status colors */
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --error-color: #F44336;
    --info-color: #2196F3;
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --text-primary: #eaeaea;
    --text-secondary: #b8b8b8;
    --border-color: #2a2a3e;
    --shadow-color: rgba(0, 0, 0, 0.3);
    
    /* Adjust brand colors for dark mode */
    --brand-primary: #ff85aa;
    --brand-secondary: #5fd9cf;
    --brand-accent: #5ac7db;
}

/* Smooth transitions for theme switch */
body,
.blog-card,
.nav,
.footer,
.sidebar,
input,
textarea,
button {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    background: var(--brand-primary);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow-color);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(180deg);
    box-shadow: 0 6px 20px var(--shadow-color);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Reading Progress Bar */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary), var(--brand-accent));
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.1s ease;
    z-index: 9999;
}

/* Scroll Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animate-on-scroll {
    opacity: 0;
    animation: slideInUp 0.6s ease forwards;
}

.animate-on-scroll.slide-left {
    animation: slideInLeft 0.6s ease forwards;
}

.animate-on-scroll.slide-right {
    animation: slideInRight 0.6s ease forwards;
}

.animate-on-scroll.fade {
    animation: fadeIn 0.6s ease forwards;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, 
        var(--bg-secondary) 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        var(--bg-secondary) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.skeleton-title {
    height: 24px;
    width: 80%;
    margin-bottom: 15px;
    border-radius: 4px;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 12px;
}

/* Smooth Scroll Behavior */
html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--brand-primary);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand-accent);
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-color);
}

/* Pulse Animation for CTAs */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse-on-hover:hover {
    animation: pulse 1s infinite;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 999;
    background: var(--brand-accent);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--brand-primary);
    transform: translateY(-5px);
}

/* Loading Spinner */
.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-secondary);
    border-top: 4px solid var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Interactive Tooltips */
[data-tooltip] {
    position: relative;
    cursor: pointer;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Focus Styles for Accessibility */
*:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* Responsive Utilities */
@media (max-width: 768px) {
    .theme-toggle,
    .back-to-top {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .theme-toggle {
        bottom: 20px;
        right: 20px;
    }
    
    .back-to-top {
        bottom: 80px;
        right: 20px;
    }
}

/* Print Styles */
@media print {
    .theme-toggle,
    .back-to-top,
    .reading-progress-bar {
        display: none !important;
    }
}

/* Performance Optimization */
.blog-card,
.sidebar-widget,
.footer-section {
    will-change: transform;
    transform: translateZ(0);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}
