/* 
 * Estilos específicos para la herramienta de Merge PDF
 * Incluye estilos para la lista de archivos y vista previa
 */

/* Lista de archivos */
.file-list {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

/* Elemento individual de archivo con vista previa */
.file-item-with-preview {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    align-items: center;
    cursor: move;
    transition: all 0.3s ease;
    position: relative;
}

.file-item-with-preview:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.file-item-with-preview.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

/* Vista previa en miniatura del PDF */
.pdf-preview-thumb {
    width: 120px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-preview-thumb::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    z-index: 1;
    pointer-events: none;
}

.pdf-preview-thumb:hover::before {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
}

.pdf-thumb-iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
    position: relative;
    z-index: 0;
}

/* Información del archivo */
.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0; /* Para permitir truncado */
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.3;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Controles del archivo */
.file-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.file-order {
    background: var(--gradient-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
    white-space: nowrap;
}

.remove-file-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.remove-file-btn:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: scale(1.05);
}

.remove-file-btn:active {
    transform: scale(0.95);
}

/* Vista previa lateral (sideblock) */
.pdf-preview-sideblock {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

.pdf-preview-sideblock.show {
    right: 0;
}

.sideblock-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.sideblock-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sideblock-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pdf-viewer {
    flex: 1;
    position: relative;
}

.sideblock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.sideblock-overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* Responsive design */
@media (max-width: 768px) {
    .file-item-with-preview {
        grid-template-columns: 80px 1fr auto;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .pdf-preview-thumb {
        width: 80px;
        height: 60px;
    }

    .file-name {
        font-size: 0.9rem;
    }

    .file-size {
        font-size: 0.8rem;
    }

    .pdf-preview-sideblock {
        width: 100%;
        right: -100%;
    }

    .file-controls {
        gap: 0.5rem;
    }

    .file-order {
        padding: 0.2rem 0.6rem;
        font-size: 0.75rem;
    }

    .remove-file-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .file-item-with-preview {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 1rem;
    }

    .pdf-preview-thumb {
        width: 100%;
        height: 120px;
        justify-self: center;
    }

    .file-controls {
        justify-content: center;
    }
}

/* Estados de arrastrar y soltar */
.file-item-with-preview.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.02);
}

.file-list.dragging .file-item-with-preview:not(.dragging) {
    opacity: 0.7;
}

/* Animaciones mejoradas */
@keyframes fileItemAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-item-with-preview {
    animation: fileItemAppear 0.3s ease-out;
}

/* Estados de carga para vista previa */
.pdf-preview-thumb.loading {
    background: var(--bg-secondary);
    position: relative;
}

.pdf-preview-thumb.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-light);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
