/* ===== OTIMIZAÇÃO GLOBAL DE TABELAS - MOTOBOR 3.0 ===== */

/* Container responsivo para tabelas */
.table-responsive {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 70vh;
    overflow: auto;
    background: white;
}

/* Estilos base para tabelas */
.table {
    margin-bottom: 0;
    font-size: 0.75rem;
    min-width: 100%;
}

/* Cabeçalho da tabela */
.table thead th {
    font-weight: 600;
    font-size: 0.7rem;
    padding: 6px 4px;
    vertical-align: middle;
    border-bottom: 2px solid #dee2e6;
    background-color: #343a40;
    color: rgb(245, 200, 104);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

/* Células da tabela */
.table tbody td {
    padding: 5px 4px;
    vertical-align: middle;
    font-size: 0.75rem;
    border-bottom: 1px solid #dee2e6;
}

/* Hover effect */
.table-hover tbody tr:hover {
    background-color: rgba(0,123,255,0.05);
    cursor: pointer;
}

/* Texto truncado com tooltip */
.text-truncate-table {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: help;
}

.text-truncate-table:hover {
    overflow: visible;
    white-space: normal;
    background-color: rgba(255,255,255,0.95);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 100;
    position: relative;
}

/* Alinhamentos específicos */
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-nowrap { white-space: nowrap !important; }

/* Botões na tabela */
.table .btn {
    margin: 1px;
    padding: 0.15rem 0.3rem;
    font-size: 0.65rem;
    line-height: 1.2;
}

.table .btn-sm {
    padding: 0.1rem 0.25rem;
    font-size: 0.6rem;
    line-height: 1.1;
}

/* Badges e status */
.table .badge {
    font-size: 0.6rem;
    padding: 0.2em 0.4em;
    line-height: 1.1;
}

/* Botões de status específicos */
.status-cell {
    font-size: 0.65rem !important;
    padding: 0.2rem 0.4rem !important;
    display: inline-block;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.2;
    min-width: 70px;
    text-align: center;
}

/* Scroll personalizado */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===== RESPONSIVIDADE ===== */

/* Tablets grandes (1200px - 1400px) */
@media (max-width: 1400px) {
    .table {
        font-size: 0.85rem;
    }
    
    .table thead th {
        padding: 10px 6px;
        font-size: 0.8rem;
    }
    
    .table tbody td {
        padding: 8px 6px;
    }
    
    .text-truncate-table {
        max-width: 150px;
    }
}

/* Tablets (768px - 1200px) */
@media (max-width: 1200px) {
    .table {
        font-size: 0.8rem;
    }
    
    .table thead th {
        padding: 8px 5px;
        font-size: 0.75rem;
    }
    
    .table tbody td {
        padding: 6px 5px;
        font-size: 0.8rem;
    }
    
    .table .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .text-truncate-table {
        max-width: 120px;
    }
}

/* Mobile (até 768px) */
@media (max-width: 768px) {
    .table-responsive {
        max-height: 60vh;
        font-size: 0.75rem;
    }
    
    .table {
        font-size: 0.75rem;
        min-width: 800px; /* Força scroll horizontal em mobile */
    }
    
    .table thead th {
        padding: 6px 4px;
        font-size: 0.7rem;
    }
    
    .table tbody td {
        padding: 5px 4px;
        font-size: 0.75rem;
    }
    
    .table .btn {
        padding: 0.15rem 0.3rem;
        font-size: 0.65rem;
    }
    
    .table .btn-sm {
        padding: 0.1rem 0.25rem;
        font-size: 0.6rem;
    }
    
    .text-truncate-table {
        max-width: 100px;
    }
    
    .table .badge {
        font-size: 0.65rem;
        padding: 0.25em 0.5em;
    }
}

/* Mobile pequeno (até 480px) */
@media (max-width: 480px) {
    .table-responsive {
        max-height: 50vh;
    }
    
    .table {
        font-size: 0.7rem;
        min-width: 700px;
    }
    
    .table thead th {
        padding: 5px 3px;
        font-size: 0.65rem;
    }
    
    .table tbody td {
        padding: 4px 3px;
        font-size: 0.7rem;
    }
    
    .text-truncate-table {
        max-width: 80px;
    }
}

/* ===== CLASSES UTILITÁRIAS ===== */

/* Larguras específicas para colunas */
.col-data { min-width: 80px; max-width: 100px; }
.col-hora { min-width: 60px; max-width: 70px; }
.col-tipo { min-width: 50px; max-width: 60px; }
.col-codigo { min-width: 60px; max-width: 80px; }
.col-cliente { min-width: 120px; max-width: 180px; }
.col-local { min-width: 100px; max-width: 150px; }
.col-observacoes { min-width: 100px; max-width: 200px; }
.col-status { min-width: 70px; max-width: 90px; }
.col-acoes { min-width: 60px; max-width: 80px; }
.col-valor { min-width: 60px; max-width: 80px; text-align: right; }

/* Estados da tabela */
.table-loading {
    opacity: 0.6;
    pointer-events: none;
}

.table-empty {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-style: italic;
}

/* Melhorias visuais */
.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0,0,0,0.02);
}

.table-bordered {
    border: 1px solid #dee2e6;
}

.table-bordered th,
.table-bordered td {
    border: 1px solid #dee2e6;
}

/* Footer da tabela */
.table tfoot td {
    font-weight: 600;
    background-color: #f8f9fa;
    border-top: 2px solid #dee2e6;
}

/* ===== ANIMAÇÕES ===== */
.table tbody tr {
    transition: background-color 0.2s ease;
}

.table .btn {
    transition: all 0.2s ease;
}

.table .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ===== PRINT STYLES ===== */
@media print {
    .table-responsive {
        overflow: visible !important;
        max-height: none !important;
    }
    
    .table {
        font-size: 10pt;
    }
    
    .table .btn {
        display: none;
    }
    
    .text-truncate-table {
        max-width: none;
        overflow: visible;
        white-space: normal;
    }
}
