/* ==========================================================================
   1. VARIABLES (Biến toàn cục)
   ========================================================================== */
:root {
    /* Colors */
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --card-bg: #1e1e1e;       /* Phục hồi biến màu cho Blog */
    --text-primary: #e0e0e0;
    --text-color: #e0e0e0;    /* Phục hồi biến màu chữ cho Blog */
    --text-secondary: #a0a0a0;
    --accent-color: #61afef;
    
    /* Z-index */
    --z-navbar: 1000;
    --z-modal: 2000;
    --z-sidebar: 100;
}

/* ==========================================================================
   2. BASE & RESET (Thiết lập gốc)
   ========================================================================== */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

h1, h2, h3 {
    color: var(--text-primary);
}

/* ==========================================================================
   3. LAYOUTS (Cấu trúc khung trang)
   ========================================================================== */
.container {
    width: 90%;
    max-width: 1000px;
    margin: 40px auto;
    padding: 20px;
}

/* ==========================================================================
   4. COMPONENTS (Thành phần tái sử dụng)
   ========================================================================== */

/* --- 4.1 Buttons (Nút bấm) --- */
.btn, .btn-view-pdf {
    display: inline-block;
    padding: 12px 28px;
    text-decoration: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 4px 10px rgba(97, 175, 239, 0.2);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(97, 175, 239, 0.5);
    background-color: #7bc0ff;
}

/* Phục hồi nút GitHub */
.btn-outline {
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    background-color: transparent;
}

.btn-outline:hover {
    transform: translateY(-3px);
    background-color: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 8px 20px rgba(97, 175, 239, 0.4);
}

/* --- 4.2 Navbar & Logo --- */
.navbar {
    background-color: var(--surface-color);
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #333;
    position: sticky; 
    top: 0;           
    z-index: var(--z-navbar);    
}

/* Phục hồi hiệu ứng Logo */
.logo {
    font-size: 24px;
    font-weight: bold;
    font-family: 'Courier New', Courier, monospace; 
    color: var(--accent-color);
}

.logo a {
    color: var(--accent-color);
    text-decoration: none;
    display: inline-block; 
    transition: all 0.3s ease; 
}

.logo a:hover {
    color: #ffffff; 
    text-shadow: 0 0 15px var(--accent-color), 0 0 30px var(--accent-color); 
    transform: scale(1.08) rotate(-2deg); 
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 30px;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    position: relative; 
    transition: color 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--accent-color);
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;           
    height: 2px;        
    bottom: -6px;       
    left: 0;            
    background-color: var(--accent-color);
    transition: width 0.3s ease; 
}

.nav-links a:hover::after, .nav-links a.active::after {
    width: 100%;        
}

/* --- 4.3 Modal & Popup --- */
.modal {
    display: none; 
    position: fixed;
    z-index: var(--z-modal); 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); 
    backdrop-filter: blur(5px); 
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1e1e1e;
    width: 90%;
    max-width: 1000px;
    height: 85vh; 
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background-color: #2d2d2d;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
    color: #fff;
    font-weight: bold;
    font-size: 1.1rem;
}

.close-btn {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #ff4757; 
}

.modal-body {
    flex-grow: 1; 
    background-color: #333;
}

/* --- 4.4 Tags Sidebar --- */
.tags-sidebar {
    position: fixed;
    top: 150px;          
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: var(--z-sidebar);
    left: max(20px, calc(50% - 660px));
}

.tag-btn {
    background-color: var(--surface-color);
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: bold;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    width: 200px;            /* Ép tất cả các nút ở mọi trang đều rộng đúng 240px */
    box-sizing: border-box;
}

.tag-btn:hover {
    color: var(--accent-color);
    border-left-color: var(--accent-color); 
    transform: translateX(8px); 
}

@media (max-width: 1300px) {
    .tags-sidebar {
        display: none;
    }
}

/* ==========================================================================
   5. PAGES (Định dạng riêng cho từng trang)
   ========================================================================== */

/* --- 5.1 Trang Chủ (Hero Section & Projects) --- */
.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}

.hero-text {
    flex: 1; 
}

.hero-image {
    flex-basis: 280px; 
    text-align: center;
}

.hero-image img {
    width: 100%;
    max-width: 250px;
    aspect-ratio: 1 / 1; 
    object-fit: cover; 
    border-radius: 50%; 
    border: 4px solid var(--accent-color); 
    box-shadow: 0 0 25px rgba(97, 175, 239, 0.3); 
    transition: transform 0.3s ease; 
}

.hero-image img:hover {
    transform: scale(1.05); 
}

@media (max-width: 768px) {
    .hero-section {
        flex-direction: column-reverse;
        text-align: center;
    }
}

/* Phục hồi giao diện khối Dự án */
.project-item {
    background-color: var(--surface-color);
    padding: 40px 50px;
    border-radius: 12px;
    margin-bottom: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease; 
    scroll-margin-top: 90px; 
}

.project-item img {
    max-width: 100%;
    height: auto;
}

.project-item:hover {
    transform: translateY(-8px); 
    box-shadow: 0 12px 30px rgba(97, 175, 239, 0.15); 
}

/* --- 5.2 Trang Tech Blog --- */
.blog-container {
    max-width: 800px; 
    margin: 40px auto;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.blog-cover {
    width: 100%;
    height: 350px;
    object-fit: cover;
    display: block;
}

.blog-header {
    padding: 30px 40px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.blog-title {
    color: var(--accent-color);
    font-size: 2.2rem;
    line-height: 1.4;
    margin-bottom: 15px;
}

.blog-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: monospace;
}

.blog-meta span {
    margin-right: 15px;
}

.blog-content {
    padding: 20px 40px;
    color: var(--text-color);
    line-height: 1.8;
    font-size: 1.1rem;
}

.blog-content h3 {
    color: var(--accent-color);
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5rem;
    scroll-margin-top: 90px; /* Phục hồi lỗi bị menu che khuất */
}

.blog-content pre {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    border-left: 4px solid var(--accent-color);
    margin: 20px 0;
}

.blog-content code {
    font-family: 'Consolas', 'Courier New', monospace;
    color: #d4d4d4;
    font-size: 0.95rem;
}

.blog-content p code {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: #ff9d00;
}

.blog-footer {
    padding: 20px 40px 40px;
}

.blog-footer hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

/* Phục hồi hộp Action Box ở cuối Blog */
.action-box {
    background-color: rgba(0, 255, 204, 0.05); 
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.action-box h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
}

.action-box p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 20px;
}