/* ============================================================
   UI Refresh Layer
   Bright, modern ERP/SIS surface overrides
   Keep this layer additive so legacy layout can remain intact.
   ============================================================ */

:root {
    --ui-primary: #2563eb;
    --ui-primary-strong: #1d4ed8;
    --ui-primary-soft: #eff6ff;
    --ui-secondary-soft: #f8fbff;
    --ui-accent: #f4c542;
    --ui-success: #16a34a;
    --ui-success-soft: #ecfdf5;
    --ui-warning: #d97706;
    --ui-warning-soft: #fff7ed;
    --ui-danger: #dc2626;
    --ui-danger-soft: #fef2f2;
    --ui-surface: #ffffff;
    --ui-surface-alt: #f8fbff;
    --ui-border: #dbe4f0;
    --ui-border-strong: #c6d3e2;
    --ui-text: #1f2937;
    --ui-text-muted: #64748b;
    --ui-shadow-sm: 0 2px 8px rgba(15, 23, 42, .05);
    --ui-shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
    --ui-shadow-lg: 0 18px 42px rgba(15, 23, 42, .10);
    --ui-radius-sm: 8px;
    --ui-radius-md: 12px;
    --ui-radius-lg: 16px;
}

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(180deg, #f8fbff 0%, #f5f8fc 100%);
    color: var(--ui-text);
    font-family: 'Noto Sans', 'Noto Sans Vietnamese', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}

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

a:hover {
    color: var(--ui-primary-strong);
    text-decoration: none;
}

.app-content {
    padding-top: 18px;
    padding-bottom: 28px;
}

.app-page-shell {
    width: 100%;
    margin: 0 auto;
}

.page-dashboard .app-content,
.page-grading .app-content,
.page-timetable .app-content,
.page-academic-planning .app-content {
    padding-top: 20px;
}

.app-content .row {
    margin-left: -15px;
    margin-right: -15px;
}

.page-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ui-text);
    margin: 0 0 1rem;
}

.card,
.panel {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
    overflow: hidden;
}

.card:hover,
.panel:hover {
    box-shadow: var(--ui-shadow-md);
}

.card-header,
.panel-heading {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-bottom: 1px solid var(--ui-border);
    color: var(--ui-text);
    padding: 1rem 1.1rem;
    font-weight: 700;
}

.card-body,
.panel-body {
    padding: 1rem 1.1rem;
    color: var(--ui-text);
}

.card-footer,
.modal-footer {
    background: #fbfdff;
    border-top: 1px solid var(--ui-border);
    padding: .9rem 1.1rem;
}

.table {
    margin-bottom: 0;
    color: var(--ui-text);
}

.table > thead > tr > th,
.table thead th {
    background: #f6f9fd;
    color: #334155;
    border-bottom: 1px solid var(--ui-border-strong);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: .9rem .8rem;
    vertical-align: middle;
}

.table > tbody > tr > td,
.table td {
    padding: .82rem .8rem;
    vertical-align: middle;
    border-top: 1px solid #edf2f7;
}

.table tbody tr {
    transition: background-color .15s ease, box-shadow .15s ease;
}

.table tbody tr:hover {
    background: #f8fbff;
}

.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(37, 99, 235, .018);
}

.table-responsive {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    overflow: hidden;
    background: var(--ui-surface);
}

.btn {
    border-radius: 10px;
    font-weight: 600;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
    box-shadow: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:focus,
.btn:active:focus,
.btn.active:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

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

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: var(--ui-primary-strong);
    border-color: var(--ui-primary-strong);
    color: #fff;
}

.btn-default,
.btn-secondary,
.btn-outline-secondary {
    background: #fff;
    border-color: var(--ui-border);
    color: var(--ui-text);
}

.btn-default:hover,
.btn-secondary:hover,
.btn-outline-secondary:hover {
    background: var(--ui-secondary-soft);
    border-color: #bfd1ea;
    color: var(--ui-primary);
}

.btn-success {
    background: var(--ui-success);
    border-color: var(--ui-success);
    color: #fff;
}

.btn-warning {
    background: var(--ui-accent);
    border-color: #e0b83c;
    color: #5b4600;
}

.btn-danger {
    background: var(--ui-danger);
    border-color: var(--ui-danger);
    color: #fff;
}

.btn-xs {
    padding: .25rem .5rem;
    font-size: .75rem;
    border-radius: 8px;
}

.form-control,
select.form-control,
textarea.form-control,
.input-group .form-control {
    background: #fff;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    color: var(--ui-text);
    min-height: 40px;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
    border-color: rgba(37, 99, 235, .45);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}

.form-group {
    margin-bottom: 1rem;
}

.alert {
    border-radius: 12px;
    border: 1px solid transparent;
    padding: .95rem 1rem;
    box-shadow: var(--ui-shadow-sm);
}

.alert-success {
    background: var(--ui-success-soft);
    border-color: #bbf7d0;
    color: #166534;
}

