/* =========================================================
   QLHV CTUT - SITE.CSS
   Chỉ chứa biến dùng chung và CSS cho nội dung/chức năng.
   Không chứa CSS layout sidebar/topbar.
   Không chứa CSS login.
   ========================================================= */

:root {
    --sidebar-width: 280px;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #172033;
    --muted: #6b7280;
    --primary: #0f4c81;
    --primary-dark: #08375f;
    --primary-soft: #e8f1fb;
    --accent: #f4b400;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --info: #0284c7;
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, .04);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: 'Open Sans', 'Roboto', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6,
.page-title,
.brand-name {
    font-family: 'Roboto', 'Open Sans', Arial, sans-serif;
}

a {
    color: var(--primary);
}

a:hover {
    color: var(--primary-dark);
}

img,
svg {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(15, 76, 129, .14);
}

.text-muted {
    color: var(--muted) !important;
}

/* Shared cards */
.content-card,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
}

.content-card {
    padding: 24px;
}

.content-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 18px;
}

.content-card-header h2 {
    font-size: 20px;
    font-weight: 800;
    margin: 0 0 4px;
}

.content-card-header p {
    margin: 0;
    color: var(--muted);
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 22px;
    flex: 0 0 auto;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    font-size: 28px;
    line-height: 1.1;
    font-weight: 800;
}

/* Checklist */
.checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.checklist-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    color: var(--text);
    background: #fafafa;
}

.checklist-item.done i {
    color: var(--success);
    margin-right: 8px;
}

/* Admin table */
.admin-table th {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .02em;
    background: #f8fafc;
}

.admin-table code,
.dynamic-form-preview code {
    color: #0f766e;
    background: #f0fdfa;
    border-radius: 6px;
    padding: 2px 6px;
}

/* Permissions */
.permission-panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: #fbfdff;
}

.permission-group {
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.permission-group:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.permission-group-title {
    font-weight: 800;
    margin-bottom: 10px;
}

.permission-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 12px;
    padding: 10px 12px;
    height: 100%;
    cursor: pointer;
}

.permission-item:hover {
    border-color: #bfdbfe;
    background: #f8fbff;
}

.permission-name {
    display: block;
    font-weight: 700;
    line-height: 1.25;
}

.permission-code {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

/* Select2 */
.select2-container--default .select2-selection--multiple {
    border-color: #dee2e6;
    min-height: 38px;
}

.select2-container--default .select2-selection--single {
    border-color: #dee2e6;
    min-height: 38px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

/* Field config */
.field-config-panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: #fbfdff;
    height: 100%;
}

.field-config-panel h6 {
    font-weight: 800;
    margin-bottom: 12px;
}

.field-config-panel .form-check {
    margin-bottom: 8px;
}

.dynamic-field-group {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    background: #fff;
    margin-bottom: 18px;
}

.dynamic-field-group-title {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 14px;
    color: var(--primary-dark);
}

/* Students */
.students-page .student-toolbar {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfdff;
    padding: 16px;
    margin-bottom: 16px;
}

.students-grid {
    width: 100%;
    height: calc(100vh - 310px);
    min-height: 520px;
    border-radius: 16px;
    overflow: hidden;
}

.column-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.column-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    background: #fff;
}

.column-check-item:hover {
    border-color: #bfdbfe;
    background: #f8fbff;
}

.column-check-item span {
    font-weight: 700;
}

.column-check-item code {
    margin-left: auto;
    color: #0f766e;
    background: #f0fdfa;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
}

.student-detail-section {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    background: #fff;
    margin-bottom: 18px;
}

.student-detail-section h5 {
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 14px;
}

.detail-field {
    height: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    background: #fbfdff;
}

.detail-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 3px;
}

.detail-value {
    font-weight: 700;
    min-height: 24px;
    word-break: break-word;
}

.detail-field code {
    display: inline-block;
    margin-top: 8px;
    color: #0f766e;
    background: #f0fdfa;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
}

.field-validation-error {
    display: block;
    margin-top: 4px;
}

/* Code/json */
.json-box {
    max-height: 520px;
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: .75rem;
    font-size: .82rem;
    line-height: 1.45;
}

/* Advanced filter */
.advanced-filter-summary .filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e3a8a;
    padding: 5px 10px;
    font-size: 13px;
}

.advanced-filter-summary .filter-chip-remove {
    border: 0;
    background: transparent;
    color: #1e40af;
    display: inline-grid;
    place-items: center;
    padding: 0;
    line-height: 1;
    font-size: 16px;
}

.advanced-filter-summary .filter-chip-remove:hover {
    color: #b91c1c;
}

.advanced-filter-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.advanced-filter-row {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fbfdff;
    padding: 12px;
}

.advanced-filter-row:hover {
    border-color: #bfdbfe;
    background: #f8fbff;
}

.advanced-filter-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.advanced-filter-check-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    transition: .15s ease;
}

.advanced-filter-check-item:hover {
    border-color: #bfdbfe;
    background: #f8fbff;
}

.advanced-filter-check-item.is-active {
    border-color: #93c5fd;
    background: #eff6ff;
}

.advanced-filter-check-head {
    margin-bottom: 10px;
}

