/**
 * Estilos para el historial de items en el modal de detalle de ticket
 */

/* Botón toggle historial item */
.btn-toggle-item-historial {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-toggle-item-historial:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-toggle-item-historial svg {
    transition: transform 0.2s ease;
    stroke: #6b7280;
}

.btn-toggle-item-historial:hover svg {
    stroke: #6366f1;
}

/* Fila de historial expandible */
.item-historial-row {
    background: #f9fafb;
}

.item-historial-content {
    padding: 1.5rem;
    border-left: 3px solid #6366f1;
    margin-left: 40px;
}

.item-historial-content h4 {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Timeline de historial */
.historial-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.historial-entry-item {
    display: flex;
    gap: 1rem;
    position: relative;
}

.historial-entry-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 28px;
    bottom: -16px;
    width: 2px;
    background: #e5e7eb;
}

.historial-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    background: white;
    border-radius: 50%;
    border: 2px solid currentColor;
    z-index: 1;
    position: relative;
}

.historial-details {
    flex: 1;
    padding-bottom: 0.5rem;
}

.historial-accion {
    margin-bottom: 0.5rem;
}

.historial-accion strong {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
}

.historial-accion p {
    margin: 0.25rem 0 0 0;
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.4;
}

.historial-accion p.text-sm {
    font-size: 0.75rem;
    color: #9ca3af;
}

.historial-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
    color: #9ca3af;
}

.historial-fecha {
    font-weight: 500;
}

.historial-usuario {
    color: #6366f1;
}

/* Tabla con historial */
.table-items-historial tbody tr[data-item-index] {
    cursor: pointer;
    transition: background 0.15s ease;
}

.table-items-historial tbody tr[data-item-index]:hover {
    background: #f9fafb;
}

.table-items-historial tbody tr.tachado {
    opacity: 0.6;
    text-decoration: line-through;
}

/* ========== Modal detalle ticket (alineado con modales base) ========== */
#modal-ticket-detalle .ticket-detalle-modal {
    max-width: 720px;
    width: 95%;
}

#modal-ticket-detalle .modal-header {
    padding: 24px 24px 20px;
    border-bottom: 1px solid #e5e7eb;
}

#modal-ticket-detalle .modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

#modal-ticket-detalle .modal-body {
    padding: 24px;
    overflow-y: auto;
}

#modal-ticket-detalle .ticket-detalle-section {
    margin-bottom: 1.5rem;
}

#modal-ticket-detalle .ticket-detalle-section:last-of-type {
    margin-bottom: 0;
}

#modal-ticket-detalle .ticket-detalle-section h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#modal-ticket-detalle .ticket-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem 1.5rem;
}

#modal-ticket-detalle .ticket-info-grid .info-label {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

#modal-ticket-detalle .ticket-info-grid .info-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #111827;
}

/* Tablas con scroll horizontal (como clientes/proveedores) */
#modal-ticket-detalle .ticket-detalle-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper table {
    width: 100%;
    min-width: 400px;
    border-collapse: collapse;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.875rem;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper tfoot td {
    padding: 12px 14px;
    border-top: 2px solid #e5e7eb;
    font-weight: 600;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper::-webkit-scrollbar {
    height: 8px;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

#modal-ticket-detalle .ticket-detalle-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Tabla auditoría */
#modal-ticket-detalle .table-auditoria {
    font-size: 0.8125rem;
}

#modal-ticket-detalle .table-auditoria .auditoria-fecha {
    white-space: nowrap;
    color: #6b7280;
}

#modal-ticket-detalle .table-auditoria .auditoria-accion {
    font-weight: 500;
    color: #111827;
}

#modal-ticket-detalle .table-auditoria .auditoria-detalles {
    max-width: 220px;
    word-break: break-word;
    font-size: 0.75rem;
    color: #6b7280;
}

#modal-ticket-detalle .ticket-detalle-section .text-muted {
    margin: 0;
    font-size: 0.875rem;
    color: #9ca3af;
}

/* Alert rectificativa */
#modal-ticket-detalle .alert.alert-warning {
    border-radius: 8px;
    border: 1px solid #fcd34d;
}

/* Responsive */
@media (max-width: 768px) {
    .item-historial-content {
        margin-left: 20px;
        padding: 1rem;
    }

    .historial-entry-item {
        gap: 0.75rem;
    }

    .historial-icon {
        width: 18px;
        height: 18px;
        font-size: 12px;
    }

    .historial-entry-item:not(:last-child)::before {
        left: 7px;
    }

    #modal-ticket-detalle .ticket-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    #modal-ticket-detalle .table-auditoria .auditoria-detalles {
        max-width: 120px;
    }
}

