:root {
    --primary-color: #0056b3;
    /* DUE Blue approx */
    --primary-light: #e6f0fa;
    --secondary-color: #64748b;
    --accent-color: #0ea5e9;
    --background-bg: #f8fafc;
    --surface-bg: #ffffff;
    --text-main: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Sidebar specific */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--background-bg);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.workspace-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .brand-subtext,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-group-header span,
.sidebar.collapsed .nav-group-header .group-toggle,
.sidebar.collapsed .nav-group-content,
.sidebar.collapsed .btn-logout span {
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    padding: 24px 15px;
    text-align: center;
}

.sidebar.collapsed .brand-name {
    font-size: 0.9rem;
}

.sidebar.collapsed .nav-icon,
.sidebar.collapsed .nav-dot {
    margin-right: 0;
    font-size: 1.1rem;
}

.sidebar.collapsed .nav-link,
.sidebar.collapsed .nav-group-header {
    justify-content: center;
    padding: 10px 0;
}

.sidebar-brand {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.brand-subtext {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 4px;
}

.sidebar-nav {
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item,
.nav-group {
    padding: 4px 12px;
}

.nav-link,
.nav-group-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9375rem;
}

.nav-link:hover,
.nav-group-header:hover {
    background-color: #f1f5f9;
}

.nav-item.active .nav-link,
.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.nav-icon {
    width: 20px;
    margin-right: 12px;
    color: var(--secondary-color);
}

.nav-dot {
    font-size: 10px;
    margin-right: 12px;
}

.color-blue {
    color: #3b82f6;
}

.color-green {
    color: #10b981;
}

.color-purple {
    color: #8b5cf6;
}

.color-orange {
    color: #f59e0b;
}

.group-toggle {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.3s;
}

.nav-group.active .group-toggle {
    transform: rotate(180deg);
}

.nav-group-content {
    display: none;
    padding-left: 32px;
    margin-top: 4px;
}

.nav-group-content.show {
    display: block;
}

.nav-sub-link {
    display: block;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-light);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-sub-link:hover {
    color: var(--primary-color);
    background-color: #f8fafc;
}

.nav-sub-link.active {
    background-color: #f1f7fe;
    color: var(--primary-color);
    font-weight: 500;
}

/* Main Workspace Content Area */
.main-workspace {
    flex: 1;
    background-color: var(--background-bg);
    overflow-x: hidden;
}

.app-container {
    max-width: 100%;
    margin: 0;
    padding: 24px 32px;
}

/* Header */
/* Breadcrumbs */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.8125rem;
    color: var(--text-light);
    padding-top: 4px;
}

.breadcrumb-item.active {
    color: var(--primary-color);
    font-weight: 500;
}

.breadcrumb-separator {
    font-size: 8px;
    opacity: 0.5;
}