.advanced-filter-check-head .form-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.advanced-filter-check-head .form-check-input {
    margin-top: 4px;
}

.advanced-filter-check-head .form-check-label {
    cursor: pointer;
    width: 100%;
}

.filter-field-name {
    display: block;
    font-weight: 800;
    line-height: 1.25;
}

.filter-field-meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
    word-break: break-word;
}

.advanced-filter-input-zone.is-disabled {
    opacity: .62;
}

/* Dashboard */
.dashboard-chart {
    width: 100%;
    height: 340px;
}

.dashboard-modern-page {
    --dashboard-bg: #f8fafc;
    --dashboard-border: #e2e8f0;
    --dashboard-muted: #64748b;
    --dashboard-dark: #0f172a;
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    border-radius: 24px;
    color: #fff;
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, .42), transparent 34%),
        linear-gradient(135deg, #0f172a 0%, #1d4ed8 56%, #0369a1 100%);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
}

.dashboard-hero h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 38px);
    font-weight: 900;
    letter-spacing: -.03em;
}

.dashboard-hero p {
    margin: 8px 0 0;
    max-width: 840px;
    color: rgba(255, 255, 255, .82);
}

.dashboard-eyebrow {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .16em;
    color: #bfdbfe;
    margin-bottom: 6px;
}

.dashboard-hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
}

.dashboard-filter-card {
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--dashboard-border);
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .08);
    backdrop-filter: blur(10px);
}

.dashboard-filter-card .form-label {
    font-size: 12px;
    font-weight: 800;
    color: #334155;
    margin-bottom: 5px;
}

.dashboard-active-filters {
    min-height: 24px;
}

.dashboard-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 6px 10px;
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
    font-size: 12px;
}

.dashboard-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    margin-bottom: 12px;
    color: #1e40af;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
}

.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.dashboard-kpi-card {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    min-height: 128px;
    padding: 18px;
    border: 1px solid var(--dashboard-border);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .07);
}

.dashboard-kpi-card::after {
    content: "";
    position: absolute;
    right: -32px;
    bottom: -40px;
    width: 96px;
    height: 96px;
    border-radius: 999px;
    background: #e0f2fe;
    opacity: .65;
}

.dashboard-kpi-card.kpi-primary {
    grid-column: span 2;
    color: #fff;
    background: linear-gradient(135deg, #0f172a, #2563eb);
    border-color: transparent;
}

.dashboard-kpi-card.kpi-primary::after {
    background: rgba(255, 255, 255, .22);
}

.dashboard-kpi-card.warning-soft::after {
    background: #fef3c7;
}

.dashboard-kpi-card.danger-soft::after {
    background: #fee2e2;
}

.dashboard-kpi-card.success-soft::after {
    background: #dcfce7;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 22px;
    position: relative;
    z-index: 1;
}

.kpi-primary .kpi-icon {
    color: #fff;
    background: rgba(255, 255, 255, .18);
}

.kpi-label,
.kpi-value,
.kpi-note {
    position: relative;
    z-index: 1;
}

.kpi-label {
    font-size: 12px;
    color: var(--dashboard-muted);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.kpi-primary .kpi-label,
.kpi-primary .kpi-note {
    color: rgba(255, 255, 255, .78);
}

.kpi-value {
    font-size: 30px;
    line-height: 1.1;
    margin-top: 8px;
    font-weight: 900;
    color: var(--dashboard-dark);
    letter-spacing: -.03em;
}

.kpi-primary .kpi-value {
    color: #fff;
}

.kpi-value.small-kpi {
    font-size: 24px;
}

.kpi-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--dashboard-muted);
}

.dashboard-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.dashboard-status-card {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid #dbeafe;
    background: linear-gradient(180deg, #fff, #f8fbff);
}

.status-name {
    color: #334155;
    font-weight: 800;
    min-height: 38px;
}

.status-value {
    margin-top: 8px;
    color: #0f172a;
    font-size: 26px;
    font-weight: 900;
}

.status-percent {
    margin-top: 3px;
    color: #2563eb;
    font-size: 12px;
    font-weight: 800;
}

.dashboard-chart-lg {
    height: 360px;
    width: 100%;
}

.dashboard-chart-md {
    height: 280px;
    width: 100%;
}

.dashboard-rank-table {
    margin-top: 6px;
    border-top: 1px dashed var(--dashboard-border);
    padding-top: 8px;
}

.dashboard-rank-table table {
    font-size: 13px;
}

.dashboard-rank-table thead th {
    color: #64748b;
    font-weight: 800;
    border-bottom-color: #e2e8f0;
}

/* Responsive content */
@media (max-width: 992px) {
    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-hero-actions {
        justify-content: flex-start;
    }

    .dashboard-kpi-card.kpi-primary {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .students-grid {
        height: calc(100vh - 420px);
        min-height: 460px;
    }

    .advanced-filter-row .text-end {
        text-align: left !important;
    }

    .advanced-filter-checklist {
        grid-template-columns: 1fr;
    }

    .content-card {
        padding: 18px;
    }

    .content-card-header {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 576px) {

    .dashboard-hero,
    .dashboard-filter-card,
    .dashboard-kpi-card {
        border-radius: 16px;
    }

    .dashboard-chart-lg {
        height: 320px;
    }
}