/* ==========================================================================
   SFVCCA Chinese School — portal (login + role dashboards)
   Loaded after style.css, which provides the design tokens.
   ========================================================================== */

/* ------------------------------------------------------------ login page */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--bg);
}

.login-aside {
    background:
        radial-gradient(600px 380px at 20% 12%, rgba(232, 23, 93, .34) 0%, transparent 62%),
        radial-gradient(520px 340px at 88% 82%, rgba(245, 185, 33, .26) 0%, transparent 60%),
        linear-gradient(155deg, var(--navy) 0%, var(--navy-dk) 100%);
    color: #fff;
    padding: 56px 54px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.login-aside::after {
    content: '學';
    position: absolute;
    right: -3%;
    bottom: -14%;
    font-family: var(--font-zh);
    font-size: 25rem;
    font-weight: 900;
    color: rgba(255, 255, 255, .05);
    line-height: 1;
    pointer-events: none;
}

.login-aside .brand-zh { color: #fff; font-size: 1.3rem; }
.login-aside .brand-en { color: rgba(255, 255, 255, .6); }

.login-aside-body { margin-top: auto; margin-bottom: auto; position: relative; z-index: 1; }
.login-aside h1 {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 3.4vw, 3rem);
    text-transform: uppercase;
    color: #fff;
    line-height: 1.02;
    margin-bottom: 12px;
}
.login-aside h1 em {
    font-style: normal;
    background: linear-gradient(96deg, #ff7aa8, var(--gold));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.login-aside .lede { color: #cfdbf0; font-size: 1rem; max-width: 40ch; }

.login-points { list-style: none; padding: 0; margin: 26px 0 0; }
.login-points li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 13px;
    font-size: .92rem;
    color: #dbe5f5;
}
.login-points svg { flex: none; margin-top: 2px; color: var(--gold); }

.login-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 46px 34px;
}
.login-card { width: 100%; max-width: 410px; }
.login-card h2 { font-size: 1.65rem; color: var(--navy); margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: .93rem; margin-bottom: 26px; }

/* demo account chooser */
.demo-box {
    margin-top: 26px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    background: var(--bg-soft);
}
.demo-box h3 {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 700;
}
.demo-list { display: grid; gap: 8px; }
.demo-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.demo-btn:hover {
    border-color: var(--crimson);
    box-shadow: 0 3px 12px rgba(232, 23, 93, .14);
    transform: translateY(-1px);
}
.demo-btn .avatar { width: 32px; height: 32px; font-size: .72rem; }
.demo-btn-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.demo-btn-role { font-weight: 700; font-size: .88rem; color: var(--ink); }
.demo-btn-cred { font-size: .76rem; color: var(--muted); font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.demo-btn .go { margin-left: auto; color: var(--muted); flex: none; }
.demo-btn:hover .go { color: var(--crimson); }

/* ------------------------------------------------------------ portal shell */
.portal-body { background: var(--bg-soft); min-height: 100vh; }

.portal-shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }

.portal-side {
    background: linear-gradient(170deg, var(--navy) 0%, var(--navy-dk) 100%);
    color: #b9c8e2;
    padding: 22px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    margin-bottom: 16px;
    text-decoration: none;
}
.portal-brand:hover { text-decoration: none; }
.portal-brand svg, .portal-brand img { width: 38px; height: 38px; flex: none; }
.portal-brand .brand-zh { color: #fff; font-size: 1rem; }
.portal-brand .brand-en { color: rgba(255, 255, 255, .55); font-size: .54rem; }

.side-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255, 255, 255, .42);
    padding: 14px 22px 7px;
    font-weight: 700;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    color: #b9c8e2;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.side-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--crimson); color: #fff; box-shadow: var(--shadow-crim); }
.side-nav a svg { flex: none; opacity: .9; }
.side-nav .count {
    margin-left: auto;
    background: var(--gold);
    color: #4a3400;
    font-size: .7rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    line-height: 1.6;
}
.side-nav a.active .count { background: #fff; color: var(--crimson); }

.side-foot {
    margin-top: auto;
    padding: 16px 22px 0;
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.side-user { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.side-user-text { min-width: 0; line-height: 1.3; }
.side-user-name {
    color: #fff;
    font-weight: 700;
    font-size: .87rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-user-role { font-size: .74rem; color: rgba(255, 255, 255, .55); }
.side-foot a { color: #b9c8e2; font-size: .84rem; display: inline-flex; align-items: center; gap: 7px; }
.side-foot a:hover { color: #fff; text-decoration: none; }

/* --------------------------------------------------------- portal main */
.portal-main { min-width: 0; display: flex; flex-direction: column; }

.portal-top {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 16px 30px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.portal-top h1 { font-size: 1.3rem; margin: 0; color: var(--navy); }
.portal-top .sub { font-size: .85rem; color: var(--muted); margin: 2px 0 0; }

.portal-content { padding: 26px 30px 50px; flex: 1; }

.portal-toggle { display: none; background: none; border: 0; cursor: pointer; color: var(--navy); padding: 4px; }

/* greeting banner */
.greet {
    background: linear-gradient(115deg, var(--navy) 0%, #1c4a8f 55%, #2a5fa8 100%);
    border-radius: var(--radius-lg);
    padding: 26px 30px;
    color: #dbe5f5;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.greet::after {
    content: '';
    position: absolute;
    right: -60px; top: -60px;
    width: 240px; height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 185, 33, .22) 0%, transparent 68%);
}
.greet h2 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 5px;
    position: relative;
    z-index: 1;
}
.greet p { margin: 0; font-size: .93rem; position: relative; z-index: 1; max-width: 62ch; }
.greet .zh-inline { color: rgba(255, 255, 255, .62); }

/* ------------------------------------------------------------ stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }

.tile {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform .16s ease, box-shadow .16s ease;
    text-decoration: none;
}
a.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }

.tile-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid; place-items: center;
    flex: none;
}
.ti-crimson { background: var(--crimson-lt); color: var(--crimson); }
.ti-orange  { background: var(--orange-lt);  color: var(--orange); }
.ti-gold    { background: var(--gold-lt);    color: #b8860b; }
.ti-navy    { background: var(--navy-lt);    color: var(--navy); }
.ti-green   { background: var(--green-lt);   color: var(--green); }

.tile-num { font-size: 1.6rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.tile-label { font-size: .81rem; color: var(--muted); font-weight: 600; line-height: 1.3; }

/* --------------------------------------------------------- panel + table */
.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line-soft);
    flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 1.03rem; color: var(--navy); }
.panel-head .sub { font-size: .82rem; color: var(--muted); margin: 2px 0 0; }
.panel-head .ml-auto { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-body { padding: 22px; }
.panel-body-flush { padding: 0; }

.data-table { width: 100%; font-size: .9rem; }
.data-table th {
    text-align: left;
    padding: 11px 18px;
    background: var(--bg-soft);
    color: var(--muted);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table td {
    padding: 13px 18px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fcfdff; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .student-cell { display: flex; align-items: center; gap: 11px; }
.data-table .student-cell .name { font-weight: 600; color: var(--ink); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------- badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.b-graded    { background: var(--green-lt);   color: #1c6e49; }
.b-submitted { background: var(--navy-lt);    color: var(--navy); }
.b-late      { background: var(--gold-lt);    color: #8a6200; }
.b-missing   { background: var(--crimson-lt); color: var(--crimson-dk); }
.b-pending   { background: #f1f3f7;           color: var(--muted); }
.b-high      { background: var(--crimson-lt); color: var(--crimson-dk); }
.b-medium    { background: var(--gold-lt);    color: #8a6200; }
.b-low       { background: var(--navy-lt);    color: var(--navy); }
.b-open      { background: var(--crimson-lt); color: var(--crimson-dk); }
.b-improving { background: var(--gold-lt);    color: #8a6200; }
.b-resolved  { background: var(--green-lt);   color: #1c6e49; }

/* grade pill */
.grade-pill {
    display: inline-grid;
    place-items: center;
    min-width: 50px;
    padding: 5px 11px;
    border-radius: 8px;
    font-weight: 800;
    font-size: .93rem;
    font-variant-numeric: tabular-nums;
}
.g-excellent { background: var(--green-lt);   color: #1c6e49; }
.g-good      { background: var(--navy-lt);    color: var(--navy); }
.g-fair      { background: var(--gold-lt);    color: #8a6200; }
.g-poor      { background: var(--crimson-lt); color: var(--crimson-dk); }
.g-muted     { background: #f1f3f7;           color: var(--muted); }

/* ------------------------------------------------------------- progress */
.bar {
    height: 8px;
    background: var(--line-soft);
    border-radius: 999px;
    overflow: hidden;
    min-width: 70px;
}
.bar span { display: block; height: 100%; border-radius: 999px; }
.bar-excellent span { background: var(--green); }
.bar-good      span { background: var(--navy); }
.bar-fair      span { background: var(--gold); }
.bar-poor      span { background: var(--crimson); }
.bar-muted     span { background: var(--line); }

/* grade distribution chart */
.dist { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding: 0 4px; }
.dist-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.dist-bar {
    width: 100%;
    max-width: 54px;
    border-radius: 7px 7px 0 0;
    min-height: 4px;
    transition: height .4s ease;
    position: relative;
}
.dist-A { background: linear-gradient(180deg, #3fbf87, var(--green)); }
.dist-B { background: linear-gradient(180deg, #3f7fd0, var(--navy)); }
.dist-C { background: linear-gradient(180deg, #f7c94a, var(--gold)); }
.dist-D { background: linear-gradient(180deg, #fa9a44, var(--orange)); }
.dist-F { background: linear-gradient(180deg, #f4557f, var(--crimson)); }
.dist-count { font-size: .82rem; font-weight: 800; color: var(--ink); }
.dist-label { font-size: .84rem; font-weight: 700; color: var(--muted); }

/* --------------------------------------------------------------- forms */
/* .field / .input / .select / .textarea / .field-row / .form-actions /
   .check-row all live in style.css, since the public contact page needs them
   too. Only the portal-specific file drop zone is defined here. */

.file-drop {
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    padding: 26px 20px;
    text-align: center;
    background: var(--bg-soft);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.file-drop:hover, .file-drop.drag { border-color: var(--crimson); background: var(--crimson-lt); }
.file-drop input[type=file] { display: none; }
.file-drop .icon { color: var(--muted); margin: 0 auto 10px; }
.file-drop strong { color: var(--crimson); }
.file-drop .file-name { margin-top: 9px; font-size: .86rem; color: var(--ink); font-weight: 600; }

/* --------------------------------------------------------------- lists */
.list-item {
    display: flex;
    gap: 15px;
    padding: 15px 22px;
    border-bottom: 1px solid var(--line-soft);
    align-items: flex-start;
    text-decoration: none;
    transition: background .14s ease;
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: #fcfdff; text-decoration: none; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 700; color: var(--ink); font-size: .95rem; margin-bottom: 2px; }
.list-item-meta { font-size: .81rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }
.list-item-side { flex: none; text-align: right; }
.list-item.unread { background: #fffdf5; }
.list-item.unread .list-item-title::before {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--crimson);
    margin-right: 8px;
    vertical-align: middle;
}

/* class cards */
.class-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease;
    display: flex;
    flex-direction: column;
    text-decoration: none;
}
a.class-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); text-decoration: none; }
.class-card-top {
    padding: 16px 20px;
    background: linear-gradient(120deg, var(--navy), #2a5fa8);
    color: #fff;
}
.class-card-top .code {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .75;
    font-weight: 700;
}
.class-card-top h3 { color: #fff; font-size: 1.08rem; margin: 3px 0 1px; }
.class-card-top .zh { font-family: var(--font-zh); font-size: .88rem; opacity: .8; }
.class-card-body { padding: 16px 20px; flex: 1; }
.class-card-body dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .85rem; }
.class-card-body dt { color: var(--muted); font-weight: 600; }
.class-card-body dd { margin: 0; color: var(--ink); }
.class-card-foot {
    padding: 12px 20px;
    border-top: 1px solid var(--line-soft);
    background: var(--bg-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: .84rem;
}

/* grade breakdown by group */
.breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
}
.breakdown-item {
    background: var(--bg-soft);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 13px 15px;
}
.breakdown-item.is-empty { opacity: .6; }
.breakdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 9px;
}
.breakdown-label { font-size: .84rem; font-weight: 700; color: var(--ink); }
.breakdown-meta { font-size: .74rem; color: var(--muted); margin-top: 7px; }

/* focus-area cards */
.focus-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--muted);
    border-radius: var(--radius-sm);
    padding: 15px 18px;
    margin-bottom: 12px;
    background: #fff;
}
.focus-card.p-high   { border-left-color: var(--crimson); }
.focus-card.p-medium { border-left-color: var(--gold); }
.focus-card.p-low    { border-left-color: var(--navy); }
.focus-card h4 { font-size: .95rem; margin-bottom: 5px; color: var(--ink); }
.focus-card p { font-size: .88rem; margin: 0 0 8px; line-height: 1.6; }
.focus-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }

/* message thread view */
.message-view { padding: 24px; }
.message-view .msg-head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 18px;
}
.message-view h2 { font-size: 1.2rem; margin-bottom: 4px; }
.message-view .msg-body { font-size: .95rem; line-height: 1.75; }
.message-view .msg-body p { margin-bottom: 1.1em; }

/* tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 22px;
    overflow-x: auto;
}
.tabs a {
    padding: 10px 16px;
    font-size: .9rem;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    text-decoration: none;
}
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--crimson); border-bottom-color: var(--crimson); }

/* two-column portal layout */
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.split-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }

/* student header block */
.student-head {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.student-head h2 { margin: 0 0 2px; font-size: 1.35rem; }
.student-head .meta { font-size: .87rem; color: var(--muted); }

/* back link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .86rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 12px;
}
.back-link:hover { color: var(--crimson); text-decoration: none; }

/* mobile sidebar */
.side-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13, 36, 80, .5);
    z-index: 39;
}

@media (max-width: 1080px) {
    .split, .split-even { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-aside { display: none; }

    .portal-shell { grid-template-columns: 1fr; }
    .portal-side {
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: 258px;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    .portal-side.open { transform: translateX(0); }
    .side-scrim.show { display: block; }
    .portal-toggle { display: block; }
    .portal-top { padding: 14px 18px; }
    .portal-content { padding: 20px 18px 44px; }
    .field-row, .field-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .greet { padding: 20px; }
    .greet h2 { font-size: 1.22rem; }
    .panel-body { padding: 18px; }
    .data-table th, .data-table td { padding: 10px 12px; }
    .tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .tile { padding: 14px; flex-direction: column; align-items: flex-start; gap: 9px; }
    .tile-num { font-size: 1.3rem; }
}

@media print {
    .portal-side, .portal-top, .side-scrim, .btn, .tabs { display: none !important; }
    .portal-shell { grid-template-columns: 1fr; }
    .portal-content { padding: 0; }
    .panel { break-inside: avoid; box-shadow: none; }
}
