/* =========================================
   1. BIẾN MÀU SẮC & CẤU HÌNH (THEME CONFIG)
   ========================================= */
:root {
    /* --- MÀU CHỦ ĐẠO (GIỮ NGUYÊN) --- */
    --primary-green: #00ff41;
    --secondary-green: #03a062;
    --font-main: 'Inter', sans-serif;
    --font-code: 'Fira Code', monospace;

    /* --- GIAO DIỆN DARK (MẶC ĐỊNH) --- */
    --bg-body: #121212;          /* Nền chính */
    --bg-card: #1e1e1e;          /* Nền thẻ/khối */
    --bg-header: rgba(5, 5, 5, 0.8); /* Nền header */
    --text-main: #ffffff;        /* Màu chữ chính */
    --text-muted: #a0a0a0;       /* Màu chữ phụ */
    
    /* Hiệu ứng kính (Glassmorphism) cho nền tối */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    /* Form inputs */
    --input-bg: #0a0a0a;
    --input-border: #333;
}

/* --- GIAO DIỆN LIGHT (Clean & Minimalist cho Đọc báo) --- */
[data-theme="light"] {
    --bg-body: #ffffff;          /* Nền trắng tinh */
    --bg-card: #ffffff;          /* Card cũng trắng (hoà vào nền) */
    --bg-header: rgba(255, 255, 255, 0.95); /* Header trắng mờ */
    --text-main: #1a1a1a;        /* Chữ đen đậm (dễ đọc hơn màu xám) */
    --text-muted: #555555;       /* Chữ phụ */
    
    /* Tắt hiệu ứng kính ở Light Mode để đỡ rối mắt */
    --glass-bg: transparent; 
    --glass-border: transparent; /* Bỏ viền thẻ */

    --input-bg: #f5f5f5;         /* Nền ô nhập liệu xám nhẹ */
    --input-border: #e0e0e0;
    
    /* Màu xanh đậm hơn chút cho dễ nhìn trên nền trắng */
    --primary-green: #009933; 
}

/* Fix riêng cho Light Mode: Bỏ bóng đổ và viền để nhìn như trang giấy */
[data-theme="light"] .glass-card {
    box-shadow: none;
    border: none;
    background: transparent;
    padding-left: 0; /* Tận dụng không gian */
    padding-right: 0;
}

[data-theme="light"] header {
    border-bottom: 1px solid #eaeaea;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* =========================================
   2. RESET & GLOBAL STYLES
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-body); /* Đã dùng biến */
    color: var(--text-main);          /* Đã dùng biến */
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease; /* Hiệu ứng chuyển màu mượt */
}

/* --- CANVAS BACKGROUND (MATRIX) --- */
#matrix-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    opacity: 0.15;
    pointer-events: none;
    transition: opacity 0.3s;
}

/* Ẩn hoặc làm mờ Matrix khi sang nền trắng cho đỡ rối */
[data-theme="light"] #matrix-bg {
    opacity: 0.05; 
}

/* =========================================
   3. COMPONENTS & UTILITIES
   ========================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.section-padding { padding: 80px 0; }

.text-gradient {
    background: linear-gradient(90deg, var(--text-main), var(--primary-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    font-family: var(--font-code);
    white-space: nowrap !important; /* QUAN TRỌNG: Cấm xuống dòng trong nút */
}

.btn-primary {
    background: var(--primary-green);
    color: #000; /* Chữ trên nút xanh luôn là đen */
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.btn-primary:hover {
    background: var(--text-main);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

.btn-outline {
    border: 1px solid var(--primary-green);
    color: var(--primary-green);
    margin-left: 15px;
}

.btn-outline:hover {
    background: rgba(0, 255, 65, 0.1);
}

/* =========================================
   4. HEADER & NAVIGATION
   ========================================= */
header {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    background: var(--bg-header); /* Dùng biến */
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 0;
    transition: background 0.3s;
}

.nav-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--text-main);
}

.highlight { color: var(--primary-green); }

.nav-links {
    list-style: none;
    display: flex;
    gap: 30px;
    align-items: center; /* Căn giữa dọc */
}

.nav-links a {
    color: var(--text-main); /* Dùng biến */
    text-decoration: none;
    font-size: 17px;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover { color: var(--primary-green); }

.mobile-toggle {
    display: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-main);
}

/* --- CHỈNH RIÊNG CHO NÚT TRÊN HEADER --- */
header .btn-primary {
    padding: 8px 20px;  /* Giảm kích thước nút trên header */
    font-size: 17px;    
    border-radius: 4px;
    white-space: nowrap !important; /* Đảm bảo nút không bị gãy dòng */
}

