/* ============================================
   ADVANCED UI/UX ENHANCEMENTS
   ============================================ */

/* ===== 1. DARK MODE TOGGLE ===== */
.dark-mode-toggle {
    position: fixed;
    bottom: 6rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 998;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.dark-mode-toggle:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.dark-mode-toggle .material-symbols-outlined {
    font-size: 24px;
    transition: transform 0.3s ease;
}

.dark-mode-toggle:hover .material-symbols-outlined {
    transform: rotate(180deg);
}

/* Dark mode body styles */
html.dark {
    color-scheme: dark;
}

/* ===== 2. IMPROVED LOADING SKELETON ===== */
.skeleton-loading {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-wave 1.5s ease-in-out infinite;
}

.dark .skeleton-loading {
    background: linear-gradient(90deg, #2a3441 25%, #1c2a36 50%, #2a3441 75%);
    background-size: 200% 100%;
}

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

.skeleton-text {
    height: 1em;
    border-radius: 4px;
    margin-bottom: 0.5em;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

.skeleton-image {
    width: 100%;
    height: 200px;
    border-radius: 12px;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* ===== 3. LAZY LOADING IMAGES WITH BLUR ===== */
.lazy-image {
    opacity: 0;
    transition: opacity 0.5s ease, filter 0.5s ease;
    filter: blur(20px);
}

.lazy-image.loaded {
    opacity: 1;
    filter: blur(0);
}

.image-placeholder {
    background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-placeholder::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 4. MOBILE NAVIGATION MENU ===== */
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 1000;
    padding: 1.5rem;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.dark .mobile-menu {
    background: #1c2a36;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.dark .mobile-menu-header {
    border-color: #374151;
}

.mobile-menu-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dark .mobile-menu-close {
    background: #374151;
    color: white;
}

.mobile-menu-close:hover {
    background: #e5e7eb;
    transform: rotate(90deg);
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-menu-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    color: #374151;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dark .mobile-menu-nav a {
    color: #d1d5db;
}

.mobile-menu-nav a:hover {
    background: linear-gradient(135deg, #667eea10 0%, #764ba210 100%);
    color: #667eea;
    transform: translateX(4px);
}

/* ===== 5. TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    animation: toast-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 400px;
}

.dark .toast {
    background: #1c2a36;
    color: white;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.toast.toast-out {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-success .toast-icon { background: #10b981; color: white; }
.toast-error .toast-icon { background: #ef4444; color: white; }
.toast-warning .toast-icon { background: #f59e0b; color: white; }
.toast-info .toast-icon { background: #3b82f6; color: white; }

.toast-message {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.dark .toast-message {
    color: #e5e7eb;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    padding: 4px;
    margin-left: auto;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #374151;
}

/* ===== 6. SCROLL ANIMATIONS ===== */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-animate.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.scroll-animate.from-left {
    transform: translateX(-30px);
}

.scroll-animate.from-left.animate-in {
    transform: translateX(0);
}

.scroll-animate.from-right {
    transform: translateX(30px);
}

.scroll-animate.from-right.animate-in {
    transform: translateX(0);
}

.scroll-animate.scale-in {
    transform: scale(0.9);
}

.scroll-animate.scale-in.animate-in {
    transform: scale(1);
}

/* Stagger animation delays */
.scroll-animate[data-delay="1"] { transition-delay: 0.1s; }
.scroll-animate[data-delay="2"] { transition-delay: 0.2s; }
.scroll-animate[data-delay="3"] { transition-delay: 0.3s; }
.scroll-animate[data-delay="4"] { transition-delay: 0.4s; }

/* ===== 7. READING PROGRESS BAR ===== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #2b8cee, #667eea, #764ba2);
    z-index: 9999;
    transition: width 0.1s ease;
}

.reading-progress::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4));
    animation: progress-shine 2s ease infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== 8. SOCIAL SHARE POPUP ===== */
.share-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.share-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.share-popup {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.dark .share-popup {
    background: #1c2a36;
}

.share-popup-overlay.active .share-popup {
    transform: scale(1) translateY(0);
}

.share-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.share-popup-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

.dark .share-popup-title {
    color: white;
}

.share-popup-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f3f4f6;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.dark .share-popup-close {
    background: #374151;
    color: white;
}

.share-popup-close:hover {
    background: #e5e7eb;
    transform: rotate(90deg);
}

.share-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.share-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.share-btn:hover {
    transform: translateY(-4px);
}

.share-btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.share-btn-facebook .share-btn-icon { background: #1877f2; }
.share-btn-twitter .share-btn-icon { background: #1da1f2; }
.share-btn-linkedin .share-btn-icon { background: #0a66c2; }
.share-btn-copy .share-btn-icon { background: linear-gradient(135deg, #667eea, #764ba2); }

.share-btn-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
}

.dark .share-btn-label {
    color: #9ca3af;
}

.share-url-box {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f3f4f6;
    border-radius: 12px;
}

.dark .share-url-box {
    background: #374151;
}

.share-url-input {
    flex: 1;
    background: none;
    border: none;
    font-size: 0.875rem;
    color: #374151;
    outline: none;
}

.dark .share-url-input {
    color: #e5e7eb;
}

.share-url-copy {
    padding: 0.5rem 1rem;
    background: #2b8cee;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-url-copy:hover {
    background: #1a6bb8;
}

/* ===== UTILITY ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.animate-pulse { animation: pulse 2s ease infinite; }
.animate-bounce { animation: bounce 1s ease infinite; }
.animate-shake { animation: shake 0.5s ease; }
