/**
 * Student panel – page-specific (headers, charts, banners, stat cards).
 * Load after app-ui-shell.css + app-panel-common.css (shared shell).
 */

/* ----- Page header (alias roles-mgmt-header for legacy student pages) ----- */
.student-page-header,
.roles-mgmt-header {
    margin-bottom: clamp(1rem, 1.8vw, 1.5rem);
}
.student-page-header h1,
.roles-mgmt-header h1 {
    font-size: clamp(1.2rem, 2vw, 1.625rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.25;
    color: var(--ee-ink, #111827);
}
.dark .student-page-header h1,
.dark .roles-mgmt-header h1 {
    color: var(--ee-ink, #f9fafb);
}
.student-page-header p,
.roles-mgmt-header p {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--ee-ink-muted, #6b7280);
}
.dark .student-page-header p,
.dark .roles-mgmt-header p {
    color: var(--ee-ink-muted, #9ca3af);
}

/* ----- Accent strip (Materio purple — admin + student) ----- */
.student-accent-border {
    border-bottom: var(--student-accent-border, 2px solid rgb(115 103 240 / 0.35));
}

.student-quick-stat-box {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.student-quick-stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(115, 103, 240, 0.12);
}
.dark .student-quick-stat-box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ----- Charts ----- */
.student-charts-wrap .student-panel-card {
    border-radius: var(--student-card-radius);
}
.student-charts-wrap > .student-panel-card .ee-panel-chart-stage,
.student-charts-wrap > .student-panel-card .student-chart-container,
.student-charts-wrap .ee-panel-chart-stage,
.student-charts-wrap .student-chart-container {
    min-height: 280px;
    height: clamp(16.5rem, 36vh, 22rem);
}

.student-charts-wrap .student-doughnut-wrap.ee-panel-chart-stage {
    min-height: 280px;
    height: clamp(16.5rem, 36vh, 22rem);
    display: block;
}
.student-chart-container canvas {
    display: block;
}

.student-doughnut-wrap #student-doughnut-center,
.student-doughnut-wrap .ee-panel-doughnut-center,
.ee-panel-doughnut-center {
    pointer-events: none;
    z-index: 2;
    text-align: center;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
}

/* HTML center labels are screen-reader only; Chart.js draws visible center text */
.ee-panel-doughnut-center--sr,
.ee-panel-doughnut-center.ee-panel-doughnut-center--sr {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
}

.student-doughnut-wrap #student-doughnut-center > div {
    margin-top: 0;
}

.student-doughnut-wrap .chartjs-tooltip,
.student-charts-wrap .chartjs-tooltip,
.student-content .chartjs-tooltip,
#chartjs-tooltip,
.chartjs-tooltip {
    z-index: 9999 !important;
    pointer-events: none;
}
.student-chart-container {
    padding: 0.75rem 1rem;
    min-height: 200px;
    overflow: visible;
    position: relative;
    z-index: 1;
}
.student-chart-container:hover {
    z-index: 9999;
}

.student-chart-html-tooltip {
    z-index: 9999 !important;
    padding: 10px 14px !important;
    border-radius: var(--ee-radius, 5px);
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 220px;
}

/* ----- Stat / metric cards (admin + student — Materio borders) ----- */
:is(#admin-body, #student-body) .student-stat-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--admin-border, rgba(47, 43, 61, 0.08)) !important;
    border-bottom: 1px solid var(--admin-border, rgba(47, 43, 61, 0.08)) !important;
    background: var(--materio-surface, #fff);
    box-shadow:
        0 1px 2px rgba(47, 43, 61, 0.04),
        0 6px 16px rgba(47, 43, 61, 0.05);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

html.dark :is(#admin-body, #student-body) .student-stat-card {
    border-color: var(--admin-border-strong, rgba(255, 255, 255, 0.12)) !important;
    border-bottom-color: var(--admin-border-strong, rgba(255, 255, 255, 0.12)) !important;
    background: var(--materio-surface, #2f3349);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.2),
        0 8px 20px rgba(0, 0, 0, 0.18);
}

:is(#admin-body, #student-body) .student-stat-card > div {
    position: relative;
    z-index: 1;
}

.student-stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
}

:is(#admin-body, #student-body) .student-content .student-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 18px rgba(115, 103, 240, 0.12);
}

html.dark :is(#admin-body, #student-body) .student-content .student-stat-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.student-stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--ee-radius, 5px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.125rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

/* ----- Panel chart stage (admin + student doughnuts) ----- */
.ee-panel-chart-stage {
    position: relative;
    width: 100%;
    min-height: 16rem;
    height: clamp(16rem, 32vh, 18rem);
}

.ee-panel-chart-stage canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-height: clamp(14rem, 30vh, 17rem);
}

.ee-panel-doughnut-center span:first-child {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ee-ink, #111827);
}

html.dark .ee-panel-doughnut-center span:first-child {
    color: var(--ee-ink, #f9fafb);
}

.ee-panel-doughnut-center span:last-child {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ee-ink-muted, #6b7280);
}

/* ----- Stat card typography (match admin Materio) ----- */
:is(#admin-body, #student-body) .student-stat-card .ee-stat-label,
:is(#admin-body, #student-body) .student-stat-card > div > div:last-child p:first-child {
    font-size: 0.6875rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.06em;
    line-height: 1.3;
    text-transform: uppercase;
    color: var(--ee-ink-muted, #6b7280) !important;
}

:is(#admin-body, #student-body) .student-stat-card .ee-stat-value,
:is(#admin-body, #student-body) .student-stat-card > div > div:last-child p:nth-child(2) {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--ee-ink, #111827) !important;
}

html.dark :is(#admin-body, #student-body) .student-stat-card .ee-stat-value,
html.dark :is(#admin-body, #student-body) .student-stat-card > div > div:last-child p:nth-child(2) {
    color: var(--ee-ink, #f9fafb) !important;
}

:is(#admin-body, #student-body) .student-stat-card .ee-stat-hint,
:is(#admin-body, #student-body) .student-stat-card > div > div:last-child p:nth-child(3) {
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    line-height: 1.35;
    margin-top: 0.125rem;
}

:is(#admin-body, #student-body) .ee-panel-card__header h3,
:is(#admin-body, #student-body) .ee-panel-card__title {
    font-size: 0.9375rem !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
}

:is(#admin-body, #student-body) .ee-panel-card__header p {
    font-size: 0.8125rem !important;
    line-height: 1.4;
    color: var(--ee-ink-muted, #6b7280) !important;
}

/* Header / stat icons stay square — left accent is a 2px border, not a stretched color column */
:is(#admin-body, #student-body) .ee-panel-card__header-row,
:is(#admin-body, #student-body) .student-stat-card > div {
    align-items: center !important;
}

:is(#admin-body, #student-body) .ee-panel-header-icon,
:is(#admin-body, #student-body) .ee-panel-card__icon,
:is(#admin-body, #student-body) .student-stat-icon {
    width: 2.5rem !important;
    height: 2.5rem !important;
    min-width: 2.5rem;
    min-height: 2.5rem;
    aspect-ratio: 1;
    align-self: center;
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: var(--ee-radius, 5px);
    container-type: size;
}

:is(#admin-body, #student-body) .ee-panel-header-icon i,
:is(#admin-body, #student-body) .ee-panel-card__icon i,
:is(#admin-body, #student-body) .student-stat-icon i {
    font-size: clamp(0.75rem, 42cqmin, 1.125rem);
    line-height: 1;
}

:is(#admin-body, #student-body) .ee-panel-header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

:is(#admin-body, #student-body) .student-stat-card > div > div:last-child {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.student-stat-card > div > div:last-child p:first-child {
    letter-spacing: 0.06em;
    font-size: 0.6875rem;
}

.student-stat-card > div > div:last-child p:nth-child(2) {
    letter-spacing: -0.02em;
    line-height: 1.2;
    font-size: 1.5rem;
}

.student-stat-card > div > div:last-child p:nth-child(3) {
    font-size: 0.8125rem;
}

.student-stat-card-1 {
    border-left-color: #7367f0 !important;
    background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 55%, #ffffff 100%);
}
.student-stat-card-1::after {
    background: radial-gradient(circle at 100% 0%, rgba(115, 103, 240, 0.08), transparent 55%);
}
.student-stat-card-1:hover::after { opacity: 1; }

.student-stat-card-2 {
    border-left-color: #f59e0b !important;
    background: linear-gradient(135deg, #ffffff 0%, #fffbeb 55%, #ffffff 100%);
}
.student-stat-card-2::after {
    background: radial-gradient(circle at 100% 0%, rgba(245, 158, 11, 0.1), transparent 55%);
}
.student-stat-card-2:hover::after { opacity: 1; }

.student-stat-card-3 {
    border-left-color: #10b981 !important;
    background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 55%, #ffffff 100%);
}
.student-stat-card-3::after {
    background: radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.1), transparent 55%);
}
.student-stat-card-3:hover::after { opacity: 1; }

.student-stat-card-4 {
    border-left-color: #8b5cf6 !important;
    background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 55%, #ffffff 100%);
}
.student-stat-card-4::after {
    background: radial-gradient(circle at 100% 0%, rgba(139, 92, 246, 0.1), transparent 55%);
}
.student-stat-card-4:hover::after { opacity: 1; }

html.dark :is(#admin-body, #student-body) .student-stat-card-1 {
    background: linear-gradient(135deg, var(--materio-surface, #2f3349) 0%, rgba(115, 103, 240, 0.12) 100%);
}
html.dark :is(#admin-body, #student-body) .student-stat-card-2 {
    background: linear-gradient(135deg, var(--materio-surface, #2f3349) 0%, rgba(245, 158, 11, 0.1) 100%);
}
html.dark :is(#admin-body, #student-body) .student-stat-card-3 {
    background: linear-gradient(135deg, var(--materio-surface, #2f3349) 0%, rgba(16, 185, 129, 0.1) 100%);
}
html.dark :is(#admin-body, #student-body) .student-stat-card-4 {
    background: linear-gradient(135deg, var(--materio-surface, #2f3349) 0%, rgba(139, 92, 246, 0.12) 100%);
}

/* ----- Buttons ----- */
.student-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    background-color: var(--student-primary);
    border-radius: var(--student-btn-radius);
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.student-btn-primary:hover {
    background-color: var(--student-primary-dark);
    box-shadow: 0 4px 14px 0 rgb(115 103 240 / 0.4);
}
.student-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--tw-gray-700, #374151);
    background-color: #fff;
    border: 1px solid var(--tw-gray-300, #d1d5db);
    border-radius: var(--student-btn-radius);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.student-btn-secondary:hover {
    background-color: var(--tw-gray-50, #f9fafb);
    border-color: var(--tw-gray-400, #9ca3af);
}
.dark .student-btn-secondary {
    color: #e5e7eb;
    background-color: var(--tw-gray-800, #1f2937);
    border-color: var(--tw-gray-600, #4b5563);
}
.dark .student-btn-secondary:hover {
    background-color: var(--tw-gray-700, #374151);
}

.student-panel-card {
    border-radius: var(--ee-radius, 5px);
}

.student-charts-wrap canvas {
    max-height: 100%;
}
.student-results-circle-wrap {
    filter: drop-shadow(0 4px 14px rgba(115, 103, 240, 0.2));
}
.dark .student-results-circle-wrap {
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.4));
}

/* Panel chart range tabs (admin + student dashboards) */
.ee-panel-chart-tab.active {
    background-color: var(--student-primary);
    color: #fff;
    border-color: var(--student-primary);
}
.dark .ee-panel-chart-tab.active {
    background-color: var(--student-primary);
    color: #fff;
    border-color: var(--student-primary);
}

@media (prefers-reduced-motion: reduce) {
    .student-content .student-stat-card:hover {
        transform: none;
    }
}

@media (max-width: 639px) {
    .student-charts-wrap .student-chart-container,
    .student-charts-wrap .student-doughnut-wrap {
        min-height: 220px;
        height: clamp(13.5rem, 48vh, 19rem);
    }
}
