/* SchoolPRO Hierarchy - Frontend Styles */
/* Minimal structural CSS — inherits theme typography and colors. */

/* Notices */
.sph-fe-notice {
    padding: 16px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.sph-fe-notice-info {
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
}

.sph-fe-notice-warning {
    background: #fef8ee;
    border: 1px solid #dba617;
}

/* Dashboard layout */
.sph-fe-dashboard h2 {
    margin-bottom: 20px;
}

.sph-fe-groups-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Group card */
.sph-fe-group-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    background: #fff;
}

.sph-fe-group-card-header {
    margin-bottom: 12px;
}

.sph-fe-group-title {
    margin: 0 0 8px 0;
    font-size: var(--title-size, 20px);
    font-weight: 700;
    color: var(--accent, #065f03);
}

.sph-fe-group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Badges */
.sph-fe-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1.6;
}

.sph-fe-badge-level {
    background: #e0e0e0;
    color: #333;
}

.sph-fe-badge-role {
    background: #e0f2fe;
    color: #075985;
}

.sph-fe-badge-source {
    font-size: 0.7em;
    font-weight: normal;
    font-style: italic;
    color: #999;
}

.sph-fe-badge-custom {
    color: #dba617;
}

/* Stats row */
.sph-fe-group-card-stats {
    display: flex;
    gap: 24px;
    padding: 12px 0;
    border-top: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 12px;
}

.sph-fe-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sph-fe-stat-number {
    font-size: 1.4em;
    font-weight: 700;
    line-height: 1.2;
}

.sph-fe-stat-label {
    font-size: 0.8em;
    color: #666;
}

/* Courses list within card */
.sph-fe-group-courses {
    margin-bottom: 12px;
}

