
/* =========================================
   TRAZABILIDAD DE CONTENEDORES - ESTILOS
   Añadir al final de contenedores.css
   ========================================= */

/* Click hint en la tarjeta */
.contenedor-card {
    cursor: pointer;
}

.contenedor-card .contenedor-numero {
    cursor: pointer;
    transition: color 0.2s;
}

.contenedor-card:hover .contenedor-numero {
    color: var(--primary-blue, #3b82f6);
}

/* Badge de historial en la tarjeta */
.btn-historial {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-historial:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* =====================
   MODAL TRAZABILIDAD
   ===================== */
#modalTrazabilidad .modal-content {
    max-width: 680px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#modalTrazabilidad .modal-header {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

#modalTrazabilidad .modal-header h2 {
    color: white;
}

#modalTrazabilidad .modal-close {
    color: rgba(255,255,255,0.7);
}

#modalTrazabilidad .modal-close:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

/* Info resumen del contenedor */
.trazabilidad-resumen {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.trazabilidad-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
}

.trazabilidad-badge.tipo-varibox { background: #ede9fe; color: #5b21b6; }
.trazabilidad-badge.tipo-tangko  { background: #fef3c7; color: #92400e; }
.trazabilidad-badge.tipo-ibc     { background: #d1fae5; color: #065f46; }
.trazabilidad-badge.estado       { background: #dbeafe; color: #1e40af; }
.trazabilidad-badge.total        { background: #f1f5f9; color: #475569; }

/* Zona scrollable del timeline */
.trazabilidad-body {
    overflow-y: auto;
    padding: 24px;
    flex: 1;
}

/* Estado vacío */
.trazabilidad-empty {
    text-align: center;
    padding: 48px 24px;
    color: #94a3b8;
}

.trazabilidad-empty i {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    opacity: 0.4;
}

.trazabilidad-empty p {
    font-size: 0.95rem;
}

/* ========================
   TIMELINE
   ======================== */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, #e2e8f0 0%, #c7d2fe 50%, #e2e8f0 100%);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

/* Punto en la línea */
.timeline-dot {
    position: absolute;
    left: -26px;
    top: 14px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 2px currentColor;
    flex-shrink: 0;
}

/* Colores según tipo de movimiento */
.timeline-item[data-tipo="creacion"]  .timeline-dot { background: #10b981; color: #10b981; }
.timeline-item[data-tipo="envio"]     .timeline-dot { background: #3b82f6; color: #3b82f6; }
.timeline-item[data-tipo="devolucion"].timeline-dot { background: #f59e0b; color: #f59e0b; }
.timeline-item[data-tipo="edicion"]   .timeline-dot { background: #8b5cf6; color: #8b5cf6; }
.timeline-item[data-tipo="eliminacion"].timeline-dot { background: #ef4444; color: #ef4444; }

.timeline-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.timeline-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

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

.timeline-tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-creacion  { background: #d1fae5; color: #065f46; }
.badge-envio     { background: #dbeafe; color: #1e40af; }
.badge-devolucion{ background: #fef3c7; color: #92400e; }
.badge-edicion   { background: #ede9fe; color: #5b21b6; }
.badge-eliminacion{ background: #fee2e2; color: #991b1b; }

.timeline-fecha {
    font-size: 0.78rem;
    color: #94a3b8;
    white-space: nowrap;
    margin-top: 2px;
}

.timeline-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #475569;
}

.timeline-row i {
    width: 16px;
    text-align: center;
    color: #94a3b8;
    flex-shrink: 0;
}

.timeline-row strong {
    color: #1e293b;
}

.timeline-arrow {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #475569;
}

.timeline-arrow .from {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    color: #64748b;
    font-size: 0.82rem;
}

.timeline-arrow .to {
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 6px;
    color: #1e40af;
    font-size: 0.82rem;
    font-weight: 600;
}

.timeline-arrow .arrow-icon {
    color: #3b82f6;
    font-size: 0.9rem;
}

.timeline-pedido {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.78rem;
    color: #64748b;
    font-family: monospace;
}

/* Spinner de carga */
.trazabilidad-loading {
    text-align: center;
    padding: 40px;
    color: #64748b;
}

.trazabilidad-loading i {
    font-size: 2rem;
    color: #6366f1;
    margin-bottom: 12px;
    display: block;
}

/* Responsive */
@media (max-width: 600px) {
    #modalTrazabilidad .modal-content {
        max-height: 92vh;
        margin: 0.5rem;
    }

    .trazabilidad-body {
        padding: 16px;
    }

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

    .timeline-arrow {
        flex-wrap: wrap;
    }
}

/* =========================================
   TRAZABILIDAD GLOBAL - ESTILOS
   ========================================= */

/* Botón en la barra de control */
.btn-trazabilidad-global {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-trazabilidad-global:hover {
    background: linear-gradient(135deg, #1e293b, #334155);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.4);
}

/* Modal más ancho para la vista global */
#modalTrazabilidadGlobal .modal-content {
    max-width: 740px;
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.traz-global-header {
    background: linear-gradient(135deg, #0f172a, #1e293b) !important;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.traz-global-header h2 {
    color: white !important;
}

/* Barra de filtros rápidos */
.traz-global-filtros {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.traz-filtro-btn {
    background: white;
    border: 1.5px solid #e2e8f0;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s ease;
}

.traz-filtro-btn:hover {
    border-color: #94a3b8;
    color: #1e293b;
}

.traz-filtro-btn.active {
    background: #1e293b;
    border-color: #1e293b;
    color: white;
}

/* Badge de número de contenedor en cada card global */
.traz-global-num {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 9px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #374151;
    font-family: monospace;
}

/* ═══════════════════════════════════════════════════════════
   ENTRADA ALMACÉN — BOTÓN Y MODAL QR SCANNER
   ═══════════════════════════════════════════════════════════ */

/* Botón en la barra de control */
.btn-entrada-almacen {
    background: linear-gradient(135deg, #065f46, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-entrada-almacen:hover {
    background: linear-gradient(135deg, #047857, #10b981);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.45);
}

/* Modal sizing */
#modalEntradaAlmacen .modal-content,
.modal-entrada-almacen {
    max-width: 520px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
.entrada-almacen-header {
    background: linear-gradient(135deg, #064e3b, #065f46) !important;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.entrada-almacen-header h2 {
    color: white !important;
}

.entrada-almacen-header .modal-close {
    color: rgba(255,255,255,0.7) !important;
}

.entrada-almacen-header .modal-close:hover {
    color: white !important;
    background: rgba(255,255,255,0.12) !important;
}

/* ── Tabs ── */
.entrada-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}

.entrada-tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.87rem;
    font-weight: 600;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.entrada-tab:hover {
    color: #059669;
    background: #ecfdf5;
}

.entrada-tab.active {
    color: #065f46;
    border-bottom-color: #059669;
    background: white;
}

/* ── Tab content ── */
.entrada-tab-content {
    display: none;
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.entrada-tab-content.active {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Área del escáner QR ── */
.qr-scanner-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.qr-viewport {
    position: relative;
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1 / 1;
    background: #0f172a;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

#qrVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    border-radius: 16px;
}

/* Marco animado del QR */
.qr-frame {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.qr-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: #10b981;
    border-style: solid;
}

.qr-corner.tl { top: 16px; left: 16px;  border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.qr-corner.tr { top: 16px; right: 16px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.qr-corner.bl { bottom: 16px; left: 16px;  border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.qr-corner.br { bottom: 16px; right: 16px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }

/* Línea láser animada */
.qr-laser {
    position: absolute;
    left: 16px;
    right: 16px;
    height: 2px;
    background: linear-gradient(to right, transparent, #10b981, transparent);
    top: 16px;
    animation: laserScan 2s ease-in-out infinite;
    box-shadow: 0 0 8px #10b981;
    border-radius: 1px;
}

@keyframes laserScan {
    0%   { top: 16px; opacity: 0.4; }
    50%  { opacity: 1; }
    100% { top: calc(100% - 18px); opacity: 0.4; }
}

/* Placeholder cuando no hay cámara */
.qr-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
    gap: 12px;
}

.qr-placeholder i {
    font-size: 3rem;
    opacity: 0.4;
}

.qr-placeholder p {
    font-size: 0.88rem;
    text-align: center;
    padding: 0 20px;
}

.qr-hint {
    font-size: 0.82rem;
    color: #64748b;
    text-align: center;
    margin: 0;
}

/* Botones de cámara */
.btn-activar-camara,
.btn-detener-camara {
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-activar-camara {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

.btn-activar-camara:hover {
    background: linear-gradient(135deg, #047857, #059669);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5,150,105,0.4);
}

.btn-detener-camara {
    background: #f1f5f9;
    color: #64748b;
    border: 1.5px solid #e2e8f0;
}

.btn-detener-camara:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* ── Entrada Manual ── */
.entrada-manual-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-numero-manual {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
    font-family: monospace;
    color: #1e293b;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.input-numero-manual:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5,150,105,0.15);
}

.btn-procesar-manual {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #065f46, #059669);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    letter-spacing: 0.02em;
}

.btn-procesar-manual:hover {
    background: linear-gradient(135deg, #047857, #10b981);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(5,150,105,0.4);
}

/* ── Resultado / Feedback ── */
.entrada-resultado {
    margin: 0 24px 20px;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.5;
    flex-shrink: 0;
}

.resultado-success {
    background: #d1fae5;
    color: #065f46;
    border: 1.5px solid #6ee7b7;
}

.resultado-success i {
    color: #059669;
    font-size: 1.1rem;
}

.resultado-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1.5px solid #fca5a5;
}

.resultado-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1.5px solid #fcd34d;
}

/* Responsive */
@media (max-width: 600px) {
    #modalEntradaAlmacen .modal-content {
        max-height: 95vh;
        margin: 0.25rem;
        border-radius: 12px;
    }

    .qr-viewport {
        max-width: 280px;
    }

    .entrada-tab-content {
        padding: 16px;
    }

    .entrada-resultado {
        margin: 0 16px 16px;
    }
}
