/* ===================================
   INVOICE SCANNER STYLES
   Estilos para el sistema de análisis de facturas con IA
   =================================== */

/* Modal de confirmación de datos extraídos */
.invoice-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.invoice-modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header del modal */
.invoice-modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(124, 58, 237, 0.1));
}

.invoice-modal-header h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.invoice-modal-header h2 i {
    font-size: 1.5rem;
}

.invoice-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.invoice-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* Cuerpo del modal con scroll */
.invoice-modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

/* Secciones del modal */
.invoice-section {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.invoice-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1rem 0;
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.invoice-section-title i {
    color: var(--primary);
}

/* Grid de campos editables */
.invoice-fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.invoice-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.invoice-field label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.invoice-field input,
.invoice-field select {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.invoice-field input:focus,
.invoice-field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Tabla de productos editable */
.invoice-products-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.invoice-products-table thead {
    background: rgba(79, 70, 229, 0.1);
}

.invoice-products-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.invoice-products-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.invoice-products-table input {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    color: var(--text-main);
}

.invoice-products-table input:focus {
    outline: none;
    border-color: var(--primary);
}

.invoice-products-table .product-name {
    min-width: 200px;
}

.invoice-products-table .product-code {
    min-width: 100px;
}

.invoice-products-table .product-qty,
.invoice-products-table .product-price {
    width: 100px;
}

.invoice-products-table .product-total {
    font-weight: 600;
    color: var(--success);
}

/* Botones de acción en tabla */
.invoice-table-actions {
    display: flex;
    gap: 0.5rem;
}

.invoice-add-product-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.invoice-add-product-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Preview de imagen */
.invoice-image-preview {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.invoice-image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Indicador de progreso OCR */
.ocr-progress-container {
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.ocr-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 1rem;
}

.ocr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.3s ease;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Footer del modal */
.invoice-modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.05);
}

.invoice-modal-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.invoice-totals-summary {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.invoice-totals-summary .total-line {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
}

.invoice-totals-summary .total-line.main {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--success);
    border-top: 2px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

/* Estados de validación */
.invoice-field.error input {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.05);
}

.invoice-field.success input {
    border-color: var(--success);
}

.invoice-field-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Badges de información */
.invoice-info-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid var(--primary);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--primary);
}

.invoice-warning-badge {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

/* Responsive */
@media (max-width: 768px) {
    .invoice-modal-content {
        max-height: 95vh;
    }

    .invoice-modal-header,
    .invoice-modal-body,
    .invoice-modal-footer {
        padding: 1rem;
    }

    .invoice-fields-grid {
        grid-template-columns: 1fr;
    }

    .invoice-products-table {
        font-size: 0.85rem;
    }

    .invoice-products-table th,
    .invoice-products-table td {
        padding: 0.5rem;
    }

    .invoice-modal-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .invoice-modal-actions {
        flex-direction: column;
    }

    .invoice-totals-summary {
        order: -1;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border);
    }
}