/* ==========================================
   📱 MOBILE PERFORMANCE OPTIMIZATION
   Tối ưu cực mạnh cho điện thoại
   ========================================== */

/* ==========================================
   1. MOBILE DETECTION & BASE OPTIMIZATIONS
   ========================================== */

@media (max-width: 768px) {
    :root {
        /* Giảm blur MẠNH cho mobile */
        --glass-blur: 12px !important;  /* Giảm từ 25px → 12px */
        --glass-saturate: 120% !important;  /* Giảm từ 150% → 120% */
    }

    /* Tắt morphing blobs trên mobile - QUÁ NẶNG */
    .blob {
        display: none !important;
    }

    /* Background đơn giản cho mobile */
    .liquid-bg {
        background: linear-gradient(135deg, 
            #0a0015 0%, 
            #1a0033 50%, 
            #0a0015 100%
        ) !important;
    }

    /* Glass effects nhẹ hơn */
    .glass-card {
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border-radius: 14px !important;
        box-shadow: 
            0 4px 16px rgba(0, 0, 0, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.1) !important;
    }

    /* Hover effects nhẹ hơn trên mobile */
    .glass-card:hover {
        transform: translateY(-4px) scale(1.005) !important;
        box-shadow: 
            0 8px 24px rgba(0, 0, 0, 0.4),
            0 0 30px rgba(156, 39, 176, 0.2) !important;
    }

    /* Navbar nhẹ */
    .glass-navbar {
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3) !important;
    }

    /* Inputs đơn giản */
    .glass-input {
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    }

    .glass-input:focus {
        transform: none !important;
        box-shadow: 
            0 0 0 2px rgba(156, 39, 176, 0.3) !important;
    }

    /* Modals nhẹ */
    .glass-modal .modal-content {
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.1) !important;
    }

    /* Tables đơn giản */
    .glass-table {
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }

    /* Buttons nhẹ */
    .btn-liquid {
        box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3) !important;
    }

    .btn-liquid:hover {
        transform: translateY(-2px) scale(1.01) !important;
        box-shadow: 0 6px 20px rgba(156, 39, 176, 0.4) !important;
    }
}

/* ==========================================
   2. TẮT ANIMATIONS NẶNG TRÊN MOBILE
   ========================================== */

@media (max-width: 768px) {
    /* Tắt float animations */
    .hero-logo,
    .navbar-logo {
        animation: none !important;
    }

    /* Tắt pulse animations */
    .feature-icon {
        animation: none !important;
    }

    /* Tắt particles */
    .glass-particles {
        display: none !important;
    }

    /* Tắt shimmer effects */
    .glass-card::before,
    .glass-card::after {
        display: none !important;
    }

    /* Tắt glow rotation */
    .glass-glow::after {
        display: none !important;
    }

    /* Đơn giản hóa transitions */
    * {
        transition-duration: 0.2s !important;
    }

    /* Giảm stagger delay */
    .ios-list-item {
        animation-delay: 0s !important;
    }

    /* Tắt parallax */
    .ios-parallax {
        transform: none !important;
    }

    /* Tắt morphing animations */
    @keyframes morph {
        0%, 100% { border-radius: 50%; }
    }

    @keyframes float {
        0%, 100% { transform: none; }
    }
}

/* ==========================================
   3. TEXT SHADOWS MOBILE - NHẸ HƠN
   ========================================== */

@media (max-width: 768px) {
    h1, h2, h3, h4, h5, h6 {
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) !important;
    }

    p, span, label, a {
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    }

    .text-glow {
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) !important;
    }
}

/* ==========================================
   4. MOBILE TOUCH OPTIMIZATIONS
   ========================================== */

@media (max-width: 768px) {
    /* Larger touch targets */
    .btn,
    button,
    a.btn {
        min-height: 44px;
        padding: 10px 20px !important;
    }

    /* Remove hover effects on touch */
    @media (hover: none) {
        *:hover {
            transform: none !important;
        }

        .glass-card:hover {
            box-shadow: 
                0 4px 16px rgba(0, 0, 0, 0.3),
                0 0 0 1px rgba(255, 255, 255, 0.1) !important;
        }
    }

    /* Simplified scrollbar */
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-thumb {
        background: rgba(156, 39, 176, 0.5);
        border-radius: 4px;
        box-shadow: none;
    }
}

/* ==========================================
   5. FONT SIZE & SPACING MOBILE
   ========================================== */

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    .card {
        margin-bottom: 1rem !important;
    }

    .navbar {
        padding: 0.5rem 1rem;
    }
}

/* ==========================================
   6. LOW-END DEVICE OPTIMIZATIONS
   ========================================== */

@media (max-width: 480px) {
    :root {
        --glass-blur: 8px !important;  /* CỰC NHẸ cho điện thoại yếu */
    }

    /* Tắt tất cả blur nặng */
    .glass-card,
    .glass-navbar,
    .glass-input,
    .glass-modal .modal-content,
    .glass-table {
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }

    /* Background đơn giản nhất */
    .liquid-bg {
        background: #1a0033 !important;
    }

    /* Tắt tất cả shadows phức tạp */
    .glass-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    }

    /* Tắt tất cả animations */
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================
   7. HARDWARE ACCELERATION
   ========================================== */

@media (max-width: 768px) {
    /* Force GPU acceleration cho elements quan trọng */
    .glass-card,
    .btn,
    .navbar {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }

    /* Avoid blur on moving elements */
    .glass-card:active,
    .btn:active {
        will-change: auto;
    }
}

/* ==========================================
   8. REDUCE MOTION (Battery Saving)
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .blob {
        display: none !important;
    }
}

/* ==========================================
   9. NETWORK OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    /* Lazy load images */
    img {
        content-visibility: auto;
    }

    /* Contain layout shifts */
    .card,
    .modal,
    .navbar {
        content-visibility: auto;
        contain-intrinsic-size: auto 200px;
    }
}

/* ==========================================
   10. SIMPLIFIED BADGE & ALERTS
   ========================================== */

@media (max-width: 768px) {
    .glass-badge {
        backdrop-filter: blur(6px) !important;
        box-shadow: 0 1px 4px rgba(156, 39, 176, 0.3) !important;
    }

    .glass-alert {
        backdrop-filter: blur(8px) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
    }
}

/* ==========================================
   11. TABLE MOBILE OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    .table-responsive {
        font-size: 13px;
    }

    .glass-table thead th {
        padding: 10px 8px !important;
        font-size: 0.75rem;
    }

    .glass-table tbody td {
        padding: 10px 8px !important;
    }

    /* Simplified table hover */
    .glass-table tbody tr:hover {
        background: rgba(156, 39, 176, 0.1) !important;
        box-shadow: none !important;
        transform: none !important;
    }
}

/* ==========================================
   12. MODAL MOBILE OPTIMIZATION
   ========================================== */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 16px !important;
    }

    .modal-body {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ==========================================
   13. PERFORMANCE HINTS
   ========================================== */

@media (max-width: 768px) {
    /* Optimize rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeSpeed;
    }

    /* Disable expensive properties */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Optimize images */
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

