/* =========================================================
   GLOBAL
========================================================= */

* {
    box-sizing: border-box;

    margin: 0;

    padding: 0;
}


html {
    font-family: "Inter", Arial, Helvetica, sans-serif;
}


body {
    font-family: "Inter", Arial, Helvetica, sans-serif;

    background: #f5f7fb;

    color: #172033;

    font-size: 14px;

    line-height: 1.5;
}


button,
select,
input {
    font-family: inherit;
}


/* =========================================================
   APP
========================================================= */

.app {
    display: flex;

    min-height: 100vh;
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: 240px;

    min-height: 100vh;

    background: #111827;

    color: white;

    padding: 28px 16px;

    position: fixed;

    left: 0;

    top: 0;

    bottom: 0;
}


.brand {
    padding: 0 12px 30px;
}


.brand h1 {
    font-size: 19px;

    font-weight: 700;

    letter-spacing: -0.3px;
}


.brand p {
    font-size: 12px;

    color: #aeb8ca;

    margin-top: 3px;
}


/* =========================================================
   MENU
========================================================= */

.menu {
    display: flex;

    flex-direction: column;

    gap: 6px;
}


.menu button {
    width: 100%;

    border: 0;

    background: transparent;

    color: #d7deea;

    text-align: left;

    padding: 12px 14px;

    border-radius: 8px;

    cursor: pointer;

    font-size: 13px;

    font-weight: 500;

    transition:
        background 0.15s ease,
        color 0.15s ease;
}


.menu button:hover {
    background: #1e293b;

    color: white;
}


.menu button.active {
    background: #2864e8;

    color: white;
}


/* =========================================================
   MAIN
========================================================= */

.main {
    margin-left: 240px;

    width: calc(100% - 240px);

    min-height: 100vh;

    padding: 28px;
}


.page {
    width: 100%;
}


/* =========================================================
   TOPBAR
========================================================= */

.topbar {
    display: flex;

    justify-content: space-between;

    align-items: flex-start;

    gap: 20px;

    margin-bottom: 22px;
}


.topbar h2 {
    font-size: 24px;

    font-weight: 700;

    letter-spacing: -0.5px;
}


.topbar p {
    color: #64748b;

    font-size: 12px;

    margin-top: 3px;
}


/* =========================================================
   SELECT
========================================================= */

.test-selector {
    min-width: 120px;

    background: white;

    border: 1px solid #dbe2ea;

    border-radius: 8px;

    padding: 10px 13px;

    color: #172033;

    font-size: 13px;

    outline: none;

    cursor: pointer;
}


.test-selector:focus {
    border-color: #2864e8;

    box-shadow:
        0 0 0 3px
        rgba(40, 100, 232, 0.12);
}


.full-width {
    width: 100%;
}


/* =========================================================
   CARD
========================================================= */

.card {
    background: white;

    border: 1px solid #e4e9f0;

    border-radius: 10px;

    padding: 20px;

    box-shadow:
        0 1px 2px
        rgba(15, 23, 42, 0.02);
}


.card-title {
    font-size: 14px;

    font-weight: 600;

    margin-bottom: 18px;

    color: #172033;
}


/* =========================================================
   KPI
========================================================= */

.kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 14px;

    margin-bottom: 18px;
}


.kpi-label {
    font-size: 12px;

    color: #64748b;

    margin-bottom: 5px;
}


.kpi-value {
    font-size: 28px;

    font-weight: 700;

    line-height: 1.15;

    color: #111827;
}


.kpi-change {
    margin-top: 7px;

    color: #16a34a;

    font-size: 11px;
}


/* =========================================================
   CONTENT GRID
========================================================= */

.content-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 2fr)
        minmax(300px, 1fr);

    gap: 18px;

    margin-bottom: 18px;
}


/* =========================================================
   CHART
========================================================= */

.chart {
    height: 280px;

    display: flex;

    align-items: flex-end;

    justify-content: space-around;

    gap: 14px;

    padding:
        25px
        10px
        5px;
}


.bar-wrapper {
    height: 100%;

    flex: 1;

    display: flex;

    flex-direction: column;

    justify-content: flex-end;

    align-items: center;

    min-width: 40px;
}


