/**
 * Globe Upscale TCMS — Responsive Mobile Tables Architecture
 * Converts desktop tables to elegant card-based mobile UI without over-scroll
 */

/* ==========================================================================
   1. DESKTOP TABLE REFINEMENTS
   ========================================================================== */
.fi-ta-table {
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: 100% !important;
}

.fi-ta-row {
    transition: background-color 0.15s ease, transform 0.15s ease !important;
}

.fi-ta-row:hover td {
    background-color: rgba(2, 132, 199, 0.03) !important;
}

.dark .fi-ta-row:hover td {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

/* ==========================================================================
   2. MOBILE RESPONSIVE CARD CONVERSION (Screen width <= 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Prevent document-level horizontal over-scroll */
    html, body, .fi-body, .fi-main, .fi-page, .fi-ta-ctn, .fi-ta-content {
        max-width: 100vw !important;
        overflow-x: clip !important;
    }

    /* Table Container becomes card wrapper */
    .fi-ta-ctn {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .fi-ta-content {
        overflow-x: visible !important;
        padding: 0 !important;
    }

    /* Hide standard desktop table header */
    thead.fi-ta-header,
    .fi-ta-header-cell {
        display: none !important;
    }

    /* Convert table to block container */
    table.fi-ta-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    table.fi-ta-table > tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 14px !important;
        width: 100% !important;
    }

    /* Table Row converts into an elevated Mobile Card */
    table.fi-ta-table > tbody > tr.fi-ta-row {
        display: flex !important;
        flex-direction: column !important;
        background: #FFFFFF !important;
        border: 1px solid #E2E8F0 !important;
        border-radius: 16px !important;
        padding: 14px 16px !important;
        box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        position: relative !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    }

    .dark table.fi-ta-table > tbody > tr.fi-ta-row {
        background: #111C2E !important;
        border-color: rgba(255, 255, 255, 0.08) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
    }

    table.fi-ta-table > tbody > tr.fi-ta-row:active {
        transform: scale(0.99) !important;
    }

    /* Cells convert into clean Key-Value rows inside the Mobile Card */
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 8px 0 !important;
        border-bottom: 1px dashed rgba(226, 232, 240, 0.7) !important;
        width: 100% !important;
        min-height: 38px !important;
        box-sizing: border-box !important;
        background: transparent !important;
        text-align: end !important;
    }

    .dark table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell {
        border-bottom-color: rgba(255, 255, 255, 0.06) !important;
    }

    /* Dynamic Column Header Label via data-label */
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell[data-label]::before {
        content: attr(data-label);
        font-size: 11.5px !important;
        font-weight: 700 !important;
        color: #64748B !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        margin-inline-end: 14px !important;
        flex-shrink: 0 !important;
        text-align: start !important;
    }

    .dark table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell[data-label]::before {
        color: #94A3B8 !important;
    }

    /* Hide pseudo labels for empty cells, checkboxes, and actions */
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell:empty::before,
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-record-checkbox-cell::before,
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-actions-cell::before {
        content: none !important;
        display: none !important;
    }

    /* Checkbox at top of mobile card */
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-record-checkbox-cell {
        border-bottom: 1px solid #F1F5F9 !important;
        padding-bottom: 8px !important;
        margin-bottom: 4px !important;
        justify-content: flex-start !important;
    }

    .dark table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-record-checkbox-cell {
        border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    }

    /* Actions Toolbar at bottom of mobile card */
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell:last-child,
    table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-actions-cell {
        border-bottom: none !important;
        margin-top: 6px !important;
        padding-top: 10px !important;
        border-top: 1px solid #F1F5F9 !important;
        justify-content: flex-end !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .dark table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-cell:last-child,
    .dark table.fi-ta-table > tbody > tr.fi-ta-row > td.fi-ta-actions-cell {
        border-top-color: rgba(255, 255, 255, 0.08) !important;
    }

    /* Search & Filters toolbar */
    .fi-ta-header-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
}
