:root {
    --primary-color: #002d62;
    /* Màu xanh navy từ logo */
    --accent-color: #ffb800;
    /* Màu vàng cam từ logo */
    --text-color: #333;
    --light-bg: #f4f7f9;
    --white: #ffffff;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header & Nav */
header {
    background: #f8f9fa;
    /* Màu xám rất nhẹ để làm nổi bật logo trắng */
    padding: 0.8rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.logo img {
    height: 70px;
    /* Tăng kích thước logo một chút */
    display: block;
}

nav a {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 700;
    margin-left: 2rem;
    transition: var(--transition);
    text-transform: uppercase;
    font-size: 0.9rem;
}

nav a:hover {
    color: var(--accent-color);
}

/* Hero Section */
.hero {
    width: 100%;
    background: #002d62;
    /* Màu nền khớp với banner của bạn */
    overflow: hidden;
}

.hero-full-banner {
    width: 100%;
    line-height: 0;
}

.hero-full-banner img {
    width: 100%;
    height: auto;
    display: block;
}

.btn-primary {
    background: var(--accent-color);
    color: var(--primary-color);
    padding: 1rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    display: inline-block;
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 184, 0, 0.4);
}

/* Course Grid */
.container {
    padding: 4rem 5%;
}

.section-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 2.5rem;
}

/* Tab buttons */
.tab-btn {
    padding: 12px 25px;
    border: 2px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background: rgba(0, 45, 98, 0.05);
}

.tab-btn.active {
    background: var(--primary-color);
    color: var(--white);
}

/* Sub-filter buttons */
.sub-tab-btn {
    padding: 8px 18px;
    border: 1px solid #ddd;
    background: var(--white);
    color: #666;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.sub-tab-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sub-tab-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--primary-color);
}

/* Search Bar */
.search-bar-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 2px solid #e0e0e0;
    border-radius: 50px;
    padding: 10px 20px;
    width: 100%;
    max-width: 550px;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(0, 45, 98, 0.15);
}

.search-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.search-bar input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-color);
    background: transparent;
    font-family: 'Inter', sans-serif;
}

.search-bar input::placeholder {
    color: #aaa;
}

.search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 0.9rem;
    padding: 0 4px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.search-clear:hover {
    color: var(--primary-color);
}

.search-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px 20px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow);
    color: #888;
}

.search-empty h3 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.course-card {
    background: var(--white);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    /* Giúp khách nhận biết có thể click */
}

.card-click-area {
    width: 100%;
    height: 100%;
}

.course-card:hover {
    transform: translateY(-10px);
}

.course-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    /* Khung ảnh hình vuông 1:1 */
    height: auto;
    object-fit: contain;
    /* Tự động thu phóng để vừa khít, không bị cắt */
    background: #fff;
    /* Nền trắng hòa vào thẻ */
    border-bottom: 1px solid #f0f0f0;
    padding: 5px;
    /* Cách lề một chút cho thoáng */
}

.course-info {
    padding: 1.5rem;
}