.bar {
    width: 52px;

    max-width: 80%;

    background: #2864e8;

    border-radius:
        6px
        6px
        0
        0;

    min-height: 5px;
}


.bar-value {
    font-size: 11px;

    font-weight: 600;

    margin-bottom: 6px;

    color: #172033;
}


.bar-label {
    margin-top: 8px;

    font-size: 10px;

    color: #64748b;

    white-space: nowrap;
}


/* =========================================================
   STUDENT LIST
========================================================= */

.student-list {
    display: flex;

    flex-direction: column;
}


.student {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 12px;

    padding: 13px 0;

    border-bottom:
        1px solid
        #edf1f5;
}


.student:first-child {
    padding-top: 0;
}


.student:last-child {
    border-bottom: 0;

    padding-bottom: 0;
}


.student-name {
    font-weight: 600;

    font-size: 13px;

    color: #111827;
}


.student-subtitle {
    font-size: 11px;

    color: #64748b;

    margin-top: 2px;
}


/* =========================================================
   STATUS
========================================================= */

.status {
    display: inline-flex;

    align-items: center;

    justify-content: center;

    padding:
        4px
        9px;

    border-radius: 999px;

    font-size: 9px;

    font-weight: 700;

    letter-spacing: 0.2px;

    white-space: nowrap;
}


.status.green {
    background: #dcfce7;

    color: #15803d;
}


.status.yellow {
    background: #fef3c7;

    color: #a16207;
}


.status.red {
    background: #fee2e2;

    color: #b91c1c;
}


/* =========================================================
   TABLE
========================================================= */

.table-wrapper {
    width: 100%;

    overflow-x: auto;
}


table {
    width: 100%;

    border-collapse: collapse;

    font-size: 12px;
}


thead {
    border-bottom:
        1px solid
        #e5e7eb;
}


th {
    text-align: left;

    padding:
        10px
        8px;

    color: #64748b;

    font-size: 10px;

    font-weight: 600;
}


td {
    padding:
        12px
        8px;

    border-bottom:
        1px solid
        #edf1f5;

    color: #334155;
}


tbody tr:hover {
    background: #f8fafc;
}


/* =========================================================
   ERROR
========================================================= */

.error {
    background: #fee2e2;

    border:
        1px solid
        #fecaca;

    color: #b91c1c;

    padding: 12px 14px;

    border-radius: 8px;

    margin-bottom: 18px;

    font-size: 12px;
}


/* =========================================================
   LOADING
========================================================= */

.loading {
    color: #94a3b8;

    font-size: 12px;

    padding: 15px 0;

    text-align: center;
}


.empty-state {
    padding: 30px;

    text-align: center;

    color: #94a3b8;
}


/* =========================================================
   TKA SUBJECT
========================================================= */

.subject-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 12px;
}


.subject-card {
    background: #f8fafc;

    border:
        1px solid
        #e2e8f0;

    border-radius: 9px;

    padding: 15px;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}


.subject-card:hover {
    transform: translateY(-2px);

    box-shadow:
        0 4px 12px
        rgba(15, 23, 42, 0.06);
}


.subject-name {
    font-size: 12px;

    color: #64748b;

    margin-bottom: 5px;
}


.subject-score {
    font-size: 22px;

    font-weight: 700;

    line-height: 1.2;
}


.subject-score.green {
    color: #15803d;
}


.subject-score.yellow {
    color: #a16207;
}


.subject-score.red {
    color: #b91c1c;
}


.subject-meta {
    font-size: 10px;

    color: #64748b;

    margin-top: 5px;
}


/* =========================================================
   STUDENT SELECTOR
========================================================= */

.student-selector-card {
    padding: 18px;
}


.selector-grid {
    display: grid;

    grid-template-columns:
        2fr
        1fr;

    gap: 16px;
}


.field-label {
    display: block;

    font-size: 11px;

    font-weight: 600;

    color: #475569;

    margin-bottom: 7px;
}


/* =========================================================
   STUDENT PROFILE
========================================================= */

