/* Style cho chính Elementor widget container */
:root select, button {
    border-radius:5px!important;
}
.ai-affiliate-widget-container {
    font-family: Inter, sans-serif;
    margin: 0 auto 30px auto;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
    max-width: 1400px;
    color: #333;
}

/* Style cho phần bộ lọc */
.filter-section {
    margin-bottom: 25px;
    padding: 20px;
    background-color: #fcfcfc;
    border-radius: 10px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e0e0e0;
}

/* CẬP NHẬT: Gộp bộ lọc và nút hành động thành 1 dòng trên PC */
@media (min-width: 992px) {
    .filter-section {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 20px;
    }
    .filters {
        margin-bottom: 0; /* Bỏ khoảng cách dưới khi nằm trên 1 hàng */
    }
    .filter-actions {
        margin-top: 0; /* Bỏ khoảng cách trên khi nằm trên 1 hàng */
    }
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 5px;
    justify-content: flex-start;
    transition: all 0.3s ease-in-out;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.95em;
}

.filter-group select {
    padding: 10px 12px;
    border: 1px solid #dcdcdc;
    border-radius: 6px; /* Bo góc */
    background-color: #fff;
    font-size: 1em;
    color: #444;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666%22%20d%3D%22M287%2C114.7L154.5%2C247.2c-2.4%2C2.4-5.5%2C3.6-8.7%2C3.6s-6.3-1.2-8.7-3.6L5.3%2C114.7c-4.8-4.8-4.8-12.5%2C0-17.3c4.8-4.8%2C12.5-4.8%2C17.3%2C0l131.7%2C131.7l131.7-131.7c4.8-4.8%2C12.5-4.8%2C17.3%2C0C291.8%2C102.2%2C291.8%2C109.9%2C287%2C114.7z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    cursor: pointer;
}

.filter-group select:focus {
    border-color: #037AFC;
    box-shadow: 0 0 0 3px rgba(3, 122, 252, 0.25);
    outline: none;
}

.filter-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 20px;
    flex-shrink: 0; /* Ngăn các nút bị co lại khi không đủ chỗ */
}

.filter-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px; /* CẬP NHẬT: Bo góc đồng bộ */
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
}

.apply-btn {
    background-color: #037AFC;
    color: white;
}

.apply-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.clear-btn {
    background-color: #6c757d;
    color: white;
}

.clear-btn:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

/* Controls: Tabs & Customize */
.controls-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 15px;
}

.tabs {
    display: flex;
    gap: 10px;
}

.tab-btn {
    padding: 10px 20px;
    border: 1px solid #dcdcdc;
    border-radius: 20px;
    background-color: #f9f9f9;
    color: #555;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.tab-btn.active {
    background-color: #037AFC;
    color: white;
    border-color: #037AFC;
}

.tab-btn:hover:not(.active) {
    background-color: #e9ecef;
    border-color: #c5c9cc;
}

.customize-btn {
    padding: 10px 20px;
    border: 1px solid #dcdcdc;
    border-radius: 20px; /* CẬP NHẬT: Bo góc dạng viên thuốc */
    background-color: #f9f9f9;
    color: #555;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease-in-out;
}

.customize-btn:hover {
    background-color: #e9ecef;
}

/* Category List */
.category-scroll {
    margin-bottom: 25px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.category-list {
    display: inline-flex;
    gap: 10px;
}

.category-btn {
    flex-shrink: 0;
    padding: 8px 18px;
    border: 1px solid #dcdcdc;
    border-radius: 20px;
    background-color: #f9f9f9;
    color: #555;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.category-btn.active {
    background-color: #037AFC;
    color: white;
    border-color: #037AFC;
}

.category-btn:hover:not(.active) {
    background-color: #e6f2ff;
    border-color: #037AFC;
}

/* Table */
.table-container {
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

thead {
    background-color: #eef2f5;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

th {
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    font-size: 0.85em;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f7f9fc;
}

.program-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: contain;
    border: 1px solid #eee;
    padding: 2px;
    background-color: #fff;
}

.program-name {
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.visit-btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: #037AFC;
    color: white;
    text-decoration: none;
    border-radius: 6px; /* CẬP NHẬT: Bo góc đồng bộ */
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    border: none;
}

.visit-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 25px;
    padding: 10px;
    border-top: 1px solid #eee;
}

.pagination-controls .pagination-btn {
    padding: 8px 15px;
    border: 1px solid #dcdcdc;
    border-radius: 6px; /* CẬP NHẬT: Bo góc đồng bộ */
    background-color: #f9f9f9;
    color: #555;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.pagination-controls .pagination-btn:hover:not(.active):not(:disabled) {
    background-color: #e9ecef;
    border-color: #c5c9cc;
}

.pagination-controls .pagination-btn.active {
    background-color: #037AFC;
    color: white;
    border-color: #037AFC;
}

/* Modal Tùy chỉnh cột */
.ai-affiliate-custom-columns-modal-overlay {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999; 
}

.ai-affiliate-custom-columns-modal {
    background-color: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    animation: fadeIn 0.3s ease-out;
    position: relative;
}

.ai-affiliate-custom-columns-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.ai-affiliate-custom-columns-modal .modal-header h3 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
}

.ai-affiliate-custom-columns-modal .close-button {
    background: none;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    color: #888;
    transition: color 0.2s;
}

.ai-affiliate-custom-columns-modal .close-button:hover {
    color: #333;
}

.ai-affiliate-custom-columns-modal .modal-body {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.ai-affiliate-custom-columns-modal .custom-column-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1em;
    color: #555;
    cursor: pointer;
    width: calc(50% - 10px);
}

.ai-affiliate-custom-columns-modal .custom-column-checkbox input[type="checkbox"] {
    transform: scale(1.2);
    accent-color: #037AFC;
}

.ai-affiliate-custom-columns-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.ai-affiliate-custom-columns-modal .modal-footer button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s, transform 0.1s;
}

.ai-affiliate-custom-columns-modal .modal-footer .save-button {
    background-color: #037AFC;
    color: white;
}

.ai-affiliate-custom-columns-modal .modal-footer .save-button:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.ai-affiliate-custom-columns-modal .modal-footer .cancel-button {
    background-color: #e2e6ea;
    color: #333;
}

.ai-affiliate-custom-columns-modal .modal-footer .cancel-button:hover {
    background-color: #d1d5db;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}


/* Responsive adjustments */
@media (max-width: 991px) { /* CẬP NHẬT: Thay đổi điểm breakpoint */
    .ai-affiliate-widget-container {
        padding: 15px;
    }

    .filters {
        flex-direction: column;
        gap: 15px;
    }

    .filter-actions {
        flex-direction: column;
        gap: 10px;
    }

    .filter-actions button {
        width: 100%;
        padding: 12px;
        font-size: 1em;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .tabs {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    
    .tab-btn, .customize-btn {
        width: 100%;
        text-align: center;
    }

    .table-container th,
    .table-container td {
        padding: 10px;
        font-size: 0.85em;
    }
    
    .program-name {
        font-size: 1em;
    }

    .pagination-controls {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .ai-affiliate-custom-columns-modal .custom-column-checkbox {
        width: 100%;
    }
}
