/* ===============================
   Responsive Data Table (2026)
   =============================== */

.data-table-container {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);

    /* KEY FIX */
    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
}

/* Toolbar */
.data-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.data-table-toolbar > * {
    min-width: 0;
}

/* Table Core */
.data-table {
    width: 100%;
    table-layout: auto;
    min-width: 900px;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.data-table thead {
    background: var(--bg-secondary);
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;

    white-space: nowrap;
}

/* ✅ FIX: allow wrapping */
.data-table td {
    padding: var(--space-4);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

/* Rows */
.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* ===============================
   Product Cell
   =============================== */

.cell-product {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.cell-product-image {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    object-fit: cover;
    flex-shrink: 0;
}

.cell-product-info {
    min-width: 0;
}

.cell-product-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.45;
}

.cell-product-meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ===============================
   Price / Stock
   =============================== */

.cell-price {
    font-family: var(--font-mono);
    font-weight: 600;
}

.cell-price .regular {
    text-decoration: line-through;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.cell-stock {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.stock-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.stock-dot.instock {
    background: var(--success-500);
}

.stock-dot.outofstock {
    background: var(--danger-500);
}

.stock-dot.onbackorder {
    background: var(--warning-500);
}

/* ===============================
   Actions
   =============================== */

.cell-actions {
    display: flex;
    gap: var(--space-1);
    justify-content: flex-end;
    white-space: nowrap;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ===============================
   Footer
   =============================== */

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* ===============================
   MOBILE FIX (Important)
   =============================== */

@media (max-width: 768px) {
    .data-table-container {
        border-radius: var(--radius-lg);
    }

    .data-table-toolbar,
    .table-footer {
        padding-inline: var(--space-4);
    }

    .data-table-toolbar .toolbar-left,
    .data-table-toolbar .toolbar-right {
        width: 100%;
        min-width: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .data-table-toolbar .filter-input,
    .data-table-toolbar .filter-select,
    .data-table-toolbar input,
    .data-table-toolbar select {
        width: 100%;
        max-width: none !important;
    }

    .data-table {
        font-size: 12px;
        min-width: 820px;
    }

    .data-table td,
    .data-table th {
        white-space: nowrap;
    }

    .cell-product {
        gap: 8px;
        min-width: 220px;
    }

    .cell-product-image {
        width: 36px;
        height: 36px;
    }

    .action-btn {
        width: 28px;
        height: 28px;
    }

    .cell-actions {
        flex-wrap: wrap;
    }

    .cell-product-name,
    .cell-product-meta {
        white-space: normal;
    }
}

/* ===============================
   OPTIONAL: Ultra Mobile Mode
   =============================== */

/* Uncomment if you want card layout instead of scroll */

/*
@media (max-width: 480px) {

    .data-table {
        display: block;
        min-width: 100%;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 12px;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
    }
}
*/