.student-profile {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 20px;

    margin-bottom: 22px;
}


.profile-name {
    font-size: 20px;

    font-weight: 700;

    color: #111827;
}


.profile-info {
    margin-top: 5px;

    color: #64748b;

    font-size: 11px;
}


.profile-test {
    text-align: right;
}


.profile-test-name {
    font-size: 11px;

    color: #64748b;

    margin-bottom: 6px;
}


.profile-kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 12px;

    border-top:
        1px solid
        #eef2f7;

    padding-top: 18px;
}


.profile-kpi-label {
    font-size: 11px;

    color: #64748b;

    margin-bottom: 4px;
}


.profile-kpi-value {
    font-size: 20px;

    font-weight: 700;

    color: #172033;
}


/* =========================================================
   SCORE SECTION
========================================================= */

.score-section-title {
    font-size: 15px;

    font-weight: 600;

    margin-bottom: 16px;

    color: #172033;
}


.score-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 12px;
}


.score-card {
    border:
        1px solid
        #e5e7eb;

    background: #f8fafc;

    border-radius: 10px;

    padding: 15px;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}


.score-card:hover {
    transform: translateY(-2px);

    box-shadow:
        0 4px 12px
        rgba(15, 23, 42, 0.08);
}


.score-card-name {
    font-size: 12px;

    color: #64748b;

    font-weight: 500;

    margin-bottom: 7px;
}


.score-card-value {
    font-size: 25px;

    line-height: 1.1;

    font-weight: 700;
}


.score-card-value.green {
    color: #15803d;
}


.score-card-value.yellow {
    color: #a16207;
}


.score-card-value.red {
    color: #b91c1c;
}


.score-card-id {
    font-size: 10px;

    color: #94a3b8;

    margin-top: 5px;
}


.empty-score {
    padding: 20px;

    text-align: center;

    color: #94a3b8;

    font-size: 12px;

    background: #f8fafc;

    border-radius: 8px;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1000px) {

    .sidebar {
        width: 210px;
    }


    .main {
        margin-left: 210px;

        width: calc(100% - 210px);

        padding: 20px;
    }


    .kpi-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }


    .content-grid {
        grid-template-columns: 1fr;
    }


    .subject-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


@media (max-width: 700px) {

    .sidebar {
        width: 190px;

        padding:
            20px
            10px;
    }


    .main {
        margin-left: 190px;

        width: calc(100% - 190px);

        padding: 15px;
    }


    .topbar {
        flex-direction: column;
    }


    .test-selector {
        width: 100%;
    }


    .selector-grid {
        grid-template-columns: 1fr;
    }


    .profile-kpi-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }


    .score-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

}


@media (max-width: 520px) {

    .sidebar {
        position: relative;

        width: 100%;

        min-height: auto;
    }


    .app {
        flex-direction: column;
    }


    .main {
        margin-left: 0;

        width: 100%;
    }


    .menu {
        display: grid;

        grid-template-columns:
            repeat(2, 1fr);
    }


    .kpi-grid {
        grid-template-columns: 1fr;
    }


    .subject-grid {
        grid-template-columns: 1fr;
    }


    .score-grid {
        grid-template-columns: 1fr;
    }


    .student-profile {
        flex-direction: column;

        align-items: flex-start;
    }


    .profile-test {
        text-align: left;
    }

}

/* =========================================================
   DETAIL TO - FIX TABLE LAYOUT
   ========================================================= */

