/* CSS dùng chung: biến màu, thanh điều hướng, bảng điểm, hộp thoại và bố cục theo màn hình; không chứa quy tắc tính CPA. */

:root {
    --app-background: #f4f7fb;
    --app-primary: #005baa;
    --app-primary-dark: #003f7d;
    --app-border: #e2e8f0;
    --app-navbar-width: 15rem;
}

body {
    min-height: 100vh;
    background: var(--app-background);
    color: #1e293b;
}

/* Thanh điều hướng cố định bên trái ở màn hình lớn; media query bên dưới đổi sang bố cục trên cùng khi màn hình nhỏ. */
.app-navbar {
    position: fixed;
    z-index: 1040;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--app-navbar-width);
    background: var(--app-primary-dark);
    color: #fff;
    box-shadow: 0 0.2rem 0.75rem rgb(15 23 42 / 14%);
}

.has-app-navbar {
    padding-left: var(--app-navbar-width);
}

.app-navbar-content {
    display: flex;
    height: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 1.5rem 1rem;
}

.app-navbar-brand {
    padding: 0.5rem 0.75rem 1.5rem;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

.app-navbar-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-navbar-link {
    display: flex;
    align-items: center;
    min-height: 3rem;
    padding: 0.65rem 0.75rem;
    border-left: 0.2rem solid transparent;
    border-radius: 0.5rem;
    color: rgb(255 255 255 / 72%);
    font-weight: 600;
    text-decoration: none;
}

.app-navbar-link:hover,
.app-navbar-link:focus-visible {
    color: #fff;
    background: rgb(255 255 255 / 8%);
}

/* Đánh dấu trang hiện tại; đây là trạng thái trình bày, không phải quyền truy cập. */
.app-navbar-link.active {
    border-left-color: #fff;
    color: #fff;
    background: rgb(255 255 255 / 12%);
}

/* Nhóm danh tính và nút đăng xuất, tách khỏi các liên kết chức năng. */
.app-navbar-account {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-top: auto;
    padding: 1rem 0.75rem 0;
    border-top: 1px solid rgb(255 255 255 / 18%);
}

.app-header {
    background: linear-gradient(135deg, var(--app-primary), var(--app-primary-dark));
    color: #fff;
}

/* Các kiểu thẻ dùng chung cho số liệu, form và nội dung để tránh lặp quy tắc giữa các trang. */
.summary-card,
.form-card,
.content-card {
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 0.35rem 1rem rgb(15 23 42 / 6%);
}

.summary-value {
    color: var(--app-primary);
    font-size: 2rem;
    font-weight: 700;
}

.edit-summary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1.15rem;
    line-height: 1;
}

/* Tiêu đề nhóm học kỳ giúp đọc lịch sử các lần học theo thứ tự. */
.semester-row th {
    background: #eaf4ff;
    color: var(--app-primary-dark);
    font-size: 0.9rem;
}

.course-name {
    min-width: 14rem;
}

.recommendation-table {
    min-width: 28rem;
}

.recommendation-course-name {
    min-width: 11rem;
}

.recommendation-course-code {
    color: var(--app-primary-dark);
    font-weight: 700;
}

/* Vùng chọn cách nhập điểm; selector :has phía dưới chỉ đổi giao diện khi radio được chọn. */
.grade-input-option {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.9rem;
    border: 1px solid var(--app-border);
    border-radius: 0.75rem;
    cursor: pointer;
}

.grade-input-option:has(input:checked) {
    border-color: var(--app-primary);
    background: #f0f7ff;
}

.grade-guide {
    border-left: 0.25rem solid var(--app-primary);
    border-radius: 0.5rem;
    background: #f8fbff;
}

/* Cụm nút mở hướng dẫn được đặt cố định để luôn truy cập được khi cuộn bảng điểm. */
.guide-trigger-stack {
    position: fixed;
    z-index: 1030;
    top: 50%;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transform: translateY(-50%);
}

.grade-guide-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5.5rem;
    height: 5.5rem;
    padding: 0.75rem;
    border-radius: 50%;
    box-shadow: 0 0.35rem 1rem rgb(15 23 42 / 18%);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
}

/* Giới hạn kích thước và chiều cao hộp thoại để nội dung dài vẫn cuộn được. */
.grade-guide-dialog {
    width: min(52rem, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 1rem 3rem rgb(15 23 42 / 24%);
}

.grade-guide-dialog::backdrop {
    background: rgb(15 23 42 / 52%);
}

.grade-guide-dialog-content {
    background: #fff;
}

.delete-course-dialog {
    width: min(32rem, calc(100% - 2rem));
}

.import-grade-dialog {
    width: min(70rem, calc(100% - 2rem));
}

#initial-grade-import-section .grade-import-content {
    border: 1px solid var(--app-border);
    border-radius: 1rem;
    box-shadow: 0 0.35rem 1rem rgb(15 23 42 / 6%);
}

/* Bảng preview nhiều cột giữ độ rộng tối thiểu, vùng bọc cho phép cuộn ngang. */
.import-preview-table {
    min-width: 58rem;
}

.import-preview-table th,
.import-preview-table td {
    white-space: nowrap;
}

.import-preview-table .import-course-name {
    min-width: 14rem;
    white-space: normal;
}

.grade-conversion-table th,
.grade-conversion-table td {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

/* Ghi đè biến Bootstrap cho nút chính, giữ các trạng thái hover/border nhất quán. */
.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark);
    --bs-btn-hover-border-color: var(--app-primary-dark);
}

/* Điều chỉnh bố cục theo độ rộng màn hình; chỉ đổi trình bày, giữ nguyên dữ liệu và thao tác nghiệp vụ. */
@media (max-width: 767.98px) {
    .has-app-navbar {
        padding-left: 0;
    }

    .app-navbar {
        position: static;
        width: auto;
    }

    .app-navbar-content {
        height: auto;
        padding: 0.75rem 1rem;
    }

    .app-navbar-brand {
        padding: 0.5rem 0.75rem 0.75rem;
    }

    .app-navbar-account {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }

    .app-navbar-links {
        flex-direction: row;
    }

    .app-navbar-link {
        flex: 1;
        justify-content: center;
        min-height: 2.75rem;
        border: 0;
    }

    .summary-value {
        font-size: 1.65rem;
    }
}

/* Cho nhãn trạng thái CPA xuống dòng để không kéo giãn bảng trên màn hình nhỏ. */
.cpa-status-badge {
    line-height: 1.25;
    text-align: left;
    white-space: normal;
}

/* Điều chỉnh bố cục theo độ rộng màn hình; chỉ đổi trình bày, giữ nguyên dữ liệu và thao tác nghiệp vụ. */
@media (max-width: 991.98px) {
    .guide-trigger-stack {
        top: auto;
        right: 0.75rem;
        bottom: 0.75rem;
        gap: 0.75rem;
        transform: none;
    }

    .grade-guide-trigger {
        width: 4.5rem;
        height: 4.5rem;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}

/* Điều chỉnh bố cục theo độ rộng màn hình; chỉ đổi trình bày, giữ nguyên dữ liệu và thao tác nghiệp vụ. */
@media (min-width: 992px) {
    .app-main {
        padding-right: 7rem;
    }
}