/* =========================================
   5. NÚT CHUYỂN ĐỔI GIAO DIỆN (SWITCH)
   ========================================= */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 20px; 
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.theme-switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #333; /* Màu mặc định khi tắt */
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

/* Khi input checked (Light Mode) */
input:checked + .slider {
    background-color: var(--primary-green);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* =========================================
   6. HERO SECTION
   ========================================= */
.hero-section {
    height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    padding-top: 60px;
}

.tagline {
    font-family: var(--font-code);
    color: var(--primary-green);
    font-size: 14px;
    display: block;
    margin-bottom: 20px;
}

.hero-content h1 {
    font-size: 4rem;
    line-height: 1.1;
    margin-bottom: 20px;
    color: var(--text-main);
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-muted); /* Dùng biến */
    max-width: 600px;
    margin-bottom: 40px;
}

.hero-stats {
    display: flex;
    gap: 50px;
    margin-top: 60px;
    border-top: 1px solid var(--glass-border);
    padding-top: 30px;
}

.stat-item h3 {
    font-size: 2rem;
    color: var(--text-main);
}

.stat-item p {
    font-family: var(--font-code);
    font-size: 0.9rem;
    color: var(--primary-green);
    margin: 0;
}

/* =========================================
   7. SECTIONS & CARDS
   ========================================= */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 50px;
}

.glass-card {
    background: var(--glass-bg); /* Dùng biến */
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 16px;
    backdrop-filter: blur(5px);
    transition: transform 0.3s, border-color 0.3s, background 0.3s;
}

.glass-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary-green);
}

.highlight-card {
    border-color: var(--primary-green);
    background: rgba(0, 255, 65, 0.05); /* Giữ nhẹ màu xanh */
}

.icon-box {
    font-size: 3rem;
    color: var(--primary-green);
    margin-bottom: 20px;
}

.feature-list {
    list-style: none;
    margin-top: 20px;
}

.feature-list li {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: var(--text-muted); /* Dùng biến */
}

.feature-list i {
    color: var(--primary-green);
    margin-right: 10px;
}

/* --- ABOUT & PROCESS --- */
.bg-darker {
    background: var(--bg-card); /* Đổi từ cứng sang biến */
    padding: 20px; /* Thêm padding nhẹ nếu cần */
    border-radius: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    align-items: center;
}

.code-block {
    background: #111; /* Code block luôn nên tối màu cho dễ nhìn code */
    padding: 30px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-green);
    font-family: var(--font-code);
    color: #ccc;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.process-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 50px;
}

.step {
    text-align: center;
    position: relative;
}

.step-num {
    font-size: 3rem;
    font-weight: 900;
    font-family: var(--font-code);
}

.step h4 {
    color: var(--primary-green);
    margin: 10px 0;
}

.step p { color: var(--text-muted); }

/* =========================================
   8. FORMS & FOOTER
   ========================================= */
.glass-form-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
}

.contact-info {
    padding: 50px;
    background: rgba(0, 255, 65, 0.05);
}
.contact-info p { color: var(--text-muted); }

.contact-form { padding: 50px; }

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    background: var(--input-bg); /* Dùng biến */
    border: 1px solid var(--input-border); /* Dùng biến */
    color: var(--text-main); /* Dùng biến */
    border-radius: 4px;
    font-family: var(--font-main);
    transition: border 0.3s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-green);
}

.full-width { width: 100%; }

footer {
    border-top: 1px solid var(--glass-border);
    padding: 30px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--bg-body);
}

.socials { margin-top: 10px; }

.socials a {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin: 0 10px;
    transition: color 0.3s;
}

.socials a:hover { color: var(--primary-green); }