.course-category {
    font-size: 0.8rem;
    color: var(--accent-color);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.course-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    height: 3.6rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.course-price {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
}

.btn-buy {
    width: 100%;
    padding: 0.8rem;
    border: none;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-buy:hover {
    background: #00408d;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 20px;
    max-width: 600px;
    width: 95%;
    position: relative;
    text-align: center;
    max-height: 90vh;
    /* Không vượt quá 90% chiều cao màn hình */
    overflow-y: auto;
    /* Hiện thanh cuộn nếu nội dung quá dài */
}

.close-modal {
    position: sticky;
    /* Giữ nút X cố định ở góc khi cuộn */
    top: 0;
    float: right;
    font-size: 2.5rem;
    cursor: pointer;
    color: #999;
    z-index: 10;
    margin-top: -1rem;
    margin-right: -0.5rem;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

.input-group {
    margin: 1.5rem 0;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 8px;
}

#qr-container img {
    max-width: 250px;
    margin: 1rem 0;
}

/* ============ Professional Footer ============ */
.main-footer {
    background: #001a3d;
    /* Tối hơn primary-color để tạo độ sâu */
    color: #e0e0e0;
    padding: 4rem 5% 1rem;
    font-size: 0.95rem;
    margin-top: 4rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

.brand-col .footer-logo {
    height: 70px;
    margin-bottom: 1.2rem;
}

.brand-col p {
    line-height: 1.6;
    color: #b0c4de;
    max-width: 350px;
}

.footer-col h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    position: relative;
    display: inline-block;
    font-weight: 700;
}

.footer-col h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -8px;
    width: 40px;
    height: 3px;
    background: var(--accent-color);
    border-radius: 2px;
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 1rem;
}

.footer-col ul li a {
    color: #b0c4de;
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.footer-col ul li a:hover {
    color: var(--accent-color);
    transform: translateX(5px);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    font-size: 0.85rem;
}

/* ============ Free Docs Section ============ */
.free-docs-section {
    background: linear-gradient(135deg, #f0f7ff 0%, #fafafa 100%);
    padding: 4rem 5%;
    border-top: 3px solid var(--accent-color);
}

.free-docs-container {
    max-width: 1200px;
    margin: 0 auto;
}

.free-docs-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.free-docs-header h2 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.free-docs-header p {
    color: #666;
    font-size: 1rem;
}

.free-docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
}

.free-doc-card {
    background: white;
    border-radius: 14px;
    padding: 1.2rem 1.4rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    border: 1px solid #e8f0fe;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.free-doc-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 45, 98, 0.12);
}

.free-doc-card--new {
    border: 2px solid var(--accent-color);
    background: linear-gradient(135deg, #fffef0, #ffffff);
}

.free-doc-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.free-doc-tag {
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.free-doc-subject {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary-color);
    background: #e8f0fe;
    padding: 3px 10px;
    border-radius: 20px;
}

.free-doc-date {
    font-size: 0.75rem;
    color: #999;
    margin-left: auto;
}

.free-doc-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: #222;
    line-height: 1.5;
    flex: 1;
}

.free-doc-btn {
    display: inline-block;
    text-align: center;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.free-doc-btn:hover {
    background: var(--accent-color);
    color: var(--primary-color);
}

/* ============ Free Docs Page (tailieu.html) ============ */
.nav-active {
    color: var(--accent-color) !important;
    font-weight: 800 !important;
}

.freedocs-hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, #004a9f 100%);
    padding: 4rem 5%;
    text-align: center;
    color: white;
}

.freedocs-hero-content h1 {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
}

.freedocs-hero-content p {
    font-size: 1rem;
    opacity: 0.85;
}

.freedocs-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 5%;
}

.freedocs-filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 2rem;
}

.fd-filter-btn {
    padding: 8px 18px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.fd-filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.fd-filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ============ Tối ưu giao diện cho Điện thoại & iPad ============ */
@media screen and (max-width: 768px) {

    /* Header */
    header {
        flex-direction: column;
        padding: 15px 5%;
    }

    .logo img {
        height: 60px;
        margin-bottom: 12px;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }

    nav a {
        margin-left: 0;
        font-size: 0.9rem;
    }

    /* Các nút Lọc */
    #filter-tabs,
    #sub-filter-tabs,
    .search-bar-container {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .tab-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .sub-tab-btn,
    .fd-filter-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Căn chỉnh lại Khoảng cách tổng thể */
    .container,
    .freedocs-main {
        padding: 2rem 5%;
    }

    .section-title {
        font-size: 1.8rem;
        margin-bottom: 1.5rem;
    }

    /* Khung Khóa học & Tài liệu */
    .course-grid,
    .free-docs-grid {
        grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
        /* Ép xuống 1 cột trên điện thoại */
        gap: 1.5rem;
    }

    /* Modal Thanh Toán */
    .modal-content {
        padding: 1.5rem;
        width: 100%;
        margin: 10px;
    }

    .close-modal {
        font-size: 2.2rem;
        top: 5px;
        right: 10px;
    }

    #qr-container img {
        max-width: 220px;
    }

    /* Bảng thông báo thành công */
    .success-card {
        padding: 30px 20px;
    }

    /* Footer Mobile */
    .footer-container {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .brand-col p {
        margin: 0 auto;
    }

    .footer-col h3::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .footer-col ul li a {
        justify-content: center;
    }
}