/* --- 1. BIẾN GLOBAL & CẤU HÌNH HỆ THỐNG --- */
:root {
    --bg-color: #0b0f19;
    --card-bg: linear-gradient(145deg, #111827, #0f172a);
    --card-border: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #00ffaa;
    --accent-hover: #00cc88;
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- 2. RESET & CẤU HÌNH CHUNG --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
html { scroll-behavior: smooth; }
body { background-color: var(--bg-color); color: var(--text-primary); line-height: 1.6; overflow-x: hidden; }
.navbar, .section, footer { position: relative; z-index: 10; }

/* --- 3. VIDEO BACKGROUND --- */
.video-bg-container {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: -100; overflow: hidden;
    pointer-events: none;
    background: var(--bg-color);
}
.video-bg {
    min-width: 100%; min-height: 100%;
    width: auto; height: auto;
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    object-fit: cover;
    filter: blur(2px);
    will-change: transform, opacity;
}
.video-overlay {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(11, 15, 25, 0.82);
    z-index: -99;
}

/* --- 4. NAVBAR --- */
.navbar {
    position: fixed; top: 0; width: 100%;
    padding: 20px 5%;
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(11, 15, 25, 0.75);
    backdrop-filter: blur(15px);
    border-bottom: 1px solid var(--card-border);
    z-index: 1000;
}
.logo { font-size: 1.6rem; font-weight: 700; letter-spacing: 1px; color: var(--text-primary); }
.accent { color: var(--accent); }
.nav-links { list-style: none; display: flex; gap: 25px; align-items: center; }
.nav-links a { text-decoration: none; color: var(--text-secondary); font-size: 0.9rem; font-weight: 600; transition: var(--transition); }
.nav-links a:hover, .nav-links a.active { color: var(--accent); text-shadow: 0 0 8px rgba(0, 255, 170, 0.5); }
.btn-cv-nav { background: rgba(0, 255, 170, 0.1); border: 1px solid var(--accent); padding: 6px 16px !important; border-radius: 6px; color: var(--accent) !important; }
.btn-cv-nav:hover { background: var(--accent) !important; color: var(--bg-color) !important; box-shadow: 0 0 15px var(--accent); }

/* --- 5. TYPING NEON GLOW --- */
.typed-text {
    color: var(--accent);
    text-shadow: 0 0 7px rgba(255,255,255,0.3), 0 0 10px var(--accent), 0 0 21px var(--accent), 0 0 42px var(--accent);
}
.cursor {
    display: inline-block; width: 3px; height: 1.1em;
    background-color: var(--accent); margin-left: 4px;
    vertical-align: middle;
    animation: blink 1s step-end infinite;
    box-shadow: 0 0 10px var(--accent);
}
.cursor.typing { animation: none; opacity: 1; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* --- 6. SCROLL INDICATORS --- */
.scroll-progress {
    position: fixed; top: 0; left: 0;
    height: 3px; background: var(--accent); width: 0%;
    z-index: 9999; box-shadow: 0 0 10px var(--accent);
}
.scroll-indicator {
    position: absolute; bottom: 5vh; left: 50%;
    transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-decoration: none; opacity: 0.6; transition: var(--transition);
}
.scroll-indicator:hover { opacity: 1; }
.scroll-indicator p { font-size: 0.7rem; letter-spacing: 2px; text-transform: uppercase; color: var(--text-secondary); }
.mouse { width: 22px; height: 32px; border: 2px solid var(--text-secondary); border-radius: 12px; display: flex; justify-content: center; padding-top: 5px; }
.wheel { width: 3px; height: 6px; background-color: var(--accent); border-radius: 2px; animation: scrollWheel 1.6s infinite; }
@keyframes scrollWheel { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(12px); opacity: 0; } }

/* --- 7. SECTION & REVEAL --- */
.section { padding: 120px 10%; min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.reveal { opacity: 0; transform: translateY(30px); transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.reveal.active { opacity: 1; transform: translateY(0); }
.section-title { font-size: 2.5rem; margin-bottom: 10px; font-weight: 700; }
.section-subtitle { color: var(--text-secondary); margin-bottom: 40px; max-width: 950px; font-size: 1.05rem; line-height: 1.7; }

/* --- 8. CARD --- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px; padding: 35px;
    transition: var(--transition);
}
.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
    border-color: rgba(0,255,170,0.4);
}

/* --- 9. HERO --- */
#hero { min-height: 100vh; align-items: center; text-align: center; }
.greeting { color: var(--accent); font-size: 1.2rem; font-weight: 600; margin-bottom: 15px; }
.hero-title { font-size: 3.8rem; line-height: 1.1; margin-bottom: 30px; }
.hero-desc { font-size: 1.15rem; color: var(--text-secondary); max-width: 650px; margin-bottom: 45px; text-align: center; }
.hero-cta { display: flex; gap: 20px; justify-content: center; }

/* --- 10. BUTTONS --- */
.btn {
    padding: 14px 30px; border-radius: 10px; text-decoration: none;
    font-weight: 600; transition: var(--transition);
    display: inline-flex; align-items: center; gap: 10px;
}
/* FIX: Added .btn-sm for project cards */
.btn-sm { padding: 9px 18px; font-size: 0.85rem; border-radius: 8px; }
.btn-primary { background-color: var(--accent); color: var(--bg-color); }
.btn-outline { color: var(--accent); border: 1px solid var(--accent); }
.btn-primary:hover, .btn-outline:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 5px 20px rgba(0,255,170,0.2); }

/* --- 11. SKILLS --- */
.skills-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 25px; }
.skill-tag {
    background: rgba(30,41,59,0.5); border: 1px solid var(--card-border);
    padding: 10px 18px; border-radius: 50px;
    font-size: 0.85rem; color: var(--text-secondary);
    transition: var(--transition);
}
.skill-tag:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,255,170,0.05); }

