/* =========================================================
   LSC List Page Styles  (Learner Support Centres)
   Scoped under .table-container and hardened with !important
   so these rules always win over the global site.css.
   ========================================================= */

/* ----- Container & layout ----- */
.table-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
    margin-bottom: 50px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----- Table ----- */
.info-header {
    background-color: #004d99 !important;
    color: #fff !important;
}

.table-container .table th,
.table-container .table td {
    min-width: 40px;
    max-width: 600px;
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
}

.table-container .table th:first-child,
.table-container .table td:first-child {
    min-width: 50px;
    max-width: 70px;
}

/* ----- Headings ----- */
.lsc-title {
    color: #004d99;
    font-weight: bold;
    margin-bottom: 18px;
}

.lsc-session {
    color: #004d99;
    margin-top: 6px;
}

/* ----- Error message ----- */
.lsc-error {
    display: block !important;
    margin-bottom: 12px;
}

/* ----- Cell value + mobile toggle (hidden on desktop) ----- */
.lsc-value {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/* Keep the extra toggle column hidden on desktop so column
   alignment with the header row is never broken. */
.table-container .lsc-toggle-cell {
    display: none !important;
}

.table-container .lsc-toggle-btn {
    display: none !important;
}

/* =========================================================
   Responsive / Mobile friendly
   On small screens the wide data table is transformed into
   a stack of cards so every column stays readable. A "View
   More" button per card expands the full wrapped text.
   ========================================================= */
@media (max-width: 768px) {

    .table-container {
        padding: 14px !important;
        margin-top: 15px !important;
        margin-bottom: 30px !important;
        box-shadow: 0 0 6px rgba(0, 0, 0, 0.08) !important;
    }

    .lsc-title {
        font-size: 18px !important;
        line-height: 1.35 !important;
    }

    .lsc-session {
        font-size: 16px !important;
    }

    /* Turn the table elements into blocks */
    .table-container .table,
    .table-container .table thead,
    .table-container .table tbody,
    .table-container .table tr {
        display: block !important;
        width: 100% !important;
    }

    /* Hide the original header row (labels are shown per cell) */
    .table-container .table thead {
        display: none !important;
    }

    .table-container .table,
    .table-container .table tbody {
        border: none !important;
    }

    /* Each data row becomes a card */
    .table-container .table tbody tr.lsc-row {
        display: block !important;
        background: #fff !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
        margin-bottom: 16px !important;
        overflow: hidden !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
    }

    /* Each cell: label (::before) + value laid out as a flex row.
       Flexbox prevents any cropping and lets the value wrap naturally. */
    .table-container .table tbody td {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 10px 12px !important;
        text-align: left !important;
        border: none !important;
        border-bottom: 1px solid #eee !important;
        min-width: 0 !important;
        max-width: none !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .table-container .table tbody tr td:last-child {
        border-bottom: none !important;
    }

    /* Let the value flex item shrink and wrap */
    .table-container .table tbody td > * {
        min-width: 0 !important;
    }

    .table-container .table tbody td::before {
        content: attr(data-label) !important;
        flex: 0 0 40% !important;
        align-self: stretch !important;
        font-weight: 600 !important;
        color: #004d99 !important;
        background: #f4f8fc !important;
        border-right: 1px solid #e3eaf2 !important;
        border-radius: 4px 0 0 4px !important;
        padding: 2px 8px !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    /* Highlight the Sr. No. row label */
    .table-container .table tbody td:first-child::before {
        background: #e8f1fb !important;
        font-weight: 700 !important;
    }

    /* Clamp each cell's value to 2 lines until the row is expanded */
    .table-container .lsc-row:not(.expanded) .lsc-value {
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    /* Toggle button row (full width, no label) */
    .table-container .lsc-toggle-cell {
        display: flex !important;
        flex: 1 1 100% !important;
        justify-content: center !important;
        align-items: center !important;
        background: #f7fafd !important;
        border-bottom: none !important;
        padding: 8px !important;
    }

    .table-container .lsc-toggle-cell::before {
        display: none !important;
    }

    .table-container .lsc-toggle-btn {
        display: inline-block !important;
        border: 1px solid #004d99 !important;
        background: #004d99 !important;
        color: #fff !important;
        padding: 6px 22px !important;
        border-radius: 20px !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
        cursor: pointer !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }

    .table-container .lsc-toggle-btn:hover {
        background: #003d7a !important;
    }

    .table-container .lsc-toggle-btn:focus {
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(0, 77, 153, 0.25) !important;
    }

    /* Expanded state shows the full wrapped value */
    .table-container .lsc-row.expanded .lsc-value {
        display: block !important;
    }
}

/* Very small phones */
@media (max-width: 420px) {
    .table-container {
        padding: 10px !important;
    }

    .table-container .table tbody td {
        font-size: 13px !important;
        gap: 8px !important;
    }

    .table-container .table tbody td::before {
        flex-basis: 38% !important;
        font-size: 12px !important;
    }
}
