/* بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ */
/* ----------------------------- */
/* PROJECT */
/* ----------------------------- */
/* Author: @GameDev */
/* Project: AFTER SCHOOL - LMS */
/* Purpose: Mengatur tampilan Login dan Attendance pada ponsel dan desktop. */
/* Version: v0.1.0 */

/* ----------------------------- */
/* CONFIG */
/* ----------------------------- */

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

/* ----------------------------- */
/* VARIABLE */
/* ----------------------------- */

:root {
    color-scheme: light;
    --bg: #f5f5f5;
    --paper: #fff;
    --ink: #1c1c1c;
    --muted: #625f59;
    --line: #e2dfd9;
    --field: #f5f2f0;
    --lime: #bee04b;
    --green: #506515;
    --green-soft: #f3f8ee;
    --green-line: #dce7d6;
    --amber: #795419;
    --red: #9d3834;
    --red-soft: #fae8e6;
    --dark: #27331a;
    --radius: 15px;
    --gutter: 24px;
}

/* ----------------------------- */
/* FUNCTION */
/* ----------------------------- */

.teacher-ui { margin: 0; color: var(--ink); background: var(--bg); font: 15px/1.42 Arial, sans-serif; }
.teacher-ui [hidden] { display: none !important; }
.teacher-ui h1, .teacher-ui h2, .teacher-ui p { margin: 0; }
.teacher-ui h1 { font-size: clamp(1.75rem, 7vw, 1.94rem); line-height: 1.12; }
.teacher-ui h2 { font-size: 1.25rem; line-height: 1.22; }
.teacher-ui button, .teacher-ui input, .teacher-ui select { font: inherit; }
.teacher-ui button, .teacher-ui a, .teacher-ui select { -webkit-tap-highlight-color: transparent; }
.teacher-ui a { color: inherit; text-decoration: none; }
.teacher-ui button { cursor: pointer; }
.teacher-ui :focus-visible { outline: 2px solid #49621b; outline-offset: 3px; }
.teacher-ui button:disabled { background: #e7e5e2; color: #635e58; border-color: #dad6d1; cursor: default; }
.teacher-icon { display: block; width: 19px; height: 19px; flex: 0 0 auto; }
.skip-link { position: fixed; z-index: 6; inset: 8px auto auto 8px; padding: 12px; background: var(--paper); transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }

/* ----------------------------- */
/* MAIN */
/* ----------------------------- */

.teacher-header { background: var(--bg); padding: 0 var(--gutter); }
.teacher-header__content { min-height: 72px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { font-size: 18px; font-weight: 700; }
.teacher-profile { display: grid; place-items: center; min-height: 44px; min-width: 44px; margin-right: -4px; color: var(--green); background: radial-gradient(circle, #edf4dc 0 18px, transparent 18.5px); border: 0; border-radius: 50%; font-weight: 700 !important; }
.teacher-nav { position: fixed; z-index: 5; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--paper); border-top: 1px solid var(--line); padding: 0 0 env(safe-area-inset-bottom); }
.teacher-nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 7px; min-height: 75px; padding: 16px 3px 4px; color: var(--muted); font-size: 12px; line-height: 1.17; }
.teacher-nav a > * { position: relative; }
.teacher-nav [aria-current="page"]::before { position: absolute; top: 11px; left: 50%; width: 48px; height: 28px; border-radius: 16px; background: #edf4dc; transform: translateX(-50%); content: ""; }
.teacher-nav [aria-current="page"] { color: var(--green); font-weight: 700; }
.teacher-main { width: 100%; padding: 24px var(--gutter) calc(88px + env(safe-area-inset-bottom)); }
.teacher-main > .message { margin-bottom: 16px; }
.module-preview { display: grid; gap: 28px; padding-top: 4px; }
.module-preview h1 { font-size: 31px; line-height: 36px; }
.module-preview__status { display: flex; align-items: center; gap: 8px; min-height: 53px; padding: 10px 15px; border-radius: 11px; color: var(--green); background: #fff0d6; font-weight: 700; }
.module-preview__status .teacher-icon { width: 20px; height: 20px; color: var(--amber); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 9px 12px; border: 1px solid transparent; border-radius: 11px; color: var(--ink); font-weight: 700 !important; text-align: center; }
.button .teacher-icon { width: 17px; height: 17px; }
.button--primary { color: var(--ink); background: var(--lime); }
.button--secondary { color: var(--dark); background: var(--paper); border-color: #8b9881; }
.button--danger { color: var(--paper); background: var(--red); }
.button--primary:enabled:hover { background: #afd43e; }
.button--danger:enabled:hover { background: #8e302e; }
.message { padding: 13px 15px; border-radius: 12px; background: var(--paper); color: var(--muted); }
.message--error { color: #782d2a; background: var(--red-soft); }
.meeting-notice, .dialog-feedback { color: var(--muted); }
.meeting-notice a { color: var(--green); font-weight: 700; text-decoration: underline; }
.dialog-feedback:not([hidden]) { color: var(--red); }

.login-brand { padding: 24px var(--gutter) 0; }
.login-brand__title { display: none; }
.login-content { padding: 65px var(--gutter) 48px; }
.login-content h1 { font-size: 35px; }
.login-content .login-subtitle { margin-top: 5px; color: var(--muted); }
.login-card { display: grid; gap: 9px; margin-top: 35px; padding: 20px; border-radius: 18px; background: var(--paper); }
.login-card label { color: #484743; font-size: 14px; font-weight: 700; }
.login-card label:not(:first-child) { margin-top: 4px; }
.login-card button { margin-top: 10px; justify-content: flex-start; }
.login-card .login-help { margin-top: 7px; color: var(--muted); font-size: 13px; }
.input-icon { position: relative; display: block; min-width: 0; }
.input-icon .teacher-icon { position: absolute; inset: 50% 12px auto auto; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input, .roster-search input { width: 100%; min-height: 47px; padding: 11px 37px 11px 13px; border: 1px solid transparent; border-radius: 11px; background: var(--field); color: var(--ink); }
.input-icon input[aria-invalid="true"] { border-color: var(--red); }

.schedule-grid { display: grid; gap: 11px; margin-top: 17px; }
.schedule-card { min-width: 0; border-radius: var(--radius); padding: 12px 15px; background: var(--paper); }
.schedule-card:hover { box-shadow: 0 0 0 1px var(--green-line); }
.schedule-card__title { display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(0, .85fr) auto; gap: 8px; align-items: center; }
.schedule-card__title div { min-width: 0; }
.schedule-card__title div span, .context-select > span:first-child { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.schedule-card__title strong { display: block; margin-top: 2px; overflow-wrap: anywhere; font-size: 17px; }
.schedule-card__status { text-align: right; color: var(--muted); font-weight: 700; font-size: 11px; }
.schedule-card__time { display: flex; align-items: center; gap: 7px; margin-top: 8px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.schedule-card__time .teacher-icon:first-child { color: var(--green); }
.schedule-card__time .teacher-icon:last-child { margin-left: auto; width: 15px; }
.schedule-more { padding-top: 16px; text-align: center; }
.schedule-more[data-auto]:not([data-manual]) a { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; overflow: hidden; clip-path: inset(50%); }
.schedule-more[data-auto]:not([data-manual]) a:focus-visible { position: static; width: auto; height: auto; padding: 9px 12px; clip-path: none; }

.back-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--green) !important; font-size: 14px; font-weight: 700; }
.back-link .teacher-icon { width: 16px; }
.meeting { display: grid; gap: 13px; }
.meeting .back-link { justify-self: start; margin: -14px 0 -18px; }
.meeting-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meeting-heading h1 { font-size: 31px; }
.meeting-heading .button { flex-shrink: 0; min-width: 131px; padding-inline: 10px; font-size: 12px; }
.meeting-context { display: grid; gap: 6px; background: var(--paper); border-radius: var(--radius); padding: 11px 12px 13px; }
.meeting-context p { color: var(--muted); font-size: 13px; }
.meeting-state--locked { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.meeting-state--locked .teacher-icon { width: 16px; height: 16px; }
.meeting-context .meeting-class { font-size: 18px; }
.context-selects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 2px; }
.context-select, .select-wrap { min-width: 0; }
.select-wrap { position: relative; display: block; margin-top: 4px; }
.select-wrap select { appearance: none; min-height: 40px; width: 100%; padding: 8px 28px 8px 12px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-weight: 700; }
.select-wrap .teacher-icon { position: absolute; inset: 50% 8px auto auto; transform: translateY(-50%); pointer-events: none; color: var(--green); }
.roster-tools { display: grid; gap: 10px; }
.roster-counts { display: flex; gap: 17px; align-items: center; font-size: 12px; font-weight: 700; }
.roster-search { position: relative; color: var(--muted); }
.roster-search > .teacher-icon { position: absolute; left: 12px; top: 13px; pointer-events: none; }
.roster-search input { padding: 9px 44px 9px 40px; background: var(--paper); }
.roster-search input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 2px; top: 1px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); }
.status--present { color: var(--green) !important; }
.status--pending { color: var(--amber); }
.status--absent { color: #8a3835; }

.roster-grid { display: grid; gap: 10px; }
.student-card { position: relative; display: grid; grid-template-columns: 65px minmax(0, 1fr) 44px; align-items: start; column-gap: 1px; row-gap: 3px; min-height: 91px; padding: 11px 10px 11px 7px; background: var(--paper); border: 1px solid transparent; border-radius: var(--radius); }
.student-card__action { position: absolute; z-index: 2; inset: 0; width: 100%; padding: 0; border: 0; border-radius: inherit; background: transparent; }
.student-card--present { background: var(--green-soft); border-color: var(--green-line); }
.student-identity { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-top: 3px; }
.student-identity h2 { font-size: 16px; overflow-wrap: anywhere; }
.student-identity p { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.student-avatar { grid-column: 1; grid-row: 1 / span 2; align-self: center; position: relative; display: grid; place-items: center; width: 65px; height: 65px; }
.student-avatar picture { grid-area: 1 / 1; z-index: 1; width: 100%; height: 100%; min-height: 0; }
.student-avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.student-avatar__fallback { grid-area: 1 / 1; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--green); background: #e9efdf; font-weight: 700; }
.student-avatar picture:not([hidden]) + .student-avatar__fallback { visibility: hidden; }
.student-status { grid-column: 2 / span 2; grid-row: 2; justify-self: end; align-self: end; padding-right: 4px; font-size: 11px; font-weight: 700; }
.student-menu, .icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; color: #484743; background: var(--field); }
.student-menu { grid-column: 3; grid-row: 1; }
.student-menu:hover, .icon-button:hover { background: #e9e4e0; }

.teacher-dialog { width: min(calc(100% - 32px), 342px); max-height: calc(100% - 32px); padding: 20px; border: 0; border-radius: 20px; background: var(--paper); color: var(--ink); }
.teacher-dialog::backdrop { background: #0006; }
.teacher-dialog h2 { font-size: 23px; overflow-wrap: anywhere; }
.teacher-dialog p { margin-top: 8px; color: var(--muted); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.dialog-actions > :only-child, .dialog-actions--single > button { grid-column: 1 / -1; }
.bluetooth-dialog { text-align: center; }
.bluetooth-symbol { display: grid; place-items: center; margin: 2px auto 15px; width: 58px; height: 58px; color: var(--green); background: #edf4dc; border-radius: 15px; }
.bluetooth-symbol .teacher-icon { width: 27px; height: 27px; }
.bluetooth-symbol [data-icon] { display: none; }
.bluetooth-symbol:not([data-result]) [data-icon="scan"],
.bluetooth-symbol[data-result="scanning"] [data-icon="scan"],
.bluetooth-symbol[data-result="verified"] [data-icon="check"],
.bluetooth-symbol[data-result="failed"] [data-icon="warning"] { display: block; }
.bluetooth-symbol[data-result="failed"] { color: var(--red); background: var(--red-soft); }
.bluetooth-context { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0 0; }
.bluetooth-context span, .bluetooth-context strong { display: block; }
.bluetooth-context span { color: var(--muted); font-size: 12px; }

form[data-busy] button:not([type="button"]):not([hidden])::after { width: 12px; height: 12px; flex: 0 0 auto; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; content: ""; }

@media (hover: hover) {
    .student-card:has(.student-card__action:hover) { border-color: var(--green-line); }
}

@media (prefers-reduced-motion: no-preference) {
    .teacher-ui :is(.button, .teacher-profile, .student-menu, .icon-button, .search-clear),
    .student-card:has(.student-card__action) { transition: transform 130ms ease, background-color 130ms ease, border-color 130ms ease; }
    .teacher-ui :is(.button, .teacher-profile, .student-menu, .icon-button, .search-clear):enabled:active { transform: scale(.96); }
    .student-card:has(.student-card__action:active) { transform: scale(.985); background: #e8f0df; }
    .teacher-dialog[open] { animation: dialog-enter 180ms ease-out both; }
    .teacher-dialog[open]::backdrop { animation: backdrop-enter 180ms ease-out both; }
    form[data-busy] button:not([type="button"]):not([hidden])::after { animation: submit-spin 700ms linear infinite; }
    .bluetooth-symbol[data-result="scanning"] { animation: scan-pulse 850ms ease-in-out infinite alternate; }

    @keyframes dialog-enter {
        from { opacity: 0; transform: translateY(8px) scale(.98); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }
    @keyframes backdrop-enter {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    @keyframes submit-spin {
        to { transform: rotate(1turn); }
    }
    @keyframes scan-pulse {
        from { opacity: .65; }
        to { opacity: 1; }
    }
}

@media (max-width: 359px) {
    :root { --gutter: 16px; }
    .schedule-card { padding-inline: 12px; }
    .schedule-card__title { gap: 5px; }
    .schedule-card__title strong { font-size: 15px; }
    .meeting-heading .button { padding-inline: 8px; }
}
@media (min-width: 640px) {
    .schedule-grid, .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .meeting-context { padding-inline: 18px; }
    .context-selects { width: min(100%, 500px); }
    .roster-tools { grid-template-columns: 1fr minmax(200px, 330px); align-items: center; }
    .roster-grid > .message, .schedule-grid > .message { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
    .teacher-header { background: var(--paper); border-bottom: 1px solid var(--line); padding-inline: 34px; }
    .teacher-header__content { max-width: 1128px; min-height: 79px; margin: auto; display: grid; grid-template-columns: 1fr auto 1fr; border: 0; }
    .teacher-profile { justify-self: end; }
    .teacher-nav { position: static; width: 480px; border: 0; padding: 0; }
    .teacher-nav a { min-height: 48px; padding: 4px; gap: 7px; flex-direction: row; justify-content: center; border-radius: 12px; white-space: nowrap; }
    .teacher-nav [aria-current="page"]::before { inset: 3px 4px; width: auto; height: auto; border-radius: 12px; transform: none; }
    .teacher-main { box-sizing: content-box; width: auto; max-width: 1128px; margin: auto; padding: 36px 34px 46px; }
    .teacher-ui h1 { font-size: 43px; }
    .module-preview { gap: 24px; padding-top: 2px; }
    .module-preview h1 { font-size: 43px; line-height: 49px; }
    .login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 45%) minmax(0, 1fr); }
    .login-brand { padding: 54px 10%; background: var(--dark); color: var(--paper); }
    .login-brand .wordmark { font-size: 21px; }
    .login-brand .login-brand__title { display: block; margin-top: min(20vh, 175px); font-size: clamp(40px, 5vw, 65px); font-weight: 700; line-height: 1.08; }
    .login-content { width: min(100%, 550px); margin: 0 auto; padding: min(20vh, 180px) 36px 64px; }
    .login-card { margin-top: 30px; }
    .schedule-grid { gap: 22px; margin-top: 24px; }
    .schedule-card { min-height: 166px; padding: 20px 24px; }
    .schedule-card__title strong { font-size: 26px; }
    .schedule-card__title div span { font-size: 13px; }
    .schedule-card__status { font-size: 13px; }
    .schedule-card__time { margin-top: 21px; padding-top: 15px; font-size: 15px; }
    .meeting-heading h1 { font-size: 43px; }
    .meeting-heading .button { min-width: 167px; font-size: 14px; }
    .meeting { gap: 16px; }
    .meeting .back-link { margin-bottom: -13px; }
    .meeting-context { padding: 14px; }
    .context-selects { gap: 20px; }
    .meeting-context p { font-size: 15px; }
    .roster-grid { gap: 20px; }
    .student-card { grid-template-columns: 1fr; grid-template-rows: minmax(min-content, 1fr) 232px auto; justify-items: center; row-gap: 0; padding: 18px 13px 48px; min-height: 381px; }
    .student-card:not(.student-card--present) { border-color: var(--line); }
    .meeting[data-state="active"] .student-identity { padding-inline: 45px; }
    .student-identity { grid-area: 1 / 1; text-align: center; width: 100%; }
    .student-identity h2 { font-size: 19px; }
    .student-identity p { font-size: 13px; }
    .student-avatar { grid-area: 2 / 1; width: 100%; max-width: 171px; height: 232px; }
    .student-avatar__fallback { width: 65px; height: 65px; font-size: 20px; }
    .student-status { grid-area: 3 / 1; justify-self: center; padding: 15px 0 0; }
    .student-menu { position: absolute; top: 9px; right: 8px; }
    .teacher-dialog { width: min(calc(100% - 32px), 440px); }
}
@media (min-width: 1050px) {
    .roster-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