/* --- 12. AI AGENT CTA (ABOUT ME) --- */
/* FIX: Unified class name — HTML now uses .ai-agent-cta-frame (removed "reveal" suffix) */
.ai-agent-cta-frame {
    margin-top: 35px; padding: 25px; border-radius: 12px;
    background: rgba(30,41,59,0.3);
    border: 1px solid rgba(0,255,170,0.1);
    text-align: center; transition: var(--transition);
}
.ai-agent-cta-frame:hover {
    border-color: rgba(0,255,170,0.3);
    box-shadow: 0 0 15px rgba(0,255,170,0.05);
}
.btn-ai-cta {
    background: transparent; border: 2px solid var(--accent); color: var(--accent);
    padding: 10px 20px; font-size: 0.9rem; font-weight: 600; border-radius: 8px;
    cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
    text-transform: uppercase; letter-spacing: 1px; transition: var(--transition);
}
.btn-ai-cta:hover { background: var(--accent); color: var(--bg-color) !important; transform: translateY(-3px); box-shadow: 0 0 15px var(--accent); }
.btn-ai-cta i { font-size: 1.2rem; }

/* --- 13. IFRAME & PROJECT SWITCHER --- */
.project-switcher-container { display: flex; justify-content: center; margin-bottom: 30px; width: 100%; }
.project-switcher { display: flex; background: rgba(30,41,59,0.5); border: 1px solid var(--card-border); border-radius: 50px; padding: 6px; gap: 8px; backdrop-filter: blur(10px); }
.switcher-btn { background: transparent; border: none; color: var(--text-secondary); padding: 12px 25px; border-radius: 40px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: var(--transition); display: flex; align-items: center; gap: 8px; }
.switcher-btn:hover { color: var(--text-primary); }
.switcher-btn.active { background: var(--accent); color: var(--bg-color); box-shadow: 0 0 15px rgba(0,255,170,0.4); }
.switcher-btn i { font-size: 1.2rem; }

