/* ==========================================================================
   BIẾN MÀU SẮC & FONT CHUNG
   ========================================================================== */
:root {
    --danger-color: #d63638;  /* Màu đỏ cho giá và nút xóa */
    --success-color: #2a8a2a; /* Màu xanh lá cho nút chọn trong modal */
    --light-gray: #f9f9f9;
    --border-color: #e0e0e0;
    --text-color: #333;
    --text-muted: #777;
}

/* ==========================================================================
   LAYOUT CHUNG CỦA BUILDER
   ========================================================================== */
.ct-pc-builder-app-container {
    font-family: var(--font-family);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--light-gray);
    color: var(--text-color);
}

/* ==========================================================================
   HEADER: TABS VÀ NÚT CHỨC NĂNG
   ========================================================================== */
.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Cho phép xuống dòng trên màn hình nhỏ */
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    gap: 10px;
}

.config-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.config-tabs button {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 700;
    transition: all 0.2s ease;
    font-size: 14px;
    text-transform: none;
    line-height: 1;
    margin-bottom: 0;
}

.config-tabs button.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.builder-actions {
    display: flex;
    gap: 10px;
}

.builder-actions .builder-action-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    text-transform: none;
    line-height: 1;
    margin-bottom: 0;
}
.builder-actions .builder-action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ==========================================================================
   MAIN: DANH SÁCH LINH KIỆN (SLOT)
   ========================================================================== */
.builder-main {
    padding: 20px;
}

/* --- Giao diện chung cho Component Slot --- */
.component-slot {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 15px;
}

.slot-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
    position: relative;
}

.slot-layout-left {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 60%;
}

.slot-icon {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    background: var(--light-gray);
}
.slot-icon i {
    font-size: 36px;
    color: #999;
}
.slot-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.slot-details {
    min-width: 0;
}
.slot-details .component-title {
    margin: 0 0 5px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-muted);
}
.slot-details .selected-product-name {
    font-size: 15px;
    margin: 0;
    line-height: 1.4;
}

.slot-layout-right {
    width: 40%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.actions-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: end;
}
.actions-filled {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: space-between;
}
.actions-filled button,
.actions-empty button{
    margin: 0 !important;
}
.selected-product-price {
    font-weight: bold;
    color: var(--danger-color);
    font-size: 16px;
}

/* Trong phần MAIN: DANH SÁCH LINH KIỆN (SLOT) */

/* Nút tăng giảm số lượng */
.quantity-control {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden; /* Đảm bảo các góc bo được áp dụng cho các nút con */
    height: 38px; /* Đặt chiều cao cố định */
}

.quantity-control .quantity-btn {
    background: var(--light-gray);
    border: none;
    width: 30px; /* Chiều rộng của nút */
    cursor: pointer;
    font-size: 12px; /* Kích thước icon */
    color: var(--text-muted);
    transition: background-color 0.2s ease;
    margin: 0 !important;
    /* Căn giữa icon bằng Flexbox */
    display: flex;
    justify-content: center;
    align-items: center;
}

.quantity-control .quantity-btn:hover {
    background: #e9e9e9;
    color: var(--text-color);
}

.quantity-control .product-quantity {
    width: 40px; /* Chiều rộng của ô nhập số */
    height: 100%; /* Lấp đầy chiều cao của container */
    text-align: center;
    font-weight: 500;
    border: none;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    color: var(--text-color);
    margin: 0 !important;
    /* Tắt mũi tên mặc định của trình duyệt */
    -moz-appearance: textfield;
}
.product-quantity::-webkit-inner-spin-button, 
.product-quantity::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}

.slot-layout-right .select-product-btn,
.slot-layout-right .edit-selection-btn {
    background-color: var(--primary-color) !important;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 4px !important;
    font-weight: 400;
    transition: all 0.2s ease;
    font-size: 14px;
    text-transform: none;
    line-height: 1;
    color: #fff;
}

.actions-filled .remove-item-btn {
    background: #f1f1f1 !important;
    border: 1px solid #ddd !important;
    color: var(--danger-color) !important;
    padding: 0 8px !important;
    min-width: auto !important;
    line-height: 1 !important;
    border-radius: 50% !important;
    position: absolute;
    left: -10px;
    top: -10px;
    margin: 0 !important;
    font-size: 13px;
}

.actions-filled .remove-item-btn > i {
    margin: 0 !important;}
.remove-item-btn i {
    font-size: 16px;
    vertical-align: middle;
}

.selected-product-right {
    display: flex;
    flex: 1;
    justify-content: flex-end;
    align-items: center;
    gap: 20px;
}

/* ==========================================================================
   FOOTER: TỔNG TIỀN VÀ NÚT THÊM VÀO GIỎ
   ========================================================================== */
.builder-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #fff;
    border-top: 1px solid var(--border-color);
}

.total-price-wrapper {
    font-size: 18px;
}
#total-price-display {
    color: var(--danger-color);
    font-weight: bold;
    margin-left: 10px;
}
#add-all-to-cart-btn {
    border-radius: 4px;
    font-size: 16px; 
    padding: 8px 24px;
    margin: 0;
}
#add-all-to-cart-btn[disabled] {
    background-color: #cccccc !important;
    border-color: #cccccc !important;
    cursor: not-allowed;

}

