/* ==========================================================================
   1. CORE VARIABLES & RESET
   ========================================================================== */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --primary-light: #eef2ff;
    --text-main: #2b2d42;
    --text-muted: #6c757d;
    --bg-body: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #e9ecef;
    
    /* Status Colors */
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;

    /* Layout & Effects */
    --radius: 10px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
    --transition: all 0.2s ease-in-out;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Inter, sans-serif; }
body { background-color: var(--bg-body); color: var(--text-main); line-height: 1.6; font-size: 14px; }
a { text-decoration: none; color: inherit; transition: var(--transition); }
ul { list-style: none; }
button, input, select, textarea { font-family: inherit; outline: none; }

/* ==========================================================================
   2. LAYOUT CONTAINERS & HEADERS
   ========================================================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Trang chủ */
.header {
    background-color: var(--bg-white);
    padding: 15px 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}
.brand h1 { font-size: 1.6rem; color: var(--primary-color); font-weight: 800; margin: 0; text-transform: uppercase; letter-spacing: 0.5px; }

/* Header Trang PC Pro (Gradient) */
.header-pro {
    background: linear-gradient(135deg, var(--primary-color), #3a56d4);
    color: white;
    padding: 40px 30px;
    text-align: center;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.header-pro h1 { font-size: 2.5rem; margin: 0 0 10px 0; color: white; text-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.header-pro p { opacity: 0.9; font-size: 1.1rem; margin-bottom: 20px; }

/* ==========================================================================
   3. BUTTONS & ACTIONS
   ========================================================================== */
.btn-refresh, .btn-back {
    padding: 8px 20px; border-radius: 30px; font-weight: 700; cursor: pointer; border: none;
    display: inline-flex; align-items: center; gap: 8px; transition: var(--transition); font-size: 0.9rem;
}

/* Nút Reset/Làm mới */
.btn-refresh { background: var(--primary-light); color: var(--primary-color); }
.btn-refresh:hover { background: #dbeafe; transform: translateY(-2px); }

/* Nút Quay lại */
.btn-back { background: rgba(255,255,255,0.2); color: white; backdrop-filter: blur(5px); }
.btn-back:hover { background: white; color: var(--primary-color); }

/* Nút Chọn Linh Kiện */
.btn-select {
    padding: 7px 18px; background: var(--primary-color); color: white; border-radius: 6px;
    border: none; font-weight: 600; cursor: pointer; font-size: 0.85rem; transition: var(--transition);
}
.btn-select:hover { background: var(--primary-hover); box-shadow: 0 3px 10px rgba(67, 97, 238, 0.3); }

/* Nút Phân Tích/Mua Ngay */
.btn-analyze, .btn-buy {
    width: 100%; padding: 12px; background: linear-gradient(135deg, #4361ee, #3a56d4); color: white;
    border: none; border-radius: 8px; font-weight: 800; font-size: 1rem; cursor: pointer;
    box-shadow: var(--shadow-md); transition: var(--transition); text-align: center;
}
.btn-analyze { border-radius: 50px; margin-top: 15px; }
.btn-analyze:hover, .btn-buy:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(67, 97, 238, 0.3); }

/* Nút Lưu Ảnh */
#btn-save-image {
    width: 100%; padding: 12px; background-color: var(--success-color); color: white;
    border: none; border-radius: 6px; font-weight: 700; cursor: pointer; margin-top: 20px;
    display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition);
}
#btn-save-image:hover { background-color: #157347; }

/* Class ẩn khi chụp ảnh */
.hide-on-capture { display: block; }
body.no-print .hide-on-capture { display: none !important; }

/* ==========================================================================
   4. TABS NAVIGATION
   ========================================================================== */
.main-tabs { display: flex; justify-content: center; gap: 15px; margin-bottom: 30px; flex-wrap: wrap; }
.main-tab-btn {
    padding: 12px 30px; border: none; background: #fff; border-radius: 30px;
    font-weight: 700; color: #666; cursor: pointer; box-shadow: var(--shadow-sm);
    transition: var(--transition); font-size: 1rem; text-decoration: none; display: inline-block;
}
.main-tab-btn:hover { transform: translateY(-2px); color: var(--primary-color); }
.main-tab-btn.active {
    background: var(--primary-color); color: white;
    box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}

.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   5. BUILDER UI (TRANG CHỦ - TAB 1)
   ========================================================================== */
.builder-layout { display: flex; gap: 25px; align-items: flex-start; }
.component-list { flex: 2.5; }
.sidebar { flex: 1; position: sticky; top: 20px; }

/* Item Linh Kiện */
.component-item {
    background: var(--bg-white); border-radius: 12px; padding: 15px 20px; margin-bottom: 12px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center; transition: var(--transition);
}
.component-item:hover { border-color: var(--primary-color); transform: translateX(5px); }

.comp-info { display: flex; align-items: center; gap: 15px; overflow: hidden; flex: 1; }
.icon-box {
    width: 45px; height: 45px; background: var(--primary-light); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; color: var(--primary-color); font-size: 1.2rem; flex-shrink: 0;
}
.comp-details { display: flex; flex-direction: column; }
.comp-label { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.selected-name { font-size: 0.9rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 400px; }
.selected-name.has-selection { color: var(--primary-color); font-weight: 600; }

/* Ô Nhập Số Lượng (Quantity) */
.qty-control {
    display: flex; align-items: center; gap: 5px; background: #f0f2f5;
    padding: 4px 8px; border-radius: 6px; border: 1px solid #ddd;
}
.qty-label { font-size: 0.75rem; font-weight: 600; color: #666; }
.qty-input {
    width: 45px; text-align: center; border: 1px solid #ccc; border-radius: 4px;
    padding: 2px; font-weight: bold; color: var(--primary-color);
}

/* Sidebar Panels */
.panel {
    background: var(--bg-white); border-radius: 12px; padding: 25px; margin-bottom: 20px;
    box-shadow: var(--shadow-md); border: 1px solid var(--border-color);
}
.panel h3 { font-size: 1.1rem; margin: 0 0 15px 0; border-bottom: 2px solid var(--bg-body); padding-bottom: 10px; color: var(--text-main); }

/* Progress Bar Hiệu Năng */
.performance-metric { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 700; margin-bottom: 5px; }
.progress-bar { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; margin-bottom: 15px; }
.progress-bar div { height: 100%; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); border-radius: 4px; }
#progress_gaming { background: var(--success-color); }
#progress_design { background: var(--warning-color); }

/* Thông tin Giá & Nguồn */
.power-info p { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.95rem; border-bottom: 1px dashed #eee; padding-bottom: 5px; }
.total-price-display { font-size: 1.8rem; font-weight: 800; color: var(--primary-color); text-align: right; padding-top: 10px; }
.currency { font-size: 0.6em; vertical-align: top; }

.compatibility-msg { font-size: 0.9rem; padding: 12px; background: var(--bg-body); border-radius: 8px; line-height: 1.5; min-height: 60px; }

/* ==========================================================================
   6. CONFIGURATION & FILTER UI (TAB 2 & 3)
   ========================================================================== */
/* Filter Bar */
.filter-bar {
    background: #fff; padding: 20px; border-radius: 12px; margin-bottom: 25px;
    display: flex; flex-wrap: wrap; gap: 15px; border: 1px solid #eee; align-items: center;
    box-shadow: var(--shadow-sm);
}
.filter-group { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 300px; }
.filter-select { padding: 10px 15px; border: 1px solid #ddd; border-radius: 8px; outline: none; flex: 1; cursor: pointer; background: #fff; }
.config-search-box { position: relative; flex: 1; min-width: 250px; }
.config-search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #999; }
.config-search-box input { width: 100%; padding: 10px 15px 10px 40px; border: 1px solid #ddd; border-radius: 8px; outline: none; transition: border 0.2s; }
.config-search-box input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-light); }

/* Checkbox Filter Area */
.app-filter-wrapper { display: flex; gap: 25px; flex-wrap: wrap; margin-bottom: 30px; }
.game-filter-container {
    flex: 1; background: #fff; padding: 20px; border-radius: 12px;
    border: 1px solid #eee; min-width: 300px; box-shadow: var(--shadow-sm);
}
.game-filter-label { font-size: 0.9rem; font-weight: 800; margin-bottom: 15px; display: block; border-bottom: 1px solid #eee; padding-bottom: 8px; }
.lbl-game { color: #7950f2; }
.lbl-soft { color: #0ca678; }

.game-checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.game-check-item {
    cursor: pointer; background: #f8f9fa; padding: 6px 14px; border-radius: 20px;
    border: 1px solid #e9ecef; font-size: 0.85rem; transition: 0.2s; user-select: none; color: #555;
}
.game-check-item:hover { border-color: var(--primary-color); background: #fff; }
.game-check-item input { display: none; }
.game-check-item.checked {
    background: var(--primary-light); color: var(--primary-color);
    border-color: var(--primary-color); font-weight: 700;
    box-shadow: 0 2px 5px rgba(67, 97, 238, 0.2);
}

/* Expand/Collapse Button */
.filter-expand-content { max-height: 130px; overflow: hidden; transition: max-height 0.4s ease-in-out; position: relative; }
.filter-expand-content.expanded { max-height: 2000px; }
.btn-expand-toggle {
    display: block; width: 100%; text-align: center; background: #f1f3f5; border: none;
    padding: 8px; cursor: pointer; color: #666; font-size: 0.8rem; font-weight: 600;
    margin-top: 15px; border-radius: 6px; transition: 0.2s;
}
.btn-expand-toggle:hover { background: #e9ecef; color: #333; }

/* Config Grid & Card */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; }
.config-card {
    background: #fff; border: 1px solid #eee; border-radius: 12px; overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); position: relative;
}
.config-card:hover { transform: translateY(-8px); box-shadow: 0 15px 30px rgba(0,0,0,0.1); border-color: var(--primary-light); }

.config-header { background: #f8f9fa; padding: 15px 20px; border-bottom: 1px solid #eee; }
.config-tag { padding: 4px 10px; font-size: 0.7rem; font-weight: 700; border-radius: 6px; letter-spacing: 0.5px; text-transform: uppercase; }
.tag-GAMING { background: #e0cffc; color: #5f3dc4; }
.tag-OFFICE { background: #c3fae8; color: #0ca678; }
.tag-DESIGN { background: #ffec99; color: #e67700; }
.config-header h3 { margin: 10px 0 0; font-size: 1.15rem; color: var(--text-main); line-height: 1.3; }

.config-body { padding: 20px; }
.spec-row { font-size: 0.9rem; color: #555; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.spec-row i { width: 20px; color: #aaa; text-align: center; }
.spec-row span { font-weight: 500; }

/* Cập nhật trong style.css */

.config-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #fff;
    display: flex;
    justify-content: space-between; /* Đẩy 2 phần tử ra 2 bên */
    align-items: center; /* Căn giữa theo chiều dọc */
    gap: 15px; /* Khoảng cách an toàn giữa giá và nút */
}

.config-price {
    font-weight: 800;
    color: #d63384;
    font-size: 1.2rem;
    white-space: nowrap; /* Không cho giá tiền xuống dòng */
}

.btn-buy {
    display: inline-block; /* Đổi từ block sang inline-block */
    width: auto; /* Để nút tự co giãn theo nội dung */
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: 0.2s;
    font-size: 0.9rem;
    text-align: center;
    white-space: nowrap; /* Không cho chữ trong nút xuống dòng */
}

.btn-buy:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Game Tags in Card */
.game-tag-list { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.mini-tag { font-size: 0.7rem; background: #f3f0ff; color: #7950f2; padding: 2px 8px; border-radius: 4px; border: 1px solid #e5dbff; white-space: nowrap; }

/* ==========================================================================
   7. ALERTS & CHECK ITEMS (TAB 3)
   ========================================================================== */
.check-list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 15px; }
.check-item { background: #f8f9fa; border: 1px solid #eee; padding: 12px; border-radius: 8px; display: flex; gap: 12px; align-items: center; }
.check-item.empty { opacity: 0.6; border-style: dashed; }
.check-item i { font-size: 1.2rem; }

.alert-box { padding: 15px; border-radius: 8px; margin-bottom: 15px; border-left: 5px solid transparent; font-size: 0.95rem; line-height: 1.5; }
.alert-box.error { background: #fff5f5; border-color: #ff6b6b; color: #c92a2a; }
.alert-box.warning { background: #fff9db; border-color: #fcc419; color: #e67700; }
.alert-box.success { background: #ebfbee; border-color: #51cf66; color: #2b8a3e; }
.alert-title { font-weight: 800; display: block; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.alert-box ul { margin: 0; padding-left: 20px; }

/* ==========================================================================
   8. MODAL (POPUP)
   ========================================================================== */
.modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 9999; backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: #fff; width: 650px; margin: 4% auto; border-radius: 12px;
    overflow: hidden; box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    animation: slideDown 0.3s ease-out;
    max-height: 90vh; display: flex; flex-direction: column;
}

.modal-header {
    padding: 15px 25px; background: #f8f9fa; border-bottom: 1px solid #eee;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 1.2rem; color: var(--text-main); }
.close-btn { font-size: 1.5rem; color: #999; cursor: pointer; transition: 0.2s; line-height: 1; }
.close-btn:hover { color: var(--danger-color); }

/* Modal Body & Scroll */
#modal_body_content, .detail-body { overflow-y: auto; padding: 10px 0; }

/* Search in Modal */
.search-box-wrapper { padding: 15px 25px; border-bottom: 1px solid #eee; position: relative; }
.search-box-wrapper input { width: 100%; padding: 12px 15px 12px 45px; border: 1px solid #ddd; border-radius: 8px; outline: none; font-size: 1rem; }
.search-box-wrapper i { position: absolute; left: 40px; top: 50%; transform: translateY(-50%); color: #999; font-size: 1.1rem; }

/* List Items in Modal */
.component-list-modal { padding: 0; }
.component-list-modal li {
    padding: 15px 25px; border-bottom: 1px solid #f1f1f1; cursor: pointer;
    display: flex; align-items: center; transition: 0.1s;
}
.component-list-modal li:hover { background: #f8f9fa; }
.component-list-modal li.selected { background: var(--primary-light); border-left: 4px solid var(--primary-color); }
.component-list-modal li.incompatible { opacity: 0.6; background: #fff5f5; }

.comp-meta { font-size: 0.85rem; color: #777; margin-top: 4px; line-height: 1.4; }
.spec-highlight { font-weight: 700; color: #333; }
.warning-text { color: var(--danger-color); font-size: 0.8rem; font-weight: 600; margin-top: 5px; display: flex; align-items: center; gap: 5px; }

/* Detail Modal (PC Pro) */
.modal-detail-content { width: 750px; max-width: 95%; }
.d-row { display: flex; padding: 12px 25px; border-bottom: 1px dashed #eee; align-items: center; font-size: 0.95rem; }
.d-label { width: 140px; font-weight: 700; color: #666; }
.d-val { flex: 1; font-weight: 600; color: #333; }
.d-games { background: #f0f9ff; padding: 20px 25px; margin-top: 20px; border-top: 1px solid #cce5ff; }
.d-tag { display: inline-block; background: #fff; border: 1px solid #b3e0ff; color: #007bff; padding: 5px 12px; border-radius: 20px; font-size: 0.85rem; margin: 4px; font-weight: 600; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 768px) {
    .builder-layout { flex-direction: column; }
    .sidebar { position: static; }
    .config-grid { grid-template-columns: 1fr; }
    .header-pro h1 { font-size: 1.8rem; }
}
/* ... (Giữ nguyên các phần trên) ... */

/* ==========================================================================
   9. RESPONSIVE (MOBILE) - SỬA LỖI GIAO DIỆN ĐIỆN THOẠI
   ========================================================================== */
@media (max-width: 768px) {
    /* Layout chính dọc */
    .builder-layout { flex-direction: column; }
    .sidebar { width: 100%; position: static; }
    
    /* Grid cấu hình 1 cột */
    .config-grid { grid-template-columns: 1fr; }
    
    /* Header nhỏ lại */
    .header-pro h1 { font-size: 1.5rem; }
    
    /* MODAL POPUP: CHUYỂN TỪ 2 CỘT NGANG SANG DỌC */
    .full-list-container {
        flex-direction: column !important; /* Bắt buộc dọc */
        gap: 20px !important;
    }
    
    .full-list-col {
        width: 100% !important;
        border-bottom: 1px solid #eee; /* Thêm vạch ngăn cách */
        padding-bottom: 20px;
    }
    .full-list-col:last-child { border-bottom: none; }
    
    /* Modal full màn hình trên mobile để dễ nhìn */
    .modal-content {
        width: 95% !important;
        margin: 10% auto !important;
        max-height: 80vh !important;
    }
    
    /* Grid nhỏ trong modal */
    .full-list-items {
        grid-template-columns: 1fr !important; /* 1 dòng 1 item cho dễ đọc */
    }
}