/* Main Header Redesign */
.main-header {
    background: var(--surface-bg);
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    border-left: 5px solid var(--primary-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.header-main-info {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.header-large-icon {
    width: 48px;
    height: 48px;
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

/* Color-coded Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-blue {
    background-color: #eff6ff;
    color: #1d4ed8;
}

.badge-orange {
    background-color: #fffaf0;
    color: #d97706;
}

.badge-green {
    background-color: #f0fdf4;
    color: #166534;
}

.badge-purple {
    background-color: #faf5ff;
    color: #7e22ce;
}

.badge-gray {
    background-color: #f8fafc;
    color: #475569;
}

.badge-green {
    background-color: #f0fdf4;
    color: #15803d;
}

.badge-yellow {
    background-color: #fefce8;
    color: #a16207;
}

.badge-teal {
    background-color: #f0fdfa;
    color: #0f766e;
}

.badge-indigo {
    background-color: #eef2ff;
    color: #4338ca;
}

.badge-dark-red {
    background-color: #fef2f2;
    color: #7f1d1d;
    font-weight: 600;
}


.badge-cyan {
    background-color: #ecfeff;
    color: #0891b2;
}

.badge-red {
    background-color: #fff1f2;
    color: #be123c;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.8125rem;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}


.header-titles h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0px;
}

.header-description {
    color: var(--text-light);
    font-size: 0.75rem;
    max-width: none;
    line-height: 1.2;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-update-data {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.btn-update-data:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-add-doc {
    background-color: #ecfdf5;
    color: #059669;
}

.btn-add-doc:hover {
    background-color: #059669;
    color: white;
}

.data-status-header {
    font-size: 0.75rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Top Actions */
.top-actions {
    margin-bottom: 12px;
}

/* Filters */
.filter-section {
    background: var(--surface-bg);
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-box {
    flex: 3;
    /* Allocate more space to search */
    min-width: 250px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    padding: 10px 10px 10px 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Filter Group (Selects + Reset) */
.filter-group {
    flex: 4;
    display: flex;
    gap: 10px;
    align-items: center;
}

.select-wrapper {
    flex: 1;
    min-width: 120px;
}

select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: white;
    font-size: 0.8125rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn-reset,
.btn-update {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 0.85rem;
}

.btn-reset {
    background-color: var(--background-bg);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    width: 32px;
    /* Square-ish for icon only */
    padding: 6px;
}

.btn-reset:hover {
    background-color: #e2e8f0;
    color: var(--danger-color);
    border-color: #cbd5e1;
}

.btn-update {
    background-color: #ecfdf5;
    border: 1px solid #10b981;
    color: #059669;
    align-self: flex-start;
    /* For top-actions alignment */
}

.btn-update:hover {
    background-color: #10b981;
    color: white;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.data-status {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    font-style: italic;
}

/* Stats */
.results-info {
    margin-bottom: 8px;
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 500;
    padding-left: 4px;
}

/* Table */
.data-container {
    background: var(--surface-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* Enforce fixed widths */
}

thead th {
    background-color: #f8fafc;
    color: var(--text-main);
    font-weight: 600;
    padding: 12px 8px;
    text-align: left;
    vertical-align: top;
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0.02em;
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: normal;
    position: relative;
}

thead th .th-sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    font-style: italic;
    color: #64748b;
    margin-top: 2px;
}

/* Resizer handle */
.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    /* Slightly wider for easier grap */
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 10;
}

.resizer:hover,
.resizing {
    background-color: var(--primary-color);
    opacity: 0.5;
}

thead th.sortable:hover {
    background-color: #e2e8f0;
    color: var(--primary-color);
}

thead th i {
    margin-left: 4px;
    font-size: 0.8em;
    color: #94a3b8;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f1f5f9;
}

tbody td {
    padding: 10px 8px;
    /* Compact padding */
    vertical-align: top;
    font-size: 13px;
    /* Compact font */
    color: var(--text-main);
}

/* Column Specifics */
td:first-child {
    text-align: left !important;
}

.sub-text-date {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-style: italic;
    color: #64748b;
    font-weight: 400;
}

td.col-sohieu {
    color: var(--text-dark);
    font-weight: normal;
    white-space: normal;
    word-break: break-word;
}

td.col-ngay {
    display: block;
    margin-top: 2px;
}

td.col-trichyeu {
    white-space: normal;
    line-height: 1.5;
    text-align: justify;
}

.sub-text-nguoiky {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    font-style: italic;
    color: #64748b;
    font-weight: 400;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 0;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-type {
    background-color: #e0f2fe;
    color: #0369a1;
}

.badge-field {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    margin-top: 2px;
    display: inline-block;
    white-space: normal;
    word-break: break-word;
    text-align: left;
}

/* File Action */
.btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-view:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-view.disabled {
    opacity: 0.3;
    pointer-events: none;
    background-color: #eee;
    color: #999;
}

/* Loading & Empty States */
.state-message {
    padding: 40px;
    text-align: center;
    color: var(--text-light);
}

.hidden {
    display: none;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Pagination Wrapper */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    gap: 20px;
    border-top: 1px solid var(--border-color);
}

/* Pagination Controls */
.pagination-wrapper .pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Items Per Page Selector */
.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
}

.items-per-page label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
    white-space: nowrap;
}

.items-per-page select {
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 0.85rem;
    cursor: pointer;
}

.page-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-numbers,
#paginationNumbers {
    display: flex;
    gap: 4px;
}

.page-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
}

/* Custom Multi-Select Dropdown */
.custom-dropdown {
    position: relative;
    width: 100%;
    min-width: 140px;
}

.dropdown-header {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: white;
    font-size: 0.8125rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    height: 34px;
    /* Force height match */
}

.dropdown-header.active {
    background-color: #ecfdf5;
    border-color: #10b981;
    color: #059669;
    font-weight: 500;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 50;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}

.custom-dropdown.open .dropdown-content {
    display: block;
}

.custom-dropdown.open .dropdown-header i {
    transform: rotate(180deg);
}

.custom-dropdown.open .dropdown-header {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}



.dropdown-content.show {
    display: block;
}

.checkbox-item {
    padding: 8px 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 0.8125rem;
    color: var(--text-main);
    line-height: 1.4;
}

.checkbox-item:hover {
    background-color: #f1f5f9;
}

.checkbox-item input[type="checkbox"] {
    margin-top: 3px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-item span {
    flex: 1;
}

.page-number:hover {
    background-color: #f1f5f9;
}

.page-number.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

/* Animations */
@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: #fef2f2;
    color: #ef4444;
}

.btn-logout i {
    font-size: 1.1rem;
}

/* Mobile Controls & Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 8px;
    margin-right: 12px;
}

/* Sidebar Toggle for Desktop */
.desktop-toggle-container {
    padding: 0 16px 12px;
    display: flex;
    justify-content: flex-end;
}

.btn-sidebar-toggle {
    background: var(--primary-light);
    color: var(--primary-color);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-sidebar-toggle:hover {
    background: var(--primary-color);
    color: white;
}

.sidebar.collapsed .btn-sidebar-toggle i {
    transform: rotate(180deg);
}

/* Responsive */
@media (max-width: 1024px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .header-actions {
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    body.no-scroll {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.mobile-show {
        left: 0;
    }

    .mobile-nav-toggle {
        display: block;
    }

    .app-container {
        padding: 16px;
    }

    .header-main-info {
        gap: 12px;
    }

    .header-large-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .header-titles h1 {
        font-size: 1rem;
    }

    .header-description {
        white-space: normal;
        overflow: visible;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-clamp: 2;
    }

    .filter-section {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .filter-group {
        flex-direction: column;
        width: 100%;
    }

    .custom-dropdown {
        width: 100%;
    }

    .btn-reset {
        width: 100%;
        height: 34px;
    }

    .table-responsive {
        border-radius: 0;
    }

    thead th {
        font-size: 11px;
        padding: 8px 4px;
    }

    tbody td {
        font-size: 12px;
        padding: 8px 4px;
    }

    .pagination-wrapper {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .header-actions {
        width: 100%;
    }

    .action-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .btn-action {
        justify-content: center;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .filter-section {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .filter-controls {
        flex-direction: column;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .logo-area {
        flex-direction: column;
    }
}