/* UI-SPECIFICATION.md adaptation, 2026-11-08.
   Presentation only. Keep Bootstrap behavior, page layout and print styles intact.
   Use the 14px competition scale with existing Bootstrap components. */
@layer ui-flat-surfaces {
    body.ui-spec-skin,
    body.ui-spec-skin *,
    body.ui-spec-skin::before,
    body.ui-spec-skin::after,
    body.ui-spec-skin *::before,
    body.ui-spec-skin *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    body.ui-spec-skin .header-v5 .lms-brand-lockup .lms-brand-photo img {
        filter: none !important;
    }
}

@media screen {
    /* Action colors take precedence over the page theme. */
    html body.ui-spec-skin :is(a, button, input[type="submit"]):is(
        .ui-action-add, .staff-group-management-action, .staff-admin-teacher-create-action,
        .eb-open-create, .lms-nav-btn[href*="p=new"], [value^="เพิ่ม"],
        :has(> :is(.fa-plus, .fa-plus-square, .fa-plus-square-o))
    ) {
        --ui-action-background: #198754;
        --ui-action-hover: #157347;
    }

    html body.ui-spec-skin :is(a, button, input[type="submit"]):is(
        .ui-action-save, .staff-course-edit-save, .staff-profile-primary-btn, [value^="บันทึก"],
        :has(> :is(.fa-save, .fa-floppy-o))
    ) {
        --ui-action-background: #0d6efd;
        --ui-action-hover: #0b5ed7;
    }

    /* Keep specificity above legacy staff action and theme rules. */
    html body.ui-spec-skin:is(#staffDashboard, .ui-spec-skin) :is(a, button, input[type="submit"]):is(
        .ui-action-add, .ui-action-save, .staff-group-management-action, .staff-admin-teacher-create-action,
        .staff-course-edit-save, .staff-profile-primary-btn, .eb-open-create, .lms-nav-btn[href*="p=new"],
        [value^="เพิ่ม"], [value^="บันทึก"],
        :has(> :is(.fa-plus, .fa-plus-square, .fa-plus-square-o, .fa-save, .fa-floppy-o))
    ) {
        background: var(--ui-action-background) !important;
        border-color: var(--ui-action-background) !important;
        color: #fff !important;
    }

    html body.ui-spec-skin:is(#staffDashboard, .ui-spec-skin) :is(a, button, input[type="submit"]):is(
        .ui-action-add, .ui-action-save, .staff-group-management-action, .staff-admin-teacher-create-action,
        .staff-course-edit-save, .staff-profile-primary-btn, .eb-open-create, .lms-nav-btn[href*="p=new"],
        [value^="เพิ่ม"], [value^="บันทึก"],
        :has(> :is(.fa-plus, .fa-plus-square, .fa-plus-square-o, .fa-save, .fa-floppy-o))
    ):is(:hover, :focus-visible, :active) {
        background: var(--ui-action-hover) !important;
        border-color: var(--ui-action-hover) !important;
    }
    html body.ui-spec-skin {
        --site-font-primary: "Noto Sans Thai Looped", "Google Sans", "Noto Sans Thai", Tahoma, sans-serif;
        --site-font-secondary: var(--site-font-primary);
        font-family: var(--site-font-primary) !important;
        font-size: 14px;
        line-height: 1.5;
    }
    html body.ui-spec-skin :is(p, li, label, .help-block, .form-control, .btn, .btn-u, .nav a, .panel-title, .modal-title) {
        font-family: var(--site-font-primary) !important;
    }
    html body.ui-spec-skin :is(p, label, .help-block) { font-size: 14px; line-height: 1.5; }
    html body.ui-spec-skin h1 { font-size: 28px; font-weight: 500; line-height: 1.5; }
    html body.ui-spec-skin h2 { font-size: 21px; font-weight: 500; line-height: 1.5; }
    html body.ui-spec-skin h3 { font-size: 17px; font-weight: 500; line-height: 1.6; }
    html body.ui-spec-skin .panel-title { font-size: 19px; line-height: 1.6; }

    /* Keep the existing menu hierarchy, collapse breakpoints and positioning. */
    html body.ui-spec-skin .lms-main-nav > li > a {
        font-size: 14px !important; line-height: 1.5 !important;
        min-height: 45px; padding: 12px 14px !important;
    }
    html body.ui-spec-skin .dropdown-menu > li > a {
        font-size: 13px !important; line-height: 1.7 !important;
        padding: 9px 14px !important; white-space: normal;
    }
    html body.ui-spec-skin .cs-sidebar :is(.cs-section-toggle, .cs-grade, a) {
        border-radius: 5px !important; line-height: 1.65 !important;
    }
    html body.ui-spec-skin .cs-sidebar .cs-section-toggle {
        font-size: 14px !important; font-weight: 500; min-height: 45px;
        padding: 12px 14px !important;
    }
    html body.ui-spec-skin .cs-sidebar :is(.cs-grade, a) {
        font-size: 12px !important; min-height: 36px; padding: 9px 8px !important;
    }
    html body.ui-spec-skin .nav-tabs > li > a {
        font-size: 14px; line-height: 1.5; padding: 11px 15px;
    }

    html body.ui-spec-skin :is(.btn, .btn-u):not(.rounded-x, .btn-circle, .btn-round) {
        font-size: 14px !important; font-weight: 400;
        line-height: 1.42857143 !important;
        padding: 6px 12px; border-radius: 4px !important;
        max-width: 100%; white-space: normal;
    }
    html body.ui-spec-skin :is(.btn-sm, .btn-u-sm, .btn-xs, .btn-u-xs):not(.rounded-x, .btn-circle, .btn-round) {
        font-size: 12px !important; line-height: 1.5 !important;
        padding: 5px 10px; border-radius: 3px !important;
    }
    html body.ui-spec-skin :is(a, button, input, select, textarea, [tabindex]):focus-visible {
        outline: 3px solid #448aff !important; outline-offset: 2px;
    }
    html body.ui-spec-skin :is(.btn, .btn-u):disabled,
    html body.ui-spec-skin :is(.btn, .btn-u).disabled { opacity: .65; cursor: not-allowed; }
    html body.ui-spec-skin :is(input.form-control, select.form-control) {
        height: 42px; font-size: 13px !important; line-height: 1.5;
        padding: 9px 12px; border-radius: 5px !important;
    }
    html body.ui-spec-skin textarea.form-control {
        font-size: 13px !important; line-height: 1.6;
        padding: 10px 12px; border-radius: 5px !important;
    }
    html body.ui-spec-skin .form-group { margin-bottom: 16px; }
    html body.ui-spec-skin .table:not(.table-condensed) > :is(thead, tbody, tfoot) > tr > :is(th, td) {
        font-size: 14px; line-height: 1.5; padding: 11px 12px; vertical-align: middle; overflow-wrap: anywhere;
    }
    html body.ui-spec-skin .table:not(.table-condensed) > thead > tr > th { font-size: 13px; font-weight: 600; }

    /* Bootstrap modal keeps its markup, events, sizes and focus management. */
    html body.ui-spec-skin .modal-dialog { max-width: calc(100% - 32px); }
    html body.ui-spec-skin .modal-content { border-radius: 8px !important; }
    html body.ui-spec-skin .modal-header { padding: 16px 20px; }
    html body.ui-spec-skin .modal-title { font-size: 19px !important; font-weight: 500; line-height: 1.5 !important; }
    html body.ui-spec-skin .modal-body { padding: 22px 20px; font-size: 14px; line-height: 1.8; overflow-wrap: anywhere; }
    html body.ui-spec-skin .modal-footer { padding: 12px 20px; }
    html body.ui-spec-skin .modal-header .close {
        width: 34px; height: 34px; margin-top: 0; padding: 0;
        font-size: 26px !important; line-height: 32px !important;
        border-radius: 4px !important;
    }
    html body.ui-spec-skin .modal-footer :is(.btn, .btn-u) { min-height: 44px; padding: 10px 18px; }
    @media (max-width: 600px) {
        html body.ui-spec-skin :is(input.form-control, select.form-control, textarea.form-control) {
            font-size: 16px !important; padding: 8px 12px;
        }
        html body.ui-spec-skin :is(input.form-control, select.form-control) { height: 44px; }
        html body.ui-spec-skin .panel-title { font-size: 17px; }
        html body.ui-spec-skin .modal-dialog { margin: 16px auto; }
    }
}

