/**
 * Componentes Modernos para Tablas
 * Badges, estados, acciones y elementos reutilizables
 */

/* ============================================== 
   BADGES Y ESTADOS
   ============================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-borrador {
    background-color: #f3f4f6;
    color: #6b7280;
}

.badge-enviado {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-recibido {
    background-color: #dcfce7;
    color: #166534;
}

.badge-cancelado {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-pendiente {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-completado {
    background-color: #d1fae5;
    color: #065f46;
}

/* Iconos en badges */
.badge svg {
    width: 12px;
    height: 12px;
}

/* ============================================== 
   ACCIONES DE TABLA
   ============================================== */

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

.table-action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.table-action-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

.table-action-btn svg {
    width: 16px;
    height: 16px;
}

.table-action-btn-primary {
    border-color: #3b82f6;
    color: #3b82f6;
}

.table-action-btn-primary:hover {
    background: #3b82f6;
    color: #ffffff;
}

.table-action-btn-danger {
    border-color: #ef4444;
    color: #ef4444;
}

.table-action-btn-danger:hover {
    background: #ef4444;
    color: #ffffff;
}

/* ============================================== 
   EMPTY STATE PARA TABLAS
   ============================================== */

.table-empty-state {
    padding: 80px 20px;
    text-align: center;
    color: #9ca3af;
}

.table-empty-state svg {
    margin: 0 auto 16px;
    opacity: 0.5;
}

.table-empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.table-empty-state p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* ============================================== 
   FILTROS Y BUSCADOR
   ============================================== */

.table-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.table-search {
    position: relative;
    flex: 1;
    margin-left: 10px;
    width: calc(100% - 20px);
}

.table-search-input {
    width: calc(100% - 50px);
    max-width: 350px;
    padding: 10px 12px 10px 38px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #f9fafb;
}

.table-search-input:focus {
    outline: none;
    border-color: #9ca3af;
    background-color: #ffffff;
}

.table-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.table-filter-select {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-filter-select:hover {
    border-color: #9ca3af;
}

.table-filter-select:focus {
    outline: none;
    border-color: #9ca3af;
}

/* ============================================== 
   LOADING STATE
   ============================================== */

.table-loading {
    padding: 60px 20px;
    text-align: center;
}

.table-loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #f3f4f6;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.table-loading-text {
    color: #6b7280;
    font-size: 14px;
}

/* ============================================== 
   COLUMNAS ESPECIALES
   ============================================== */

/* Columna de número/ID */
.table-col-id {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* Columna de fecha */
.table-col-date {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
}

/* Columna de precio/monto */
.table-col-price {
    font-weight: 600;
    color: #111827;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Columna de usuario */
.table-col-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.table-user-name {
    font-size: 14px;
    color: #111827;
    font-weight: 500;
}

/* ============================================== 
   HEADER DE TABLA CON ACCIONES
   ============================================== */

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.table-header-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #111827;
}

.table-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============================================== 
   HOVER EN FILAS
   ============================================== */

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: #f9fafb;
    cursor: pointer;
}

tbody tr.no-hover:hover {
    background-color: transparent;
    cursor: default;
}

/* ============================================== 
   RESPONSIVE
   ============================================== */

@media (max-width: 768px) {
    .table-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .table-search {
        min-width: 100%;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .table-actions {
        gap: 4px;
    }

    .table-action-btn {
        width: 28px;
        height: 28px;
    }

    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
}