.detail-to-page {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.detail-to-card {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.detail-to-table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  display: block;
  position: relative;
}

.detail-to-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.detail-to-table th,
.detail-to-table td {
  white-space: nowrap;
  padding: 12px 14px;
}

/* NO */
.detail-to-table th:first-child,
.detail-to-table td:first-child {
  min-width: 50px;
  width: 50px;
  text-align: center;
}

/* NAMA SISWA */
.detail-to-table th:nth-child(2),
.detail-to-table td:nth-child(2) {
  min-width: 240px;
  width: 240px;
  text-align: left;
}

/* Nilai mapel */
.detail-to-table th:nth-child(n+3),
.detail-to-table td:nth-child(n+3) {
  min-width: 75px;
  text-align: center;
}

/* Header */
.detail-to-table thead th {
  white-space: nowrap;
}

/* Jangan biarkan tabel menekan layout halaman */
.detail-to-table-wrapper table {
  max-width: none;
}

/* Mobile / layar kecil */
@media (max-width: 900px) {
  .detail-to-table-wrapper {
    overflow-x: auto;
  }

  .detail-to-table {
    min-width: 1200px;
  }
}

/* =========================================================
   COMPATIBILITY + DETAIL TO FINAL FIX
   Targets the actual class/id names used by index.html
   ========================================================= */

/* Main content used by index.html */
.main-content {
    margin-left: 240px;
    width: calc(100% - 240px);
    min-height: 100vh;
    padding: 28px;
    min-width: 0;
}

/* Header used by index.html */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 22px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.page-header p {
    color: #64748b;
    font-size: 12px;
    margin-top: 3px;
}

/* Selects used by index.html */
.page-header select,
.student-selectors select {
    min-width: 120px;
    background: white;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    padding: 10px 13px;
    color: #172033;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.page-header select:focus,
.student-selectors select:focus {
    border-color: #2864e8;
    box-shadow: 0 0 0 3px rgba(40, 100, 232, 0.12);
}

/* =========================================================
   DETAIL TO
   ========================================================= */

.detail-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 18px;
}

.detail-toolbar-left,
.detail-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box input {
    width: 280px;
    max-width: 100%;
    padding: 10px 13px;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 13px;
    background: white;
}

.search-box input:focus {
    border-color: #2864e8;
    box-shadow: 0 0 0 3px rgba(40, 100, 232, 0.12);
}

.secondary-button {
    border: 1px solid #dbe2ea;
    background: white;
    color: #334155;
    border-radius: 8px;
    padding: 10px 13px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.secondary-button:hover {
    background: #f8fafc;
}

.detail-table-card {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.detail-test-title {
    font-size: 15px;
    font-weight: 600;
    color: #172033;
    margin-bottom: 15px;
}

/*
   IMPORTANT:
   The HTML uses .detail-table-wrapper and #detailTable,
   not .detail-to-table-wrapper / .detail-to-table.
*/
.detail-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    display: block;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

#detailTable {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

#detailTable th,
#detailTable td {
    white-space: nowrap;
    padding: 12px 14px;
}

#detailTable th:first-child,
#detailTable td:first-child {
    min-width: 50px;
    width: 50px;
    text-align: center;
}

#detailTable th:nth-child(2),
#detailTable td:nth-child(2) {
    min-width: 240px;
    width: 240px;
    text-align: left;
    position: sticky;
    left: 0;
}

#detailTable th:nth-child(n+3),
#detailTable td:nth-child(n+3) {
    min-width: 75px;
    text-align: center;
}

#detailTable thead th {
    white-space: nowrap;
    background: white;
}

/* Keep the first two columns readable while horizontally scrolling */
#detailTable th:first-child,
#detailTable td:first-child,
#detailTable th:nth-child(2),
#detailTable td:nth-child(2) {
    background: white;
}

#detailTable tbody tr:hover td:first-child,
#detailTable tbody tr:hover td:nth-child(2) {
    background: #f8fafc;
}

/* =========================================================
   RESPONSIVE COMPATIBILITY
   ========================================================= */

@media (max-width: 1000px) {
    .main-content {
        margin-left: 210px;
        width: calc(100% - 210px);
        padding: 20px;
    }
}

@media (max-width: 700px) {
    .main-content {
        margin-left: 190px;
        width: calc(100% - 190px);
        padding: 15px;
    }

    .page-header {
        flex-direction: column;
    }

    .page-header select {
        width: 100%;
    }

    .detail-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .detail-toolbar-left,
    .detail-toolbar-right {
        width: 100%;
    }

    .search-box,
    .search-box input {
        width: 100%;
    }

    .detail-toolbar-right {
        justify-content: flex-end;
    }
}

@media (max-width: 520px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* =========================================================
   END FINAL FIX
   ========================================================= */