/* Eduport palette for the existing screen controls. */
@media screen {
    html body.ui-spec-skin {
        --edu-accent: #066ac9;
        --edu-accent-soft: #e6f0fa;
        --edu-danger: #a62435;
        --edu-danger-soft: #fce9ec;
        --edu-surface: #f5f7f9;
        --edu-border: #dde4eb;
        --edu-ink: #24292d;
    }

    html body.ui-spec-skin :is(.btn, .btn-u, .lms-nav-btn):not(.rounded-x, .btn-circle, .btn-round) {
        border-radius: 6px !important;
    }

    html body.ui-spec-skin :is(.btn-primary, .btn-u-blue, .lms-nav-btn-primary) {
        background-color: var(--edu-accent) !important;
        border-color: var(--edu-accent) !important;
        color: #fff !important;
    }

    html body.ui-spec-skin :is(.btn-primary, .btn-u-blue, .lms-nav-btn-primary):is(:hover, :focus-visible) {
        background-color: #0556a3 !important;
        border-color: #0556a3 !important;
    }

    html body.ui-spec-skin :is(.btn-default, .lms-nav-btn-secondary) {
        background-color: var(--edu-accent-soft) !important;
        border-color: var(--edu-accent-soft) !important;
        color: #07589f !important;
    }

    html body.ui-spec-skin :is(.btn-default, .lms-nav-btn-secondary):is(:hover, :focus-visible) {
        background-color: #d3e7fa !important;
        border-color: #d3e7fa !important;
    }

    html body.ui-spec-skin :is(.btn-danger, .btn-u-red) {
        background-color: var(--edu-danger-soft) !important;
        border-color: var(--edu-danger-soft) !important;
        color: var(--edu-danger) !important;
    }

    html body.ui-spec-skin :is(.btn-danger, .btn-u-red):is(:hover, :focus-visible) {
        background-color: #f8d6dc !important;
        border-color: #f8d6dc !important;
    }

}

