/*
Theme Name: Portfolio Minimalist
Theme URI: https://example.com
Author: Your Name
Author URI: https://example.com
Description: Giao diện Portfolio tối giản hỗ trợ Dark Mode và Responsive.
Version: 1.1
Text Domain: portfolio-minimalist
*/

/* ==================== COLOR PALETTE & ERGONOMICS ==================== */
:root[data-theme="light"] {
    --bg-color: #fdfdfc;         
    --card-bg: #ffffff;          
    --sidebar-bg: #f4f4f0;       
    --text-primary: #242826;     
    --text-secondary: #5c605d;   
    --border-color: #e3e3dc;     
    --accent-color: #2b569a;     
    --hover-bg: #eaeaea;         
    --shadow-color: rgba(0,0,0,0.03);
}

:root[data-theme="dark"] {
    --bg-color: #18191a;         
    --card-bg: #222426;          
    --sidebar-bg: #1f2022;       
    --text-primary: #d1d5db;     
    --text-secondary: #9ca3af;   
    --border-color: #2e3235;     
    --accent-color: #60a5fa;     
    --hover-bg: #2a2d30;         
    --shadow-color: rgba(0,0,0,0.25);
}

/* ==================== GLOBAL STYLES ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== TOGGLE BUTTON & SIDEBAR ==================== */
.toggle-btn-outer {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 99;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

body:not(.sidebar-collapsed) .toggle-btn-outer {
    opacity: 0;
    visibility: hidden;
}

.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px 15px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
}

.close-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    min-width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-box {
    position: relative;
    flex-grow: 1;
}

.search-box input[type="search"] {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
}

.search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    fill: var(--text-secondary);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-links li a {
    text-decoration: none;
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    display: block;
}

.nav-links li.current-menu-item a,
.nav-links li a:hover {
    background-color: var(--hover-bg);
    color: var(--accent-color);
}

/* ==================== MAIN CONTENT AREA ==================== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 40px 5%;
    transition: margin-left 0.3s ease, width 0.3s ease;
    width: calc(100% - 280px);
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
    width: 100%;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Profile Section & Projects Grid */
.profile-section { text-align: center; margin-bottom: 50px; }
.avatar-container { width: 110px; height: 110px; margin: 0 auto 15px; border-radius: 50%; border: 2px solid var(--border-color); padding: 4px; background: var(--card-bg); }
.avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-name { font-size: 1.8rem; font-weight: 600; color: var(--text-primary); margin-bottom: 5px; }
.profile-bio { font-size: 0.95rem; color: var(--text-secondary); max-width: 500px; margin: 0 auto; }

.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; width: 100%; }

/* NÂNG CẤP: Phóng to nhẹ và Click toàn bộ Card */
.project-card { 
    background-color: var(--card-bg); 
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s ease, border-color 0.25s ease;
}

.project-card:hover {
    transform: translateY(-4px) scale(1.015);
    box-shadow: 0 10px 25px var(--shadow-color);
    border-color: var(--accent-color);
}

.card-image { width: 100%; height: 180px; background-color: var(--hover-bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.project-card:hover .card-image img { transform: scale(1.05); }

.card-body { padding: 20px; display: flex; flex-direction: column; flex-grow: 1; }
.card-title { font-size: 1.1rem; font-weight: 500; margin-bottom: 8px; }
.card-title a { color: inherit; text-decoration: none; }

/* Tạo lớp bao phủ toàn bộ thẻ bài viết từ thẻ <a> của tiêu đề */
.card-title a::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
}

.card-description { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 20px; flex-grow: 1; }

/* NÂNG CẤP: Giữ nút Categories/Tags có thể click độc lập */
.card-tags { 
    display: flex; 
    gap: 6px; 
    flex-wrap: wrap; 
    margin-bottom: 15px; 
    position: relative; 
    z-index: 2; 
}
.tag { 
    font-size: 0.75rem; 
    padding: 3px 8px; 
    border-radius: 4px; 
    background-color: var(--hover-bg); 
    color: var(--text-secondary); 
    text-decoration: none; 
    transition: background-color 0.2s ease, color 0.2s ease;
}
.tag:hover {
    background-color: var(--accent-color);
    color: #ffffff;
}

.card-link { text-decoration: none; font-size: 0.85rem; font-weight: 500; color: var(--accent-color); }

/* ==================== SINGLE POST ==================== */
.single-post-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 20px 0 60px 0;
}

.post-header {
    margin-bottom: 35px;
    text-align: left;
}

.post-meta {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.post-meta a {
    color: var(--text-secondary);
    text-decoration: none;
}

.post-meta a:hover {
    color: var(--accent-color);
}

.meta-sep {
    margin: 0 6px;
}

.post-title {
    font-size: 2.2rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.post-content {
    font-size: 1.125rem;
    line-height: 1.78;
    color: var(--text-primary);
    word-break: break-word;
}

.post-content p {
    margin-bottom: 1.6em;
}

.post-content h2, 
.post-content h3, 
.post-content h4 {
    color: var(--text-primary);
    line-height: 1.3;
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    font-weight: 600;
}

.post-content h2 { font-size: 1.5rem; }
.post-content h3 { font-size: 1.28rem; }

.post-content a {
    color: var(--accent-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-content blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: 20px;
    margin: 1.8em 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content ul, 
.post-content ol {
    margin-bottom: 1.6em;
    padding-left: 24px;
}

.post-content li {
    margin-bottom: 0.5em;
}

.post-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.post-tags .tag-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.post-tags a {
    display: inline-block;
    background: var(--hover-bg);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.82rem;
    text-decoration: none;
    margin-left: 6px;
}

.post-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.92rem;
}

.post-navigation a {
    color: var(--accent-color);
    text-decoration: none;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.post-navigation a:hover {
    text-decoration: underline;
}

/* ==================== CLASSIC EDITOR HORIZONTAL GALLERY ==================== */
.classic-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 2em 0;
    width: 100%;
}

.classic-gallery .gallery-item {
    flex: 1 1 calc(33.333% - 12px);
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--hover-bg);
}

.classic-gallery .gallery-item img {
    width: 100%;
    height: 100%;
    min-height: 160px;
    max-height: 240px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.classic-gallery .gallery-item img:hover {
    transform: scale(1.03);
}

.classic-gallery.gallery-cols-1 .gallery-item { flex: 1 1 100%; }
.classic-gallery.gallery-cols-2 .gallery-item { flex: 1 1 calc(50% - 12px); }
.classic-gallery.gallery-cols-3 .gallery-item { flex: 1 1 calc(33.333% - 12px); }
.classic-gallery.gallery-cols-4 .gallery-item { flex: 1 1 calc(25% - 12px); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .projects-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .main-content { margin-left: 0 !important; width: 100% !important; }
    .projects-grid { grid-template-columns: 1fr; }
    .single-post-container { padding: 10px 0 40px 0; }
    .post-title { font-size: 1.75rem; }
    .post-content { font-size: 1.05rem; }
    .classic-gallery .gallery-item { flex: 1 1 calc(50% - 12px) !important; }
}