﻿/* ==========================================================================
   Teacher statistics (#stats-teachers)
   --------------------------------------------------------------------------
   Сторінка зібрана з наявних компонентів системи, щоб виглядати так само, як
   решта застосунку:
     .data-table, .teachers-toolbar, .teachers-search, .tbtn, .tselect,
     .teachers-table-wrap, .teachers-table-scroll, .teachers-footer,
     .mini-badge, .mini-dot — нативні компоненти «Список вчителів»;
     .stats-title / .stats-value / .stats-subvalue — типографіка карток
       показників.
   Каркаси карток мають власні класи .ts-kpi / .ts-insight / .ts-shell /
   .ts-card: глобальне правило системи задає .stats-card/.teachers-card/
   .teachers-table-shell фіксовану висоту на весь екран, що для сторінки
   статистики не підходить.
   ========================================================================== */

/* --- KPI cards ---------------------------------------------------------- */
#stats-teachers .ts-kpis {
    margin-top: 0;
    margin-bottom: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

#stats-teachers .ts-kpi {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#stats-teachers .ts-kpi .stats-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
}

#stats-teachers .ts-kpi .stats-value {
    font-size: 28px;
    line-height: 1.15;
}

#stats-teachers .ts-kpi .stats-subvalue {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 700;
}

/* --- Table card: same frame as «Список вчителів» ------------------------ */
#stats-teachers .ts-shell {
    width: 100%;
    margin: 0 0 16px;
    box-sizing: border-box;
}

#stats-teachers .ts-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
}

#stats-teachers .teachers-card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px 16px;
}

#stats-teachers .ts-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

#stats-teachers .ts-head-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
}

#stats-teachers .ts-head-meta i {
    margin-right: 4px;
}

#stats-teachers .teachers-search {
    min-width: 240px;
}

#stats-teachers .teachers-search input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
}

#stats-teachers .teachers-search input::placeholder {
    color: rgba(255, 255, 255, 0.75);
}

#stats-teachers .ts-source-btn {
    cursor: default;
}

/* --- Table -------------------------------------------------------------- */
#stats-teachers .teachers-table-wrap {
    flex: 0 1 auto;
}

#stats-teachers .teachers-table-scroll {
    max-height: 62vh;
}

#stats-teachers .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

#stats-teachers .data-table th[data-ts-sort] {
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

#stats-teachers .data-table th[data-ts-sort]:hover {
    color: var(--primary-blue);
}

#stats-teachers .data-table td {
    white-space: nowrap;
}

#stats-teachers .ts-sort-ind {
    margin-left: 4px;
    font-size: 9px;
    color: #cbd5e1;
}

#stats-teachers .ts-sort-ind--active {
    color: var(--primary-blue);
}

#stats-teachers .ts-hours {
    font-weight: 900;
}

#stats-teachers .ts-hours--good {
    color: #047857;
}

#stats-teachers .ts-hours--warn {
    color: #b45309;
}

#stats-teachers .ts-hours--bad {
    color: #b91c1c;
}

#stats-teachers .ts-hours--muted {
    color: #94a3b8;
}

#stats-teachers .ts-delta {
    font-weight: 900;
}

#stats-teachers .ts-delta--over {
    color: #b45309;
}

#stats-teachers .ts-delta--under {
    color: #2563eb;
}

#stats-teachers .ts-muted {
    color: #94a3b8;
}

#stats-teachers .ts-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#stats-teachers .ts-foot-note {
    color: #64748b;
    font-weight: 700;
}

/* --- Insight cards ------------------------------------------------------ */
#stats-teachers .ts-insights {
    margin-top: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

#stats-teachers .ts-insight {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#stats-teachers .ts-insight .stats-title {
    margin-bottom: 2px;
    font-size: 15px;
    color: #0f172a;
}

#stats-teachers .ts-insight .stats-subvalue {
    margin: 0 0 10px;
}

#stats-teachers .ts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#stats-teachers .ts-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    background: #fff;
}

#stats-teachers .ts-list-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

#stats-teachers .ts-list-title {
    font-size: 13px;
    font-weight: 800;
    color: #0f172a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#stats-teachers .ts-list-sub {
    font-size: 12px;
    color: #64748b;
}

#stats-teachers .ts-empty {
    padding: 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    font-size: 13px;
    text-align: center;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 1240px) {
    #stats-teachers .ts-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1000px) {
    #stats-teachers .ts-insights {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    #stats-teachers .ts-kpis {
        grid-template-columns: 1fr;
    }

    #stats-teachers .teachers-search {
        min-width: 160px;
    }
}


/* --- Clickable rows in teachers stats table --- */
#stats-teachers-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
#stats-teachers-table tbody tr:hover {
    background-color: #f1f5f9 !important;
}

/* ==========================================================================
   Teacher Workload Detail Page (#stats-teacher-workload)
   ========================================================================== */
#stats-teacher-workload {
    width: 100%;
    box-sizing: border-box;
}

#stats-teacher-workload .tw-shell {
    width: 100%;
    margin: 0 0 24px;
    box-sizing: border-box;
}

#stats-teacher-workload .tw-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

#stats-teacher-workload .tw-card-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px 20px;
    background: #0f68f8;
    color: #fff;
}

#stats-teacher-workload .tw-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

#stats-teacher-workload .tw-teacher-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

#stats-teacher-workload .tw-teacher-title h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.01em;
}

#stats-teacher-workload .tw-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#stats-teacher-workload .tw-table-scroll {
    overflow-x: auto;
    max-height: 65vh;
}

#stats-teacher-workload .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#stats-teacher-workload .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    text-align: left;
    padding: 12px 18px;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

#stats-teacher-workload .data-table tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}

#stats-teacher-workload .data-table tbody tr:hover {
    background-color: #f8fafc;
}

#stats-teacher-workload .tw-badge-group {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    margin-left: 6px;
}

#stats-teacher-workload .tw-source-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
}
#stats-teacher-workload .tw-source-tag--sched {
    background: #dcfce7;
    color: #15803d;
}
#stats-teacher-workload .tw-source-tag--curr {
    background: #e0f2fe;
    color: #0369a1;
}

#stats-teacher-workload .tw-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
}