.iframe-container { height: auto; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.iframe-header { background: #1e293b; padding: 12px 20px; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f56; } .dot.yellow { background: #ffbd2e; } .dot.green { background: #27c93f; }
.iframe-title { color: #94a3b8; font-size: 0.8rem; margin-left: 10px; font-family: monospace; }
.iframe-wrapper { width: 100%; height: 80vh; min-height: 650px; border-radius: 0 0 10px 10px; overflow: hidden; position: relative; }
iframe { width: 100%; height: 100%; border: none; }

/* --- 14. PROJECTS --- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 30px; }
.tech-stack { color: var(--accent); font-size: 0.85rem; font-family: monospace; margin: 15px 0; }

/* --- 15. GITHUB CTA --- */
.github-cta { text-align: center; margin-top: 60px; padding: 40px; border-top: 1px solid var(--card-border); }
.github-cta p { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 25px; font-style: italic; }
.btn-github-more {
    background: transparent; border: 2px solid var(--accent); color: var(--accent);
    padding: 15px 35px; font-size: 1.1rem; border-radius: 12px;
    text-transform: uppercase; letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(0,255,170,0.1); transition: all 0.4s ease;
}
.btn-github-more:hover { background: var(--accent); color: var(--bg-color) !important; transform: translateY(-5px) scale(1.05); box-shadow: 0 0 30px var(--accent); }
.btn-github-more i { font-size: 1.4rem; }

/* --- 16. CONTACT --- */
.contact-links { display: flex; gap: 25px; justify-content: center; flex-wrap: wrap; }
.contact-item { color: var(--text-primary); text-decoration: none; display: flex; align-items: center; gap: 12px; font-size: 1.1rem; transition: var(--transition); }
.contact-item:hover { color: var(--accent); transform: translateY(-2px); }

/* --- 17. FOOTER --- */
footer { text-align: center; padding: 80px 20px; background: rgba(11,15,25,0.9); border-top: 1px solid var(--card-border); backdrop-filter: blur(10px); }
.footer-content strong { color: var(--accent); letter-spacing: 2.5px; text-shadow: 0 0 15px rgba(0,255,170,0.3); font-size: 1.1rem; }
.footer-sub { font-size: 0.8rem; margin-top: 15px; opacity: 0.5; text-transform: uppercase; letter-spacing: 2px; }

/* --- 18. CHATBOT --- */
.chatbot-container { position: fixed; bottom: 30px; right: 30px; z-index: 1000; font-family: 'Inter', sans-serif; }
.chat-toggle-btn {
    width: 65px; height: 65px; border-radius: 50%;
    background-color: #0f172a; color: var(--accent);
    border: 1px solid var(--card-border); font-size: 30px;
    cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.3s ease;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.chat-toggle-btn:hover { transform: scale(1.1); box-shadow: 0 0 15px rgba(0,255,170,0.3); }
.siri-sphere {
    position: absolute; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(0,255,170,0.5) 0%, rgba(72,0,255,0.4) 50%, rgba(0,0,0,0) 70%);
    filter: blur(2px); opacity: 0.8; transition: opacity 0.3s ease;
}
.siri-sphere.hidden { opacity: 0; pointer-events: none; }
.chat-toggle-btn.active #robot-icon { opacity: 0; }

.chat-window {
    position: absolute; bottom: 85px; right: 0;
    width: 350px; height: 480px;
    background-color: #0b0f19; border: 1px solid var(--card-border);
    border-radius: 18px; display: flex; flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8); overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom right;
}
.chat-window.hidden { opacity: 0; transform: scale(0); pointer-events: none; }

.chat-header {
    background-color: rgba(255,255,255,0.03); padding: 16px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--card-border);
}
.bot-name { font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
#close-chat-btn { background: none; border: none; color: var(--text-secondary); font-size: 20px; cursor: pointer; }

.chat-messages { flex-grow: 1; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 5px; }

.message { max-width: 80%; padding: 11px 16px; border-radius: 16px; font-size: 0.9rem; line-height: 1.5; }
.message.bot { background-color: rgba(255,255,255,0.04); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 3px; }
.message.user { background-color: var(--accent); color: var(--bg-color); align-self: flex-end; border-bottom-right-radius: 3px; font-weight: 600; }

/* FIX: Typing indicator animation */
.message.typing-indicator { opacity: 0.6; font-style: italic; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

.chat-input-area { display: flex; padding: 16px; border-top: 1px solid var(--card-border); gap: 10px; }
#chat-input { flex-grow: 1; background-color: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: 20px; padding: 10px 18px; color: var(--text-primary); outline: none; }
#chat-input:focus { border-color: var(--accent); }
#send-chat-btn { background-color: var(--accent); color: var(--bg-color); border: none; border-radius: 50%; width: 42px; height: 42px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
#send-chat-btn:hover { transform: scale(1.1); }

/* --- 19. RESPONSIVE --- */
@media (max-width: 768px) {
    .hero-title { font-size: 2.5rem; }
    .nav-links { display: none; }
    .section { padding: 80px 5%; }
    .hero-cta { flex-direction: column; }
    .project-switcher { flex-direction: column; border-radius: 20px; width: 100%; }
    .switcher-btn { width: 100%; justify-content: center; }
    .iframe-wrapper { height: 75vh; min-height: 500px; }
    .chatbot-container { bottom: 15px; right: 15px; }
    .chat-window { width: calc(100vw - 30px); height: 400px; right: 0; bottom: 75px; }
}

/* --- 20. THÊM MỚI: LANGUAGE TOGGLE SWITCH --- */
.lang-switch-container {
    margin-left: 20px;
    margin-right: auto;
    display: flex;
    align-items: center;
}

.lang-checkbox {
    display: none;
}

.lang-label {
    width: 65px;
    height: 32px;
    background-color: var(--card-border);
    border-radius: 50px;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    border: 1px solid rgba(0, 255, 170, 0.1);
    transition: var(--transition);
}

.lang-label:hover {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.2);
}

.lang-ball {
    width: 24px;
    height: 24px;
    background-color: var(--accent);
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 4px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
    box-shadow: 0 0 8px var(--accent);
}

/* Khi checkbox được check (sang Tiếng Anh - icon bên phải) */
.lang-checkbox:checked + .lang-label .lang-ball {
    transform: translateX(31px);
}

.lang-icon {
    font-size: 16px;
    z-index: 1;
    user-select: none;
    transition: opacity 0.3s ease;
}

/* Làm mờ icon không được chọn */
.lang-checkbox:checked + .lang-label .vi-icon { opacity: 0.3; }
.lang-checkbox:not(:checked) + .lang-label .en-icon { opacity: 0.3; }
.lang-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: opacity 0.3s ease;
}

.lang-icon img {
    display: block;
    border-radius: 2px; /* Bo góc nhẹ cho lá cờ nhìn hiện đại */
    object-fit: contain;
}

/* Giữ nguyên các logic mờ icon cũ của bạn */
.lang-checkbox:checked + .lang-label .vi-icon { opacity: 0.3; }
.lang-checkbox:not(:checked) + .lang-label .en-icon { opacity: 0.3; }