/* CAMINHO: /css/global/tables.css */
/* OBJETIVO: Tabelas padronizadas para consultas/listagens */

.erp-table-wrapper {
    width: 100%;
    overflow-x: auto;
    background: var(--erp-white);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius-lg);
    box-shadow: var(--erp-shadow-sm);
}

.erp-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
    background: var(--erp-white);
}

.erp-table thead {
    background: linear-gradient(135deg, var(--erp-gray-50), #ffffff);
}

.erp-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--erp-gray-600);
    border-bottom: 1px solid var(--erp-border);
    white-space: nowrap;
}

.erp-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--erp-gray-700);
    border-bottom: 1px solid var(--erp-border);
    vertical-align: middle;
}

.erp-table tbody tr {
    transition: var(--erp-transition);
}

.erp-table tbody tr:hover {
    background: var(--erp-gray-50);
}

.erp-table tbody tr:last-child td {
    border-bottom: 0;
}

.erp-table-title {
    font-weight: 800;
    color: var(--erp-gray-900);
}

.erp-table-subtitle {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--erp-text-soft);
}

.erp-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.erp-table-cell-center {
    text-align: center;
}

.erp-table-cell-right {
    text-align: right;
}

.erp-table-cell-nowrap {
    white-space: nowrap;
}

.erp-table-money {
    font-weight: 800;
    color: var(--erp-gray-900);
    white-space: nowrap;
}

.erp-table-id {
    font-weight: 800;
    color: var(--erp-primary);
    white-space: nowrap;
}

.erp-table-mobile {
    display: none;
}

.erp-list-card {
    background: var(--erp-white);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius-lg);
    box-shadow: var(--erp-shadow-sm);
    padding: 16px;
}

.erp-list-card + .erp-list-card {
    margin-top: 12px;
}

.erp-list-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.erp-list-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--erp-gray-900);
}

.erp-list-card-subtitle {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--erp-text-soft);
}

.erp-list-card-body {
    display: grid;
    gap: 10px;
}

.erp-list-card-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--erp-gray-100);
}

.erp-list-card-row:last-child {
    border-bottom: 0;
}

.erp-list-card-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--erp-text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.erp-list-card-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--erp-gray-800);
    text-align: right;
}

.erp-list-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.erp-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.erp-pagination a,
.erp-pagination span {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--erp-radius);
    border: 1px solid var(--erp-border);
    background: var(--erp-white);
    font-size: 14px;
    font-weight: 800;
    color: var(--erp-gray-700);
}

.erp-pagination .active {
    background: var(--erp-primary);
    border-color: var(--erp-primary);
    color: var(--erp-white);
}

@media (min-width: 901px) {
    .erp-table-mobile,
    .erp-table-mobile-ready {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .erp-table-desktop-only {
        display: none !important;
    }

    .erp-table-mobile,
    .erp-table-mobile-ready {
        display: block !important;
    }

    .erp-table-card-ready {
        width: 100%;
        max-width: 100%;
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .erp-table-card-ready .erp-table-has-mobile-cards {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        border-collapse: separate;
        background: transparent;
    }

    .erp-table-has-mobile-cards thead {
        display: none;
    }

    .erp-table-has-mobile-cards tbody {
        display: grid;
        gap: 12px;
    }

    .erp-table-has-mobile-cards tr {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 12px;
        border: 1px solid var(--erp-border);
        border-radius: 16px;
        background: var(--erp-white);
        box-shadow: var(--erp-shadow-sm);
        overflow: hidden;
    }

    .erp-table-has-mobile-cards tr:hover {
        background: var(--erp-white);
    }

    .erp-table-has-mobile-cards td {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 8px 0;
        border: 0;
        border-bottom: 1px solid var(--erp-gray-100);
        color: var(--erp-gray-800);
        font-size: 13px;
        line-height: 1.35;
        text-align: left;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .erp-table-has-mobile-cards td:last-child {
        border-bottom: 0;
    }

    .erp-table-has-mobile-cards td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: var(--erp-text-soft);
        font-size: 11px;
        font-weight: 900;
        line-height: 1.2;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .erp-table-has-mobile-cards td:first-child {
        font-size: 15px;
        font-weight: 900;
        color: var(--erp-gray-900);
    }

    .erp-table-has-mobile-cards td:first-child::before {
        font-size: 11px;
    }

    .erp-table-has-mobile-cards .erp-table-actions,
    .erp-table-has-mobile-cards td.erp-table-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: left;
    }

    .erp-table-has-mobile-cards td.erp-table-actions::before {
        margin-bottom: 2px;
    }

    .erp-table-has-mobile-cards td.erp-table-actions .erp-btn,
    .erp-table-has-mobile-cards td.erp-table-actions form,
    .erp-table-mobile .erp-btn,
    .erp-table-mobile form {
        width: 100%;
    }

    .erp-card > .erp-table-card-ready,
    .erp-panel > .erp-table-card-ready,
    .erp-section > .erp-table-card-ready {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .erp-table-has-mobile-cards .erp-mobile-table-empty,
    .erp-table-has-mobile-cards td[colspan] {
        display: block;
        padding: 0;
        text-align: center;
        border-bottom: 0;
    }

    .erp-table-has-mobile-cards .erp-mobile-table-empty::before,
    .erp-table-has-mobile-cards td[colspan]::before {
        display: none;
    }
}