/* Shared data-table appearance takes precedence over older page palettes. */
@layer data-table-appearance {
    .ui-spec-skin {
        --data-table-line: #e0e4ea;
        --data-table-heading: #f5f6f8;
        --data-table-ink: #475569;
        --data-table-radius: 10px;
    }

    .ui-spec-skin table:has(> thead > tr > :is(th, td), > tbody > tr > th) {
        border-collapse: separate !important;
        border-spacing: 0 !important;
        border: 1px solid var(--data-table-line) !important;
        border-radius: var(--data-table-radius) !important;
        background-color: #fff !important;
    }

    .ui-spec-skin table:has(> thead, > tbody > tr > th) > :is(thead, tbody, tfoot) > tr > :is(th, td) {
        border-inline-width: 0 !important;
    }

    .ui-spec-skin table:has(> thead, > tbody > tr > th) > tbody > tr:not(.is-selected) > td {
        background-color: #fff !important;
    }

    .ui-spec-skin :is(.table-responsive, .staff-group-table-wrap, .staff-student-group-table-wrap, .staff-student-list-table-wrap, .eb-table-scroll):has(> table > thead) {
        border: 0 !important;
        box-shadow: none !important;
    }

    .ui-spec-skin table > thead > tr > :is(th, td),
    .ui-spec-skin table:not(:has(> thead)) > tbody > tr:first-child > th {
        background-color: #f5f6f8 !important;
        color: var(--data-table-ink) !important;
        border-color: var(--data-table-line) !important;
    }

    .ui-spec-skin table > thead:first-of-type > tr:first-child > :first-child {
        border-start-start-radius: calc(var(--data-table-radius) - 1px);
    }

    .ui-spec-skin table > thead:first-of-type > tr:first-child > :last-child {
        border-start-end-radius: calc(var(--data-table-radius) - 1px);
    }

    @media (min-width: 1101px) {
        .ui-spec-skin table:has(> thead > tr > :is(th, td), > tbody > tr > th) > :is(thead, tbody, tfoot) > tr > :is(th, td) {
            border-top-width: 0 !important;
            border-bottom: 1px solid var(--data-table-line) !important;
            padding: 5px 14px !important;
        }

        .ui-spec-skin .staff-group-list-page:not(.staff-group-list-page--register) .staff-group-table > :is(thead, tbody) > tr {
            border-bottom: 0 !important;
        }

        .ui-spec-skin table > :is(tbody, tfoot):last-child > tr:last-child > :is(th, td) {
            border-bottom-width: 0 !important;
        }
    }
}