/* =========================================
   9. RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 768px) {
    /* --- HEADER MOBILE --- */
    header {
        padding: 10px 0; 
    }

    .nav-flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative; 
    }

    .nav-links {
        display: none; 
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--bg-header);
        flex-direction: column;
        padding: 20px;
        text-align: center;
        border-bottom: 1px solid var(--glass-border);
    }
    
    .nav-links.active {
        display: flex; 
    }

    /* Mobile: Ẩn nút Khởi tạo dự án to trên header để tiết kiệm chỗ */
    header .btn-primary {
        display: none; 
    }

    .logo {
        font-size: 18px; 
    }

    .theme-switch-wrapper {
        margin-left: auto;
        margin-right: 15px;
    }

    .mobile-toggle {
        display: block;
        font-size: 22px;
        color: var(--primary-green);
    }

    /* --- HERO MOBILE --- */
    .hero-section {
        padding-top: 100px;
        height: auto;
        padding-bottom: 40px;
        text-align: center;
    }

    .tagline { font-size: 12px; }

    .hero-content h1 {
        font-size: 1.8rem;
        line-height: 1.3;
        margin-bottom: 15px;
        padding: 0 10px;
    }

    .hero-content p {
        font-size: 0.95rem;
        padding: 0 15px;
        line-height: 1.5;
    }

    .hero-btns {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0 40px;
        margin-top: 20px;
    }

    .btn {
        width: 100%;
        margin: 0;
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    /* --- CONTENT MOBILE --- */
    .hero-stats {
        flex-direction: row; 
        justify-content: space-around;
        flex-wrap: wrap;
        gap: 15px;
        margin-top: 30px;
    }
    
    .stat-item h3 { font-size: 1.5rem; }
    
    .grid-2, .grid-3, .process-steps, .glass-form-container, .detail-container {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   10. ADD-ONS & UTILS
   ========================================= */
#projects { overflow: hidden; }

.swiper {
    width: 100%;
    padding-top: 50px;
    padding-bottom: 50px;
}

.swiper-slide {
    background-position: center;
    background-size: cover;
    width: 300px;
    height: 400px;
    border-radius: 15px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    filter: blur(2px) brightness(0.7); 
    transition: 0.3s;
}

.swiper-slide-active {
    filter: blur(0) brightness(1);
    border-color: var(--primary-green);
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.2);
}

.swiper-slide img {
    display: block;
    width: 100%;
    height: 70%;
    object-fit: cover;
}

.slide-content {
    padding: 15px;
    text-align: center;
    height: 30%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.slide-content h3 {
    color: var(--primary-green);
    font-family: var(--font-code);
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.slide-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.swiper-pagination-bullet { background: var(--text-muted); }
.swiper-pagination-bullet-active { background: var(--primary-green); }

/* Khi ở trang bài viết, làm mờ canvas */
body.is-article #matrix-bg {
    opacity: 0.02 !important; 
}

/* Tăng độ tương phản cho khung bài viết */
.article-detail, .glass-card {
    background: var(--bg-card);
    backdrop-filter: none;
    border: 1px solid var(--border-glass);
    box-shadow: 0 5px 7px rgba(0,0,0,0.5);
}

/* NÚT ĐỔI NGÔN NGỮ */
.lang-btn {
    display: flex;
    align-items: center;
    margin-left: 15px;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.lang-btn img {
    width: 40px;
    height: auto;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.lang-btn:hover {
    transform: scale(1.1);
    opacity: 0.9;
}

/* ======================================================
   11. GLOBAL: DESKTOP MENU FIX & ROLLING EFFECT
   (FIX LỖI CHỮ TIẾNG VIỆT BỊ TRÀN & NÚT BẤM)
   ====================================================== */
@media screen and (min-width: 992px) {
    
    /* 1. Mở rộng khung chứa để tận dụng màn hình */
    .container.nav-flex {
        max-width: 98% !important; /* Dùng 98% chiều rộng */
        padding-left: 15px;
        padding-right: 15px;
    }

    /* 2. Thu gọn khoảng cách menu (ÉP CÂN) */
    .nav-links {
        gap: 15px !important; /* Giảm từ 30px xuống 15px */
    }

    /* 3. Cấu hình thẻ Link (Menu) */
    .nav-links a {
        overflow: hidden !important; 
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        
        /* Fix kích thước chữ & khoảng cách */
        font-size: 1.15rem !important; /* Chữ nhỏ lại xíu cho gọn */
        height: 24px;       
        line-height: 24px;  
        padding: 0 5px;     /* Bỏ padding dọc */
        white-space: nowrap !important; /* CẤM XUỐNG DÒNG */
        
        text-decoration: none;
        vertical-align: middle;
    }

    /* 4. Hiệu ứng Rolling Text (Chữ nẩy) */
    .nav-text-wrapper {
        display: block;
        position: relative;
        line-height: 24px;
        transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    }

    .nav-text-wrapper::after {
        content: attr(data-text); 
        position: absolute;
        left: 0;
        top: 100%; 
        width: 100%;
        height: 100%;
        color: var(--primary-green, #00ff41); 
        transform: translate3d(0, 0, 0); 
    }

    .nav-links a:hover .nav-text-wrapper {
        transform: translateY(-100%); 
    }
    
    .nav-links a.active-link .nav-text-wrapper {
        transform: translateY(-100%);
    }

    /* 5. Fix Nút "Khởi tạo dự án" & Logo không bị chồng lấn */
    header .btn-primary {
        white-space: nowrap !important;
        min-width: fit-content;
        margin-left: 10px; /* Thêm chút khoảng cách với menu */
    }
}