/* ============================================================
   HELP Campus Gradebook — Mobile-First Stylesheet
   ============================================================ */

/* ── Reset / Base ─────────────────────────────────────────── */
.hgb-wrapper *,
.hgb-wrapper *::before,
.hgb-wrapper *::after {
    box-sizing: border-box;
}

.hgb-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: #1a1a2e;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 0 40px;
}

.hgb-notice,
.hgb-empty {
    padding: 16px;
    background: #f0f4ff;
    border-radius: 8px;
    color: #555;
    font-size: 14px;
    text-align: center;
}

/* ── Course Block ─────────────────────────────────────────── */
.hgb-course {
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
    background: #fff;
}

.hgb-course-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #16213e;
    color: #fff;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
}

.hgb-course-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    flex: 1;
    padding-right: 12px;
}

/* ── Lesson Block ─────────────────────────────────────────── */
.hgb-lesson {
    border-bottom: 1px solid #eef0f5;
}

.hgb-lesson:last-child {
    border-bottom: none;
}

.hgb-lesson-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f3460;
    color: #e2e8f0;
    padding: 13px 20px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.hgb-lesson-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    padding-right: 12px;
}

/* ── Topic Block ──────────────────────────────────────────── */
.hgb-topic {
    background: #f8faff;
    border-left: 3px solid #e94560;
    margin: 0 0 2px 0;
}

.hgb-topic-header {
    padding: 10px 16px 6px;
}

.hgb-topic-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #e94560;
}

/* ── Quiz Summary Row ─────────────────────────────────────── */
.hgb-quiz-block {
    border-bottom: 1px solid #f0f2f8;
}

.hgb-quiz-block:last-child {
    border-bottom: none;
}

.hgb-quiz-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fff;
    gap: 8px;
    min-height: 56px;
}

.hgb-quiz-summary.hgb-expandable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hgb-quiz-summary.hgb-expandable:active {
    background: #f5f7ff;
}

.hgb-quiz-name {
    flex: 1;
    min-width: 0;
}

.hgb-quiz-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a2e;
    line-height: 1.4;
    word-break: break-word;
}

.hgb-attempt-badge {
    display: inline-block;
    margin-top: 4px;
    font-size: 11px;
    color: #6b7280;
    background: #f0f2f8;
    border-radius: 20px;
    padding: 2px 8px;
}

.hgb-quiz-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hgb-best-score {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    min-width: 46px;
    text-align: right;
}

/* Status badges */
.hgb-status-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    border-radius: 20px;
    padding: 3px 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.hgb-status-pass    { background: #d1fae5; color: #065f46; }
.hgb-status-fail    { background: #fee2e2; color: #991b1b; }
.hgb-status-incomplete { background: #f3f4f6; color: #6b7280; }

.hgb-chevron {
    font-size: 20px;
    color: #9ca3af;
    transition: transform 0.25s ease;
    line-height: 1;
    display: inline-block;
}

.hgb-quiz-summary.hgb-open .hgb-chevron {
    transform: rotate(90deg);
}

/* ── Attempts Detail Table ────────────────────────────────── */
.hgb-attempts-detail {
    display: none;
    padding: 0 0 8px;
    background: #f8faff;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.hgb-attempts-detail.hgb-open {
    display: block;
}

.hgb-attempts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.hgb-attempts-table thead th {
    background: #e8ecf8;
    color: #374151;
    font-weight: 700;
    padding: 9px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid #d1d5db;
}

.hgb-attempts-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.hgb-attempts-table tbody tr:last-child td {
    border-bottom: none;
}

.hgb-row-pass { background: #f0fdf4; }
.hgb-row-fail { background: #fff5f5; }

/* Score pill */
.hgb-score-pill {
    display: inline-block;
    font-weight: 700;
    font-size: 13px;
    border-radius: 6px;
    padding: 2px 8px;
}

.hgb-pill-pass { background: #d1fae5; color: #065f46; }
.hgb-pill-fail { background: #fee2e2; color: #991b1b; }

.hgb-pass-text { color: #059669; font-weight: 600; }
.hgb-fail-text { color: #dc2626; font-weight: 600; }

/* Toggle icons */
.hgb-toggle-icon {
    font-size: 14px;
    opacity: 0.7;
    transition: transform 0.25s ease;
    display: inline-block;
    flex-shrink: 0;
}

.hgb-course-header.hgb-open .hgb-toggle-icon,
.hgb-lesson-header.hgb-open .hgb-toggle-icon {
    transform: rotate(180deg);
}

/* ── Mobile: card-style table on small screens ────────────── */
@media (max-width: 600px) {
    .hgb-attempts-table thead {
        display: none;
    }

    .hgb-attempts-table tbody tr {
        display: block;
        margin: 8px 12px;
        border-radius: 8px;
        border: 1px solid #e5e7eb;
        overflow: hidden;
    }

    .hgb-attempts-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 14px;
        border-bottom: 1px solid #f0f2f8;
        font-size: 13px;
    }

    .hgb-attempts-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #6b7280;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        margin-right: 8px;
    }

    .hgb-attempts-table tbody td:last-child {
        border-bottom: none;
    }

    .hgb-quiz-title {
        font-size: 13px;
    }

    .hgb-best-score {
        font-size: 15px;
    }
}

@media (max-width: 400px) {
    .hgb-course-header {
        padding: 14px 14px;
    }
    .hgb-course-title {
        font-size: 15px;
    }
    .hgb-lesson-header {
        padding: 12px 14px;
    }
}


/* ── Hidden / Collapsed state ────────────────────────────────────────────── */
.hgb-hidden { display: none !important; }
.hgb-course-header, .hgb-lesson-header { cursor: pointer; user-select: none; }
.hgb-course-header .hgb-toggle-icon,
.hgb-lesson-header .hgb-toggle-icon { transition: transform 0.2s ease; display: inline-block; }
.hgb-course-header.hgb-collapsed .hgb-toggle-icon,
.hgb-lesson-header.hgb-collapsed .hgb-toggle-icon { transform: rotate(-90deg); }

/* ── Overall Grade Bar (two columns) ─────────────────────────────────────── */
.hgb-overall-grade-bar {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.hgb-grade-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 120px;
    padding: 4px 8px;
}
.hgb-grade-divider {
    width: 1px;
    height: 52px;
    background: #e0e0e0;
    flex-shrink: 0;
    margin: 0 8px;
}
.hgb-grade-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    margin-bottom: 4px;
}
.hgb-grade-value {
    font-size: 26px;
    font-weight: 800;
    border-radius: 6px;
    padding: 2px 14px;
    margin-bottom: 4px;
    line-height: 1.2;
}
.hgb-grade-pass { color: #166534; background: #dcfce7; }
.hgb-grade-fail { color: #991b1b; background: #fee2e2; }
.hgb-grade-none { color: #9ca3af; background: #f3f4f6; }
.hgb-grade-meta { font-size: 11px; color: #9ca3af; }

@media (max-width: 480px) {
    .hgb-overall-grade-bar { padding: 12px 14px; }
    .hgb-grade-value { font-size: 22px; }
    .hgb-grade-divider { height: 44px; }
}

/* ── Gradebook section title ─────────────────────────────────────────────── */
.hgb-gradebook-header {
    padding: 10px 0 6px 2px;
}
.hgb-gradebook-title {
    font-size: 18px;
    font-weight: 800;
    color: #1d2327;
    letter-spacing: -0.01em;
}