.alert-warning {
    background: var(--ui-warning-soft);
    border-color: #fed7aa;
    color: #92400e;
}

.alert-danger {
    background: var(--ui-danger-soft);
    border-color: #fecaca;
    color: #991b1b;
}

.alert-info,
.alert-primary {
    background: var(--ui-primary-soft);
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.badge {
    border-radius: 999px;
    padding: .35rem .7rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .01em;
}

.badge-primary {
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
}

.badge-success {
    background: var(--ui-success-soft);
    color: var(--ui-success);
}

.badge-warning {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

.badge-danger {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.dropdown-menu {
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    box-shadow: var(--ui-shadow-md);
    overflow: hidden;
    padding: .4rem 0;
}

.dropdown-item {
    padding: .55rem 1rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--ui-secondary-soft);
    color: var(--ui-primary);
}

.modal-content {
    border: 1px solid var(--ui-border);
    border-radius: 18px;
    box-shadow: var(--ui-shadow-lg);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border-bottom: 1px solid var(--ui-border);
    padding: 1rem 1.1rem;
}

.modal-title {
    color: var(--ui-text);
    font-weight: 700;
}

.modal-body {
    padding: 1rem 1.1rem;
    background: #fff;
}

.pagination {
    margin: 1rem 0 0;
}

.pagination > li > a,
.pagination > li > span {
    border: 1px solid var(--ui-border);
    color: var(--ui-text);
    border-radius: 10px !important;
    margin: 0 3px;
    min-width: 36px;
    text-align: center;
}

.pagination > li > a:hover,
.pagination > li > span:hover {
    background: var(--ui-primary-soft);
    border-color: #bfd1ea;
    color: var(--ui-primary);
}

.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover,
.pagination > .active > span:hover {
    background: var(--ui-primary);
    border-color: var(--ui-primary);
    color: #fff;
}

.table-tools-bar {
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    padding: .75rem .85rem;
    margin: 0 0 .9rem;
    background: var(--ui-surface);
}

.table-tools-search {
    min-width: 260px;
    background: #fff;
}

.table-tools-per-page {
    min-width: 120px;
}

.table-tools-meta {
    color: var(--ui-text-muted);
}

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

.panel {
    margin-bottom: 1rem;
}

.panel-heading {
    border-bottom: 1px solid var(--ui-border);
}

.panel-body {
    background: #fff;
}

.page-dashboard .page-container,
.page-grading .page-container,
.page-timetable .page-container,
.page-academic-planning .page-container {
    width: 100% !important;
}

/* Dashboard */
.page-dashboard .dashboard-modern-shell {
    display: grid;
    gap: 1rem;
}

.page-dashboard .dashboard-hero {
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    border: 1px solid var(--ui-border);
    border-radius: 18px;
    box-shadow: var(--ui-shadow-sm);
    padding: 1rem 1.1rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.page-dashboard .dashboard-hero h1 {
    margin: 0 0 .25rem;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--ui-text);
}

.page-dashboard .dashboard-hero p {
    margin: 0;
    color: var(--ui-text-muted);
}

.page-dashboard .dashboard-hero-cta {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.page-dashboard .dashboard-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .9rem;
}

.page-dashboard .dashboard-stat-card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    padding: 1rem 1.05rem;
    box-shadow: var(--ui-shadow-sm);
    min-height: 128px;
}

.page-dashboard .dashboard-stat-card .card-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .6rem;
}

.page-dashboard .dashboard-stat-card .card-title h3 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
    color: var(--ui-text-muted);
}

.page-dashboard .dashboard-stat-card .card-title .icon {
    font-size: 1.4rem;
    color: var(--ui-primary);
    opacity: 1;
}

.page-dashboard .dashboard-stat-card .card-body {
    padding: 0;
    font-size: 2rem;
    font-weight: 800;
    color: var(--ui-text);
}

.page-dashboard .dashboard-action-card,
.page-dashboard .dashboard-list-card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    box-shadow: var(--ui-shadow-sm);
    overflow: hidden;
}

.page-dashboard .dashboard-list-card .table thead th,
.page-dashboard .dashboard-list-card .table thead td,
.page-timetable .timetable-modern-shell .table thead th,
.page-timetable .timetable-modern-shell .table thead td {
    background: #f6f9fd;
    color: #334155;
    border-bottom: 1px solid var(--ui-border-strong);
}

.page-dashboard .dashboard-action-card .btn {
    min-height: 44px;
}

/* Grading */
.page-grading .grading-modern-shell {
    background: transparent;
}

.page-grading .grading-modern-shell .card {
    border-radius: 16px;
}

.page-grading .grading-modern-shell .nav-tabs {
    border-bottom: 1px solid var(--ui-border);
    gap: 6px;
    padding: .85rem .95rem 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.page-grading .grading-modern-shell .nav-tabs > li > a {
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--ui-text-muted);
    font-weight: 700;
    padding: .6rem .95rem;
}

