/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #2c3e50;
}

.container {
    width: 90%;
    max-width: none;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.header-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
}

/* Cards */
.config-card {
    background: white;
    border-radius: 20px;
    padding: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    width: 280px;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.config-card .card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2c3e50;
}

.results-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: #2c3e50;
}

/* Sections */
.section {
    margin-bottom: 15px;
}

.section:has(.category-group) {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: center;
    overflow-x: auto;
}

.section-label {
    display: none;  /* Ẩn label "Chủ đề muốn lấy" */
}

/* Category Groups Container */
.section > .category-group:first-of-type,
.section > .category-group {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    margin-right: 15px;
    margin-bottom: 0;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    height: 70px;
    vertical-align: top;
}

/* Category Groups Wrapper */
.category-groups-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
    width: 100%;  /* Full width 280px */
}

/* Custom scrollbar */
.category-groups-container::-webkit-scrollbar {
    width: 6px;
}

.category-groups-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.category-groups-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.category-groups-container::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.category-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    height: auto;
    gap: 8px;
    flex-shrink: 0;
}

.group-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    padding: 0 0 6px 0;
    border-right: none;
    border-bottom: 2px solid #3498db;
    white-space: nowrap;
    cursor: pointer;
}

.group-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Categories Grid */
.categories-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 5px;
    align-items: stretch;
    overflow-x: visible;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 8px;
    background: #ffffff;
    border-radius: 5px;
    flex-shrink: 0;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
    font-size: 0.7rem;
    white-space: nowrap;
    height: fit-content;
    width: 100%;
}

.checkbox-label:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 14px;
    height: 14px;
    border: 2px solid #667eea;
    border-radius: 4px;
    margin-right: 6px;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: #667eea;
    border-color: #667eea;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: bold;
}

.checkbox-text {
    font-size: 0.7rem;
    font-weight: 500;
    color: #2c3e50;
}

/* Date Range and Action Row */
.date-action-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.date-range-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.date-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: #34495e;
    white-space: nowrap;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 5px;
}

.date-input {
    width: 100%;
    padding: 7px 8px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
}

.date-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.date-separator {
    color: #7f8c8d;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.btn-icon {
    font-size: 0.85rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #229954;
    transform: translateY(-2px);
}

/* Status Section */
.status-section {
    margin-top: 25px;
}

.status-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.status-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    border-radius: 10px;
}

.status-text {
    font-size: 0.95rem;
    color: #7f8c8d;
    text-align: center;
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.results-count {
    font-size: 1rem;
    color: #7f8c8d;
    font-weight: 500;
}

.results-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.results-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.results-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.results-table tbody tr {
    border-bottom: 1px solid #e9ecef;
    transition: background 0.2s ease;
}

.results-table tbody tr:hover {
    background: #f8f9fa;
}

.results-table td {
    padding: 15px;
    font-size: 0.9rem;
}

.empty-row .empty-message {
    text-align: center;
    padding: 40px;
    color: #95a5a6;
    font-style: italic;
}

.action-cell {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn-preview {
    background: #3498db;
    color: white;
}

.action-btn-preview:hover {
    background: #2980b9;
}

.action-btn-open {
    background: #27ae60;
    color: white;
}

.action-btn-open:hover {
    background: #229954;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-large {
    width: 90vw;
    height: 90vh;
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 5px 10px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-height: 40px;
}

.modal-header h3 {
    display: none; /* Ẩn tiêu đề, chỉ hiển thị nút X */
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8f9fa;
}

/* Date Picker Inputs */
.date-input-group {
    margin-bottom: 20px;
}

.date-input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #34495e;
}

.date-picker-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.date-picker-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.date-hint {
    margin-top: 10px;
    color: #95a5a6;
    font-size: 0.9rem;
}

/* Article Preview */
.preview-content {
    line-height: 1.8;
}

.preview-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #2c3e50;
}

.preview-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
    color: #7f8c8d;
    font-size: 0.95rem;
}

.preview-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-body {
    font-size: 1.05rem;
    color: #34495e;
}

.preview-body p {
    margin-bottom: 15px;
}

.preview-body img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 20px 0;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .config-card {
        width: 100%;
    }

    .results-card {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .header-title {
        font-size: 2rem;
    }

    .config-card,
    .results-card {
        padding: 20px;
    }

    .categories-grid {
        grid-template-columns: 1fr;
    }

    .date-action-row {
        flex-direction: column;
        gap: 15px;
    }

    .date-range-container {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        min-width: auto;
    }

    .date-inputs {
        width: 100%;
    }

    .date-input {
        min-width: auto;
    }

    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .results-table {
        font-size: 0.85rem;
    }
    
    .results-table th,
    .results-table td {
        padding: 10px;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* Loading Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

/* Tabs Styles */
.tabs-container {
    margin-bottom: 20px;
}

.tabs-header {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 20px;
}

.tab-button {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: #7f8c8d;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    bottom: -2px;
}

.tab-button:hover {
    color: #667eea;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* SAPO Content */
.sapo-container {
    padding: 20px 0;
}

.sapo-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
}

.sapo-content {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    min-height: 400px;
}

.sapo-empty {
    text-align: center;
    color: #95a5a6;
    padding: 60px 20px;
    font-size: 1.1rem;
}

.sapo-article {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.sapo-article h3 {
    color: #2c3e50;
    font-size: 1.4rem;
    margin-bottom: 15px;
    line-height: 1.4;
}

.sapo-article p {
    color: #34495e;
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 12px;
}

/* New SAPO item styling */
.sapo-article-item {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.sapo-title {
    color: #2c3e50;
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.sapo-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    font-style: italic;
    color: #7f8c8d;
}

.sapo-date {
    color: #7f8c8d;
}

.sapo-separator {
    color: #bdc3c7;
}

.sapo-link {
    color: #3498db;
    text-decoration: none;
    transition: color 0.2s ease;
}

.sapo-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

.sapo-divider {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 15px 0;
}

.sapo-content-text {
    color: #34495e;
    font-size: 1rem;
    line-height: 1.8;
}

.sapo-content-text p {
    margin-bottom: 12px;
}

.sapo-loading {
    text-align: center;
    padding: 40px;
}

.sapo-loading .loading {
    width: 40px;
    height: 40px;
    border-width: 4px;
    border-color: rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    margin: 0 auto 20px;
}

.sapo-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    padding: 20px;
    color: #c53030;
    text-align: center;
}

/* Checkbox in table */
.results-table th input[type="checkbox"],
.results-table td input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Results header with button */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 15px;
}
