/* --- Khởi tạo Biến Màu sắc (Light/Dark Mode) --- */
:root {
    --bg-body: #f4f7f6;
    --bg-container: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --bg-element: #fdfdfd;
    --bg-menu: #f8f9fa;
    --border-color: #eeeeee;
    --btn-open-bg: #eef2f5;
    --btn-open-text: #333333;
}

[data-theme="dark"] {
    --bg-body: #121212;
    --bg-container: #1e1e1e;
    --text-primary: #f5f5f5;
    --text-secondary: #aaaaaa;
    --bg-element: #252525;
    --bg-menu: #2a2a2a;
    --border-color: #333333;
    --btn-open-bg: #333333;
    --btn-open-text: #f5f5f5;
}

/* --- Easter Egg: Matrix Mode --- */
body.matrix-mode {
    --bg-body: #000000;
    --bg-container: #0a0a0a;
    --text-primary: #00ff00;
    --text-secondary: #008800;
    --bg-element: #050505;
    --bg-menu: #111111;
    --border-color: #00ff00;
    --btn-open-bg: #00ff00;
    --btn-open-text: #000000;
}
.matrix-mode .avatar { border-color: #00ff00; filter: contrast(1.5) sepia(1) hue-rotate(80deg); }
.matrix-mode .skill, .matrix-mode .btn-copy, .matrix-mode .btn-primary { background: #00ff00; color: #000; }
.matrix-mode #particles-js canvas { filter: hue-rotate(90deg) brightness(1.5); }
.matrix-mode .tech-track img { filter: grayscale(100%) sepia(1) hue-rotate(80deg) saturate(5); }

/* --- Reset CSS --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Quicksand', sans-serif;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    padding: 20px 10px;
    position: relative;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 480px;
    background: var(--bg-container);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    overflow: hidden;
    padding: 20px;
    position: relative;
    z-index: 1; 
}

/* --- Loading Screen --- */
#loading-screen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--bg-container);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}
.spinner {
    width: 40px; height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
.matrix-mode .spinner { border-top: 4px solid #00ff00; }
.loading-text { font-weight: 600; color: var(--text-primary); text-align: center; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-hidden { opacity: 0; visibility: hidden; }

/* --- Dark Mode Toggle Button --- */
.theme-toggle-btn {
    position: absolute;
    top: 20px; right: 20px;
    background: var(--bg-menu);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px; height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.theme-toggle-btn:active { transform: scale(0.9); }

/* --- Header --- */
.header { text-align: center; margin-bottom: 20px; margin-top: 25px; }
.avatar { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid #007bff; padding: 3px; cursor: pointer; }
.name-box { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 10px 0 5px; }
.name { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.tick { width: 18px; height: 18px; }
.skills { display: flex; justify-content: center; gap: 10px; }
.skill { background: var(--bg-menu); padding: 5px 15px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

/* Avatar Shake Animation */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px) rotate(-5deg); }
    50% { transform: translateX(5px) rotate(5deg); }
    75% { transform: translateX(-5px) rotate(-5deg); }
    100% { transform: translateX(0); }
}
.shake-anim { animation: shake 0.3s ease-in-out; }

/* --- Tech Stack Slider --- */
.tech-slider {
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
    margin: 20px 0 5px 0;
    position: relative;
}
.tech-slider::before, .tech-slider::after {
    content: '';
    position: absolute;
    top: 0;
    width: 40px;
    height: 100%;
    z-index: 2;
}
.tech-slider::before { left: 0; background: linear-gradient(to right, var(--bg-container), transparent); }
.tech-slider::after { right: 0; background: linear-gradient(to left, var(--bg-container), transparent); }
.tech-track {
    display: inline-block;
    animation: scroll 12s linear infinite;
}
.tech-track img {
    height: 28px;
    margin: 0 15px;
    vertical-align: middle;
    filter: grayscale(100%);
    opacity: 0.7;
    transition: 0.3s;
}
.tech-track img:hover { filter: grayscale(0%); opacity: 1; }
@keyframes scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Menu (Tabs) --- */
.menu { display: flex; justify-content: space-between; list-style: none; background: var(--bg-menu); border-radius: 12px; padding: 5px; margin-bottom: 20px; }
.menu-item { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 10px; cursor: pointer; border-radius: 10px; transition: 0.3s; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.menu-item.active { background: var(--bg-container); color: #007bff; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.matrix-mode .menu-item.active { color: #00ff00; }

/* --- Content Sections --- */
.main-content { display: none; animation: fadeIn 0.4s ease-in-out; }
.main-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.content-header { font-size: 1.1rem; font-weight: 700; margin-bottom: 15px; border-left: 4px solid #007bff; padding-left: 10px; margin-top: 20px; color: var(--text-primary); }
.matrix-mode .content-header { border-left-color: #00ff00; }

/* --- Form QR Code --- */
.qr-generator { background: var(--bg-menu); padding: 15px; border-radius: 12px; border: 1px solid var(--border-color); margin-bottom: 20px; }
.input-field { width: 100%; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border-color); background: var(--bg-container); color: var(--text-primary); border-radius: 8px; font-size: 0.95rem; outline: none; transition: 0.2s; }
.input-field:focus { border-color: #007bff; }
.matrix-mode .input-field:focus { border-color: #00ff00; }
.btn-primary { width: 100%; background: #007bff; color: white; padding: 12px; border: none; border-radius: 8px; font-weight: 700; font-size: 1rem; cursor: pointer; transition: 0.2s; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.qr-result-box { text-align: center; margin-top: 15px; background: var(--bg-container); padding: 15px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.qr-result-box img { max-width: 200px; width: 100%; border-radius: 8px; }
.qr-note { font-size: 0.85rem; color: var(--text-secondary); margin-top: 10px; font-weight: 600; }

/* --- List Items --- */
.list { list-style: none; }
.list-item { display: flex; align-items: center; background: var(--bg-element); border: 1px solid var(--border-color); padding: 12px; border-radius: 12px; margin-bottom: 12px; transition: 0.2s; }
.list-item:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.05); border-color: #007bff; }
.matrix-mode .list-item:hover { border-color: #00ff00; }
.list-item__logo-box { flex-shrink: 0; } 
.list-item__logo-box img { width: 45px; height: 45px; border-radius: 10px; object-fit: cover; }
.list-item__detail { flex: 1; margin-left: 15px; overflow: hidden; text-align: left; }
.list-item__detail .title { font-weight: 700; font-size: 1rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item__detail .subtitle { font-weight: 600; font-size: 0.9rem; color: #007bff; }
.matrix-mode .list-item__detail .subtitle { color: #00ff00; }
.list-item__detail .desc { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Buttons --- */
.btn { flex-shrink: 0; padding: 8px 16px; border: none; border-radius: 8px; font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; text-align: center; white-space: nowrap; }
.btn-open { background: var(--btn-open-bg); color: var(--btn-open-text); }
.btn-copy { background: #007bff; color: #fff; }
.btn:active { transform: scale(0.95); }

/* --- Toast Notification --- */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: #28a745; color: #fff; padding: 10px 25px; border-radius: 50px; font-weight: 600; opacity: 0; transition: all 0.3s ease-in-out; box-shadow: 0 5px 15px rgba(0,0,0,0.2); z-index: 1000; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* --- Typing Effect --- */
#typing-text { display: inline-block; min-width: 120px; text-align: center; }
#typing-text::after { content: '|'; margin-left: 2px; opacity: 1; animation: blink 0.7s infinite; color: var(--text-secondary); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* --- Particles Background --- */
#particles-js { position: fixed; width: 100%; height: 100%; top: 0; left: 0; z-index: 0; }

/* --- Spotify Widget --- */
.spotify-container { margin-top: 15px; width: 100%; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border-radius: 12px; overflow: hidden; transition: 0.3s; }
[data-theme="dark"] .spotify-container, .matrix-mode .spotify-container { opacity: 0.9; }

/* ========================================================
   TỐI ƯU HÓA CHO ĐIỆN THOẠI (MOBILE RESPONSIVE)
   ======================================================== */
@media (max-width: 480px) {
    body { padding: 10px 5px; }
    .container { padding: 15px 12px; border-radius: 12px; }
    .header { margin-top: 35px; }
    .theme-toggle-btn { top: 12px; right: 12px; width: 35px; height: 35px; font-size: 1rem; }
    .avatar { width: 90px; height: 90px; }
    .name { font-size: 1.15rem; }
    .menu { padding: 4px; }
    .menu-item { padding: 8px 2px; font-size: 0.75rem; }
    .list-item { padding: 10px; }
    .list-item__logo-box img { width: 40px; height: 40px; }
    .list-item__detail { margin-left: 10px; }
    .list-item__detail .title { font-size: 0.95rem; }
    .list-item__detail .subtitle, .list-item__detail .desc { font-size: 0.75rem; }
    .btn { padding: 7px 12px; font-size: 0.75rem; }
}