/* ==========================================================================
   MODAL POPUP
   ========================================================================== */
.ct-modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.ct-modal-content {
    background: #fff;
    width: 100%;
    max-width: 900px; /* Tăng chiều rộng modal */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.ct-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
}
.ct-modal-header h3 { margin: 0; font-size: 20px; }
.ct-modal-close-btn { background: none; border: none; font-size: 28px; cursor: pointer; line-height: 1; padding: 0;margin:0;}

.ct-modal-body {
    padding: 20px;
    overflow-y: auto;
    position: relative;
    min-height: 200px;
}

/* Loader */
.ct-modal-loader {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex; justify-content: center; align-items: center;
    z-index: 10;
}
.ct-spinner {
    border: 5px solid #f3f3f3; border-top: 5px solid var(--primary-color);
    border-radius: 50%; width: 50px; height: 50px;
    animation: spin 1s linear infinite;
}

/* Modal Filters */
#ct-modal-filters { padding: 0 0 20px 0; border-bottom: 1px solid #eee; margin-bottom: 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; margin-bottom: 20px; }
.filter-item select { width: 100%; border-radius: 4px; border: 1px solid #ddd; box-shadow:none;font-size: 14px; }
.filter-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.sort-options { display: flex; flex-wrap: wrap; gap: 8px; }
.sort-options button { background: #f0f0f1; border: 1px solid #dcdcde; padding: 4px 12px; cursor: pointer; border-radius: 4px;font-size: 14px;line-height: 1; }
.sort-options button.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
#ct-modal-filters .search-box input { padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; width: 250px; box-shadow: none; }

/* Product list inside modal */
.product-item { display: flex; align-items: center; padding: 10px; border-bottom: 1px solid #f0f0f0; gap: 15px; }
.product-item:last-child { border-bottom: none; }
.product-image img { width: 60px; height: 60px; object-fit: contain; border: 1px solid #eee; border-radius: 4px; }
.product-details { flex-grow: 1; }
.product-details .product-name { font-size: 15px; font-weight: 600; margin: 0 0 5px; }
.product-price { color: var(--danger-color); font-weight: bold; }
.product-actions .select-this-product-btn {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #fff !important;
    font-size: 13px !important;
    padding: 5px 15px !important;
    margin: 0;
    border-radius: 4px;
}

/* ==========================================================================
   CÁC THÀNH PHẦN KHÁC
   ========================================================================== */

/* Export Menu */
.export-wrapper { position: relative; display: inline-block; }
.export-menu {
    display: none; position: absolute; right: 0; top: 100%;
    background-color: #fff; min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 100; border-radius: 4px; padding: 5px 0; margin-top: 5px;
}
.export-menu a { color: black; padding: 8px 16px; text-decoration: none; display: block; font-size: 14px; }
.export-menu a:hover { background-color: #f1f1f1; }

/* Animation */
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; margin-right: 5px; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media screen and (max-width: 991px) {
    .slot-layout,
    .actions-filled {
        flex-direction: column;
        align-items: stretch;
    }
    .slot-layout-left, .slot-layout-right {
        width: 100%;
    }
    .actions-filled {
        align-items: center;
        flex-direction: row; /* Giữ các nút trên 1 hàng trên mobile */
        justify-content: space-between;
    }
}

@media screen and (max-width: 768px) {
    .builder-header, .builder-footer {
        flex-direction: column;
        align-items: flex-start;
    }
    .actions-filled {
        flex-direction: column; /* Xuống dòng trên màn hình rất nhỏ */
        align-items: stretch;
    }
    .search-box {
        width: 100%;
    }
    .search-box input {
        width: 100%;
    }
}


/* phân trang */
#ct-modal-pagination {
    margin-top: 25px; 
    margin-bottom: 15px;
    display: flex; 
    justify-content: center; 
    width: 100%;
}

#ct-modal-pagination .page-numbers {
    display: flex;
    align-items: center;
    list-style: none; 
    padding: 0;
    margin: 0;
	gap: 8px;
}

#ct-modal-pagination .page-numbers li {
    margin: 0;
}

#ct-modal-pagination .page-numbers a,
#ct-modal-pagination .page-numbers span {
    display: flex;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    color: #333; 
    background-color: #fff; 
    border: 1px solid #ddd; 
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
	border-radius: 100px;
	width: 28px;
	height: 28px;
	align-items: center;
	justify-content: center;
}

#ct-modal-pagination .page-numbers li:first-child a {
    border-left: none; 
}

/* Hiệu ứng khi di chuột vào nút */
#ct-modal-pagination .page-numbers a:hover {
    background-color: #f5f5f5; 
    color: #000;
}

/* Kiểu đặc biệt cho nút trang hiện tại (active) */
#ct-modal-pagination .page-numbers .current {
    background-color: var(--primary-color); 
    cursor: default; 
	color: #fff;
    border-color: var(--primary-color);
}