.sph-fe-group-courses h4 {
    margin: 0 0 6px 0;
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sph-fe-course-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sph-fe-course-list li {
    padding: 4px 0;
    font-size: 0.95em;
}

.sph-fe-course-list li a {
    text-decoration: underline;
}

/* Action buttons */
.sph-fe-group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.sph-fe-btn {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.9em;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    line-height: 1.4;
    transition: background 0.15s, border-color 0.15s;
}

.sph-fe-btn-primary {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.sph-fe-btn-primary:hover {
    background: #135e96;
    color: #fff;
}

.sph-fe-btn-secondary {
    background: #f0f0f0;
    color: #333;
    border-color: #c3c4c7;
}

.sph-fe-btn-secondary:hover {
    background: #e0e0e0;
    color: #333;
}

/* Breadcrumb */
.sph-fe-breadcrumb {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 4px;
}

.sph-fe-breadcrumb-sep {
    margin: 0 4px;
    color: #999;
}

.sph-fe-breadcrumb-current {
    font-weight: 600;
    color: #333;
}

/* Responsive */
@media screen and (max-width: 600px) {
    .sph-fe-group-card-stats {
        gap: 16px;
    }

    .sph-fe-group-actions {
        flex-direction: column;
    }

    .sph-fe-btn {
        text-align: center;
    }
}

/* SchoolPRO access products — seat selector helper */
.sph-seats-help {
    margin: 0 0 10px;
    padding: 8px 12px;
    background: #eff6ff;
    border-left: 3px solid #2563eb;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
}
.sph-cart-seats { color: #2563eb; font-weight: 600; }

/* SchoolPRO access products — Individual / Group selector */
.sph-purchase-choice {
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid #dbe2ea;
    border-radius: 6px;
    background: #f8fafc;
}
.sph-choice-label { margin: 0 0 8px; }
.sph-choice-opt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 18px;
    cursor: pointer;
}
.sph-seats-field { margin-top: 12px; }
.sph-seats-field label { display: block; font-weight: 600; margin-bottom: 4px; }
.sph-seats-input { width: 110px; padding: 6px 8px; }
.sph-seats-note { margin: 4px 0 0; color: var(--ink-3, #7b8794); font-size: 13px; }
.sph-price-preview { margin: 12px 0 0; font-size: 16px; }
.sph-price-preview strong { font-size: 20px; color: #1d2327; }

/* Manage Users — the whole "search existing / add new" block and the roster
   (search + table) are two separate top-level cards (.sph-dash-card), so no
   extra box is needed around "add new" specifically any more — plain
   spacing inside its own card is enough. */
.sph-dash-add-people { margin: 14px 0 0; }
.sph-dash-add-person-label { display: block; font-weight: 600; margin-bottom: 6px; }

/* Manage Users — the two top-level containers themselves. */
.sph-dash-add-members-card,
.sph-dash-roster-card {
    border: 1px solid var(--line, #e4e7ec);
    border-radius: var(--r-card, 12px);
    background: var(--surface-2, #fafbfc);
    padding: 16px 18px;
    margin-bottom: 16px;
}
.sph-dash-add-members-card:last-child { margin-bottom: 0; }
.sph-dash-add-members-title { margin: 0 0 6px; font-size: var(--title-size, 20px); font-weight: 700; color: var(--accent, #065f03); }
.sph-dash-add-members-disclaimer { margin: 0 0 14px; color: var(--ink-3, #7b8794); font-size: 13px; line-height: 1.4; }
.sph-dash-add-members-refresh-hint { margin: 14px 0 0; color: var(--ink-3, #7b8794); font-size: 13px; font-style: italic; }
.sph-dash-add-person-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.sph-dash-add-person-row input { flex: 1 1 160px; min-width: 120px; }
.sph-dash-add-person-remove { border: 0; background: transparent; color: #d63638; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 6px; }
.sph-dash-add-people-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* Reports — lazy hierarchy tree */
.sph-report-tree { margin-top: 8px; }
.sph-report-node {
    border: 1px solid #e2e8f0;
    border-left: 4px solid rgb(var(--tier-rgb, 123 135 148));
    border-radius: 6px;
    margin: 6px 0;
    background: #fff;
}
.sph-report-course { border-left-color: #cbd5e1; }
.sph-report-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; user-select: none; }
.sph-report-head:hover { background: #f8fafc; }
.sph-report-toggle { display: inline-flex; width: 18px; justify-content: center; font-weight: 700; color: var(--ink-3, #7b8794); }
.sph-report-name { font-weight: 600; }
.sph-report-course .sph-report-name { font-weight: 500; }
.sph-report-count { margin-left: auto; color: var(--ink-3, #7b8794); font-size: 13px; }
.sph-report-level {
    margin-left: 4px;
    background: rgb(var(--tier-rgb, 123 135 148) / .12);
    color: rgb(var(--tier-rgb, 123 135 148));
    border: 1px solid rgb(var(--tier-rgb, 123 135 148) / .22);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: 10px;
    text-transform: uppercase;
}
.sph-report-children { padding: 0 10px 8px 30px; border-left: 1px dashed #e2e8f0; margin-left: 16px; }

/* Separate "Classes" / "Schools" containers within a node's children. */
.sph-report-subgroup { margin: 10px 0; }
.sph-report-subgroup-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-3, #7b8794);
    margin: 0 0 4px;
}
.sph-report-member { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; border-top: 1px solid #f1f5f9; }
.sph-report-member-name small { color: var(--ink-3, #7b8794); }
.sph-report-member-prog { color: #334155; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.sph-report-member-prog.is-complete { color: #166534; } /* dark green — accessible contrast, not bright */
.sph-report-member-prog.is-incomplete { color: #991b1b; } /* dark red — accessible contrast, not bright */
.sph-report-empty { padding: 8px 10px; color: var(--ink-3, #7b8794); font-style: italic; }
.sph-report-loadmore { margin: 8px 0 4px; }
.sph-report-export { margin-left: auto; }

/* Notifications broadcast */
.sph-notify-form { display: flex; flex-direction: column; gap: 12px; max-width: 720px; }
.sph-notify-field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.sph-notify-subject, .sph-notify-body { width: 100%; }
.sph-notify-tokens { display: block; margin-top: 4px; color: var(--ink-3, #7b8794); font-weight: normal; font-size: 13px; }
.sph-notify-tokens-label { display: block; font-weight: 600; margin-bottom: 2px; }
.sph-notify-key-list { list-style: none; margin: 0; padding: 0; }
.sph-notify-key-list li { padding: 1px 0; }
.sph-notify-key-list code { background: #eef2f7; border-radius: 3px; padding: 1px 4px; }
.sph-notify-form fieldset { border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 12px; }
.sph-notify-form legend { font-weight: 600; padding: 0 6px; }
.sph-notify-preview-row { display: flex; }
.sph-notify-preview { border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px 12px; background: #f8fafc; }
.sph-notify-preview h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3, #7b8794); }
.sph-notify-preview-subject { margin-bottom: 8px; }
.sph-notify-preview-body { background: #fff; border: 1px solid #e2e8f0; border-radius: 4px; padding: 10px 12px; }
.sph-notify-groups { margin-top: 8px; max-height: 220px; overflow-y: auto; border-top: 1px solid #f1f5f9; padding-top: 8px; }
.sph-notify-group { display: block; padding: 3px 0; }
.sph-notify-replyme-row { display: flex; align-items: center; gap: 6px; }
.sph-notify-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sph-notify-status { font-size: 13px; }
.sph-notify-progress { margin-top: 6px; }
.sph-notify-bar { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.sph-notify-bar span { display: block; height: 100%; width: 0; background: var(--accent, #4f46e5); transition: width .3s; }
.sph-notify-prog-text { display: block; margin-top: 4px; font-size: 13px; color: var(--ink-3, #7b8794); }
.sph-notify-log-head { margin-top: 20px; }
.sph-notify-log-table { width: 100%; border-collapse: collapse; }
.sph-notify-log-table th, .sph-notify-log-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: top; }
.sph-notify-badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.sph-notify-badge--done { background: #dcfce7; color: #166534; }
.sph-notify-badge--sending { background: #dbeafe; color: #1e40af; }
.sph-notify-badge--queued { background: #f1f5f9; color: #475569; }

/* ---------- Cascade (trust-/school-wide) progress reset ---------- */
.sph-dash-reset-scope { border-bottom: 1px solid #f1f5f9; padding-bottom: 10px; margin-bottom: 12px; }
.sph-dash-reset-cascade-preview { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; color: var(--ink-2, #475569); }
.sph-dash-reset-bulk-progress { margin-top: 10px; }
.sph-dash-progress-track { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.sph-dash-progress-bar { display: block; height: 100%; width: 0; background: #dc2626; transition: width .3s; }
.sph-dash-reset-bulk-progress-label { margin-top: 4px; font-size: 13px; color: var(--ink-3, #7b8794); }

/* ---------- Add Users (CSV wizard) ---------- */
.sph-wizard-help { margin: 0 0 10px 18px; color: var(--ink-2, #475569); font-size: 13px; }
.sph-wizard-help li { margin-bottom: 4px; }
.sph-wizard-upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.sph-wizard-table-wrap { overflow-x: auto; margin-top: 8px; }
.sph-wizard-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sph-wizard-table th, .sph-wizard-table td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; text-align: left; white-space: nowrap; }
.sph-wizard-table thead th { position: sticky; top: 0; background: #f8fafc; border-bottom: 2px solid #e2e8f0; z-index: 2; }
.sph-wizard-pick-col { text-align: center; }
/* Freeze the Name (first) column so it stays put during horizontal scroll. */
.sph-wizard-table th:first-child,
.sph-wizard-table td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
    box-shadow: 1px 0 0 #e2e8f0;
}
.sph-wizard-table thead th:first-child { background: #f8fafc; z-index: 3; }

/* Class-selection modal (one-by-one member add). */
.sph-dash-class-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 16px;
}
.sph-dash-class-modal-box {
    background: #fff;
    border-radius: 10px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow: auto;
    padding: 20px 22px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}
.sph-dash-class-modal-box h3 { margin: 0 0 6px; font-size: var(--title-size, 20px); font-weight: 700; color: var(--accent, #065f03); }
.sph-dash-class-modal-people { margin: 0 0 12px; font-size: 13px; }
.sph-dash-class-modal-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.sph-dash-class-option {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
}
.sph-dash-class-option:hover { background: #f8fafc; }
.sph-dash-class-option-name { font-weight: 600; }
.sph-dash-class-option-courses { color: var(--ink-3, #7b8794); font-size: 13px; }
.sph-dash-class-modal-actions { display: flex; gap: 8px; }

/* Members/Leaders roster: search + pagination. */
.sph-dash-roster-tools { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; flex-wrap: wrap; }
.sph-dash-roster-search { flex: 1 1 220px; max-width: 480px; padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 6px; }
.sph-dash-roster-count { color: var(--ink-3, #7b8794); font-size: 13px; white-space: nowrap; }
.sph-dash-roster-body { transition: opacity 0.15s ease; }
.sph-dash-roster-pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.sph-roster-pageinfo { color: var(--ink-3, #7b8794); font-size: 13px; }

/* List / Grid view toggle — a clear segmented control. */
.sph-view-toggle { display: inline-flex; margin: 2px 0 12px; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; }
.sph-view-btn { border: 0; background: #fff; color: #475569; padding: 6px 16px; font-size: 13px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.sph-view-btn + .sph-view-btn { border-left: 1px solid #cbd5e1; }
.sph-view-btn.is-active { background: var(--accent, #065f03); color: #fff; }
.sph-view-btn:not(.is-active):hover { background: #f1f5f9; }

/* Enrolment matrix (users × classes) — compact, to fit more on screen. */
.sph-matrix-toolbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; flex-wrap: wrap; }
.sph-matrix-row-all { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sph-matrix-status { color: #475569; font-size: 12px; }
.sph-matrix-save { background: #16a34a; border-color: #16a34a; color: #fff; font-weight: 600; }
.sph-matrix-save:hover { background: #15803d; border-color: #15803d; }
.sph-matrix-wrap { overflow: auto; border: 1px solid #e2e8f0; border-radius: 6px; max-height: 72vh; }
.sph-matrix-table { border-collapse: collapse; font-size: 12px; }
.sph-matrix-table th, .sph-matrix-table td { border-bottom: 1px solid #f1f5f9; padding: 3px 7px; text-align: center; white-space: nowrap; }
.sph-matrix-table th.sph-matrix-classhead { vertical-align: bottom; font-weight: 600; font-size: 12px; width: 130px; max-width: 130px; white-space: normal; word-break: break-word; }
.sph-matrix-course { display: block; color: #64748b; font-size: 10px; font-weight: normal; width: 116px; white-space: normal; word-break: break-word; line-height: 1.2; }
.sph-matrix-user { text-align: left; }
.sph-matrix-user-name { display: block; font-weight: 600; font-size: 12px; line-height: 1.25; }
.sph-matrix-user-email { display: block; color: #64748b; font-size: 10px; line-height: 1.2; }
.sph-matrix-cb { width: 15px; height: 15px; margin: 0; cursor: pointer; }
/* Freeze the user (first) column and the header row. */
.sph-matrix-table th.sph-matrix-userhead,
.sph-matrix-table td.sph-matrix-user { position: sticky; left: 0; background: #fff; z-index: 1; box-shadow: 1px 0 0 #e2e8f0; }
.sph-matrix-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 2; }
.sph-matrix-table thead th.sph-matrix-userhead { z-index: 3; }

/* Email composer: schedule row. */
.sph-notify-schedule-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; }
.sph-notify-schedule-label { display: flex; align-items: center; gap: 8px; color: var(--ink-2, #475569); font-size: 13px; }
.sph-notify-schedule-at { padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; }
.sph-wizard-col-hint { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3, #7b8794); margin-top: 2px; }
.sph-wizard-row.is-invalid { color: #94a3b8; background: #fef2f2; }
.sph-wizard-tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #e0f2fe; color: #075985; }
.sph-wizard-tag--bad { background: #fee2e2; color: #991b1b; }
.sph-wizard-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.sph-dash-btn-link { background: none; border: none; color: var(--accent, #4f46e5); cursor: pointer; padding: 0; font-size: 14px; }
.sph-wizard-skip { margin: 4px 0 0 18px; color: #991b1b; font-size: 13px; }
.sph-wizard-seat-notice {
    margin-top: 12px;
    padding: 10px 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    color: #92400e;
    font-size: 13px;
}
.sph-wizard-seat-notice a { color: inherit; font-weight: 600; }
