/* ================================================= */
/* 1. GLOBAL RESET & BASE STYLES (Chuẩn hóa)         */
/* ================================================= */
* {
    box-sizing: border-box; /* Quan trọng: Giúp padding không làm vỡ khung */
    -webkit-tap-highlight-color: transparent; /* Bỏ highlight xanh khi bấm trên mobile */
}

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: url("hinhanh/background.jpg") no-repeat center center fixed;
    background-size: cover;
    background-attachment: fixed;
    color: #f8fafc;
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden; /* Chặn thanh cuộn ngang thừa */
}

a { text-decoration: none; transition: 0.3s; }
ul { list-style: none; padding: 0; margin: 0; }
img { max-width: 100%; height: auto; display: block; }

/* Ẩn nút 3 gạch mặc định trên PC */
.menu-toggle { display: none; }

/* ================================================= */
/* 2. COMPONENT CHUNG (Container, Button, Title)     */
/* ================================================= */
.container, .shop-container, .detail-container, .cart-wrapper, .history-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%; /* Đảm bảo không tràn màn hình */
}

/* Tiêu đề section */
.section-header { text-align: center; margin-bottom: 40px; margin-top: 40px; }
.section-header h2 {
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    color: white;
}
.divider { height: 4px; width: 60px; background: #10b981; margin: 0 auto; border-radius: 2px; }

/* Nút bấm chung (Hiệu ứng đẹp) */
button, .btn-buy-now, .btn-confirm-buy, .btn-filter {
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
}
button:active { transform: scale(0.98); }

/* ================================================= */
/* 3. HERO BANNER (Trang chủ)                        */
/* ================================================= */
.hero, .hero-slider {
    position: relative;
    width: 100%;
    height: 500px; /* Chiều cao chuẩn PC */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}
.hero img, .slide {
    width: 100%; height: 100%; object-fit: cover;
}
.hero-content {
    position: relative; z-index: 10; text-align: center; padding: 20px; width: 100%;
}
.main-title {
    font-size: 48px; font-weight: 900; text-transform: uppercase; 
    margin-bottom: 20px; text-shadow: 0 4px 10px rgba(0,0,0,0.8);
    line-height: 1.2;
}
.sub-title {
    color: #4ade80; font-weight: 700; letter-spacing: 3px; font-size: 18px;
}

/* ================================================= */
/* 4. PRODUCT GRID (Lưới sản phẩm thông minh)        */
/* ================================================= */
.game-grid, .product-grid {
    display: grid;
    /* Tự động chia cột: Tối thiểu 240px, còn lại chia đều */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.game-card, .product-card {
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex; flex-direction: column;
}
.game-card:hover, .product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    border-color: #4f46e5;
}

.card-thumb, .card-image {
    height: 180px; width: 100%; position: relative; overflow: hidden;
}
.card-thumb img, .card-image img {
    width: 100%; height: 100%; object-fit: cover; transition: 0.5s;
}
.product-card:hover img { transform: scale(1.1); }

.card-details, .card-info { padding: 15px; flex-grow: 1; }
.card-title, .card-info h3 {
    font-size: 16px; font-weight: 700; margin: 0 0 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; /* Cắt chữ nếu dài */
    color: white;
}
.card-price { color: #ef4444; font-weight: bold; font-size: 18px; }

/* ================================================= */
/* 5. TABLES (Bảng Giỏ hàng/Lịch sử)                 */
/* ================================================= */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); }
th { background: rgba(0,0,0,0.2); color: #94a3b8; font-size: 14px; text-transform: uppercase; }

/* Wrapper để bảng cuộn ngang trên mobile */
.table-responsive {
    width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
}

/* ================================================= */
/* 6. MODAL & POPUP                                  */
/* ================================================= */
.modal {
    display: none; position: fixed; z-index: 2000;
    left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    justify-content: center; align-items: center;
}
.modal-content {
    background: #1e293b; width: 90%; max-width: 500px;
    border-radius: 16px; border: 1px solid #334155;
    animation: zoomIn 0.3s ease; position: relative;
    max-height: 90vh; overflow-y: auto; /* Cuộn nếu dài */
}
@keyframes zoomIn { from {transform: scale(0.9); opacity: 0;} to {transform: scale(1); opacity: 1;} }

/* ================================================= */
/* 7. FAKE NOTIFY (Thông báo ảo)                     */
/* ================================================= */
.fake-notify {
    position: fixed; top: 90px; right: 20px;
    background: rgba(15, 23, 42, 0.95); border-left: 4px solid #10b981;
    padding: 12px 15px; border-radius: 6px; color: white;
    z-index: 9999; font-size: 13px; max-width: 280px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5); display: none;
    animation: slideInRight 0.5s ease;
}
@keyframes slideInRight { from {transform: translateX(100%);} to {transform: translateX(0);} }
.fake-notify strong { color: #10b981; }
.fake-notify .time { display: block; font-size: 11px; color: #64748b; margin-top: 3px; }


/* ================================================= */
/* ---------------- RESPONSIVE (QUAN TRỌNG) -------- */
/* ================================================= */

/* --- TABLET & MOBILE (Dưới 768px) --- */
@media (max-width: 768px) {
    /* 1. Header & Menu */
    .nav-container {
        padding: 0 15px; height: 60px;
        display: flex; justify-content: space-between; align-items: center;
    }
    
    .logo img { height: 32px; }
    .logo span { font-size: 16px; }

    /* Nút 3 gạch hiện lên */
    .menu-toggle {
        display: block; font-size: 24px; color: white; margin-left: 15px;
    }

    /* Menu trượt từ phải sang */
    .nav-menu {
        position: fixed; top: 60px; right: -100%;
        width: 75%; height: calc(100vh - 60px);
        background: #0f172a; flex-direction: column;
        padding: 20px; transition: 0.3s;
        border-left: 1px solid #334155;
        align-items: flex-start; /* Chữ căn trái */
        z-index: 998;
        box-shadow: -5px 0 20px rgba(0,0,0,0.5);
    }
    .nav-menu.active { right: 0; }
    .nav-menu li { width: 100%; border-bottom: 1px solid #1e293b; margin-bottom: 0; }
    .nav-menu li a { display: block; padding: 15px 0; font-size: 16px; }

    /* Nút Đăng nhập (Fix lỗi vỡ layout) */
    .nav-container > div:last-child {
        display: flex; align-items: center; margin-left: auto;
    }
    .btn-login-nav {
        font-size: 12px !important; padding: 6px 12px !important;
        white-space: nowrap; height: 32px; line-height: 20px;
    }
    .nav-username { display: none !important; } /* Ẩn tên dài */
    .user-trigger { padding: 0 !important; background: none !important; }
    .user-trigger i { display: none; }

    /* 2. Hero Banner */
    .hero, .hero-slider { height: 280px; } /* Banner thấp lại */
    .main-title { font-size: 24px; margin-bottom: 10px; }
    .sub-title { font-size: 12px; }
    .hero-desc { font-size: 13px; padding: 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .btn-explore { padding: 10px 25px; font-size: 13px; }

    /* 3. Grid Sản phẩm (2 cột giống Shopee) */
    .game-grid, .product-grid {
        grid-template-columns: repeat(2, 1fr); /* Ép buộc 2 cột */
        gap: 10px;
    }
    .card-thumb, .card-image { height: 110px; }
    .card-title { font-size: 13px; margin-bottom: 2px; }
    .card-price { font-size: 15px; }
    .card-details { padding: 10px; }
    .card-attributes { display: none; } /* Ẩn bớt thông tin phụ cho gọn */
    .btn-buy-now { font-size: 12px; padding: 8px; }

    /* 4. Trang Chi tiết */
    .detail-container {
        grid-template-columns: 1fr; /* Xếp dọc */
        margin-top: 80px; padding: 10px;
    }
    .main-img { height: 250px; }
    .action-btns { flex-direction: column; gap: 10px; }
    .action-btns button { width: 100%; padding: 12px; font-size: 16px; }

    /* 5. Shop Layout */
    .shop-container {
        grid-template-columns: 1fr; /* Bỏ sidebar */
        padding: 10px; margin-top: 70px;
    }
    .filter-card { margin-bottom: 20px; }

    /* 6. Table (Giỏ hàng) */
    .cart-wrapper, .history-container {
        margin-top: 80px; padding: 0 10px;
    }
    /* Biến bảng thành dạng thẻ hoặc cho cuộn ngang */
    .cart-table, .data-table {
        display: block; width: 100%; overflow-x: auto; white-space: nowrap;
    }
    .cart-item-img { width: 50px; height: 50px; }

    /* 7. Footer */
    .footer-container {
        grid-template-columns: 1fr; text-align: center; gap: 30px;
    }
    .social-icons { justify-content: center; }
    .footer-col img { margin: 0 auto 20px !important; }
}

/* --- MOBILE NHỎ (Dưới 400px - iPhone 5/SE) --- */
@media (max-width: 400px) {
    .main-title { font-size: 20px; }
    .btn-login-nav { font-size: 11px !important; padding: 5px 8px !important; }
    .logo span { display: none; } /* Ẩn tên shop, chỉ hiện logo nếu màn quá bé */
}