.page-grading .grading-modern-shell .nav-tabs > li.active > a,
.page-grading .grading-modern-shell .nav-tabs > li.active > a:focus,
.page-grading .grading-modern-shell .nav-tabs > li.active > a:hover {
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    border-color: rgba(37, 99, 235, .12);
}

.page-grading .grading-modern-shell .table-responsive,
.page-grading .grading-modern-shell .card-body.table-responsive {
    border-radius: 14px;
}

.page-grading .grading-modern-shell .btn-group .btn {
    margin-right: 4px;
}

/* Timetable */
.page-timetable .timetable-modern-shell {
    display: grid;
    gap: 1rem;
}

.page-timetable .timetable-modern-shell .page-header,
.page-timetable .timetable-modern-shell .toolbar,
.page-timetable .timetable-modern-shell .card,
.page-timetable .timetable-modern-shell .timetable-card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 16px;
    box-shadow: var(--ui-shadow-sm);
}

.page-timetable .timetable-modern-shell h1,
.page-timetable .timetable-modern-shell h2,
.page-timetable .timetable-modern-shell h3 {
    color: var(--ui-text);
}

.page-timetable .timetable-modern-shell .badge-success {
    background: var(--ui-success-soft);
    color: var(--ui-success);
}

.page-timetable .timetable-modern-shell .badge-warning {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

/* Academic planning */
.page-academic-planning .card,
.page-academic-planning .panel {
    border-radius: 16px;
}

.page-academic-planning .card-header,
.page-academic-planning .panel-heading {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.page-academic-planning .table thead th {
    background: #f6f9fd;
    color: #334155;
}

.page-academic-planning .btn {
    box-shadow: none;
}

.page-academic-planning .alert {
    box-shadow: var(--ui-shadow-sm);
}

body.dark-mode .card,
body.dark-mode .panel,
body.dark-mode .table-responsive,
body.dark-mode .modal-content,
body.dark-mode .dropdown-menu {
    background: #111827;
    border-color: #334155;
}

body.dark-mode .card-header,
body.dark-mode .panel-heading,
body.dark-mode .modal-header,
body.dark-mode .card-footer,
body.dark-mode .modal-footer {
    background: #0f172a;
    border-color: #334155;
    color: #f8fafc;
}

body.dark-mode .table thead th {
    background: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}

body.dark-mode .table tbody tr:hover {
    background: #1e293b;
}

body.dark-mode .form-control,
body.dark-mode select.form-control,
body.dark-mode textarea.form-control {
    background: #0f172a;
    border-color: #334155;
    color: #e5e7eb;
}

body.dark-mode .form-control::placeholder {
    color: #94a3b8;
}

body.dark-mode .btn-default,
body.dark-mode .btn-secondary,
body.dark-mode .btn-outline-secondary,
body.dark-mode .dropdown-item {
    background: #111827;
    color: #e5e7eb;
    border-color: #334155;
}

body.dark-mode .btn-default:hover,
body.dark-mode .btn-secondary:hover,
body.dark-mode .btn-outline-secondary:hover,
body.dark-mode .dropdown-item:hover {
    background: #1e293b;
    color: #f8fafc;
}

body.dark-mode .alert-success {
    background: rgba(22, 163, 74, .12);
    border-color: rgba(22, 163, 74, .24);
    color: #86efac;
}

body.dark-mode .alert-warning {
    background: rgba(217, 119, 6, .14);
    border-color: rgba(217, 119, 6, .24);
    color: #fcd34d;
}

body.dark-mode .alert-danger {
    background: rgba(220, 38, 38, .14);
    border-color: rgba(220, 38, 38, .24);
    color: #fca5a5;
}

body.dark-mode .alert-info,
body.dark-mode .alert-primary {
    background: rgba(37, 99, 235, .12);
    border-color: rgba(37, 99, 235, .24);
    color: #93c5fd;
}

body.dark-mode .badge-primary {
    background: rgba(37, 99, 235, .18);
    color: #93c5fd;
}

body.dark-mode .badge-success {
    background: rgba(22, 163, 74, .16);
    color: #86efac;
}

body.dark-mode .badge-warning {
    background: rgba(217, 119, 6, .16);
    color: #fcd34d;
}

body.dark-mode .badge-danger {
    background: rgba(220, 38, 38, .16);
    color: #fca5a5;
}

body.dark-mode .pagination > li > a,
body.dark-mode .pagination > li > span {
    background: #111827;
    border-color: #334155;
    color: #cbd5e1;
}

body.dark-mode .pagination > li > a:hover,
body.dark-mode .pagination > li > span:hover,
body.dark-mode .pagination > .active > a,
body.dark-mode .pagination > .active > span,
body.dark-mode .pagination > .active > a:hover,
body.dark-mode .pagination > .active > span:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

@media (max-width: 768px) {
    .card-header,
    .panel-heading,
    .card-body,
    .panel-body,
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: .9rem;
        padding-right: .9rem;
    }

    .table-tools-bar {
        padding: .6rem .7rem;
    }

    .table-tools-search {
        min-width: 180px;
    }
}
