/* Layout & Typography specifics for the PDF merger tool */

/* Mantener consistencia con la paleta de colores del sitio */
:root {
    --tool-bg: #fff;
    --tool-border: #e6eef2;
    --tool-heading: #06233a;
    --tool-muted: #5d7285;
    --tool-accent: #0b91a6;
    --tool-accent-hover: #087a8c;
    --tool-danger: #e25c5c;
    --tool-danger-hover: #c93b3b;
    --tool-danger-bg: #ffeeee;
}

.page-content {
    padding-top: 40px;
    padding-bottom: 60px;
}

.tool-header {
    text-align: center;
    max-width: 600px;
    margin: 0 auto 40px;
}

.tool-header h1 {
    font-size: 32px;
    color: var(--tool-heading);
    margin-bottom: 12px;
}

.tool-header p {
    font-size: 18px;
    color: var(--tool-muted);
    line-height: 1.5;
}

.tool-workspace {
    background: var(--tool-bg);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(6, 35, 58, 0.08);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    border: 1px solid var(--tool-border);
    position: relative;
    min-height: 300px;
}

/* Drag and Drop Zone */
.drop-zone {
    border: 2px dashed #b8cdd6;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    background-color: #fcfdfe;
    cursor: pointer;
}

.drop-zone:hover {
    border-color: var(--tool-accent);
    background-color: #f4f8fa;
}

.drop-zone.drag-over {
    border-color: var(--tool-accent);
    background-color: #f0f8fa;
    transform: scale(1.02);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    /* Let the parent handle drop events neatly */
}

/* Ensure the button within is clickable */
.drop-zone-content .btn {
    pointer-events: auto;
    margin-top: 20px;
}

.upload-icon {
    color: var(--tool-accent);
    margin-bottom: 16px;
}

.drop-zone h3 {
    font-size: 20px;
    color: var(--tool-heading);
    margin-bottom: 8px;
}

.drop-zone p {
    color: var(--tool-muted);
    margin-bottom: 0;
}

.hidden-input {
    display: none;
}

/* File List Container */
.file-list-header {
    margin-bottom: 24px;
}

.file-list-header h3 {
    font-size: 18px;
    color: var(--tool-heading);
    margin-bottom: 4px;
}

.file-list-header .hint {
    font-size: 14px;
    color: var(--tool-muted);
    margin: 0;
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 8px;
    /* Espacio para el scrollbar */
}

/* Estilizar el scrollbar para un aspecto premium (Webkit) */
.file-list::-webkit-scrollbar {
    width: 6px;
}

.file-list::-webkit-scrollbar-track {
    background: #f4f8fa;
    border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb {
    background-color: #cfdee6;
    border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb:hover {
    background-color: #8da4b3;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background-color: var(--tool-bg);
    border: 1px solid var(--tool-border);
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    animation: slideIn 0.3s ease-out forwards;
    position: relative;
    cursor: grab;
}

.file-item:active {
    cursor: grabbing;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-color: #cfdee6;
    transform: translateY(-2px);
}

.file-thumbnail {
    width: 100px;
    height: 140px;
    background-color: #f4f8fa;
    border: 1px solid #cfdee6;
    border-radius: 4px;
    margin-bottom: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.file-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #fff;
    display: block;
}

.file-thumbnail.skeleton {
    animation: pulse-bg 1.5s infinite;
}

@keyframes pulse-bg {
    0% {
        background-color: #f4f8fa;
    }

    50% {
        background-color: #e6eef2;
    }

    100% {
        background-color: #f4f8fa;
    }
}

.file-thumbnail svg {
    color: #8da4b3;
    width: 24px;
    height: 24px;
}

.file-info {
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin-bottom: 0;
}

.file-name {
    font-weight: 600;
    color: var(--tool-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
    font-size: 14px;
    width: 100%;
}

.file-size {
    font-size: 12px;
    color: #8da4b3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.file-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--tool-border);
}

.control-btn {
    background: transparent;
    border: 1px solid var(--tool-border);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--tool-muted);
    transition: all 0.2s;
}

.control-btn:hover:not(:disabled) {
    background: #f4f8fa;
    color: var(--tool-heading);
    border-color: #cfdee6;
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #fafcfd;
}

.remove-btn {
    color: var(--tool-danger);
    border-color: transparent;
}

.remove-btn:hover {
    background: var(--tool-danger-bg);
    color: var(--tool-danger-hover);
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 24px;
    border-top: 1px solid var(--tool-border);
}

.preview-btn,
.merge-btn {
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
}

.preview-btn {
    background-color: transparent;
    border: 1px solid var(--tool-border);
    color: var(--tool-heading);
}

.preview-btn:hover:not(:disabled) {
    background-color: #f4f8fa;
    border-color: #cfdee6;
    transform: translateY(-2px);
}

.preview-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.merge-btn {
    box-shadow: 0 4px 12px rgba(11, 145, 166, 0.2);
}

.merge-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(11, 145, 166, 0.3);
}

.merge-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(2px);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--tool-border);
    border-top-color: var(--tool-accent);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
    margin-bottom: 16px;
}

.loading-overlay p {
    font-weight: 600;
    color: var(--tool-heading);
    animation: pulse 1.5s infinite;
}

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

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Responsive fixes */
@media (max-width: 600px) {
    .tool-workspace {
        padding: 16px;
    }

    .file-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }

    .file-item {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px;
        justify-content: flex-start;
    }

    .file-thumbnail {
        width: 64px;
        height: 90px;
        margin-bottom: 0;
        margin-right: 12px;
    }

    .file-info {
        flex: 1;
        width: calc(100% - 76px);
        align-items: flex-start;
        text-align: left;
    }

    .file-name {
        font-size: 14px;
        white-space: normal;
        word-break: break-word;
    }

    .file-controls {
        width: 100%;
        flex-direction: row;
        justify-content: flex-end;
        border-top: 1px dashed var(--tool-border);
        margin-top: 12px;
        padding-top: 12px;
        gap: 8px;
    }

    .control-btn {
        width: 36px;
        height: 36px;
    }

    .up-btn svg {
        transform: rotate(-90deg);
        /* points right initially, so rotate left pointing UP */
    }

    .down-btn svg {
        transform: rotate(90deg);
        /* points right initially, rotate right pointing DOWN */
    }

    .action-bar {
        flex-direction: column;
        gap: 16px;
    }

    .action-bar>div {
        width: 100%;
        flex-direction: column !important;
    }

    .action-bar .btn {
        width: 100%;
    }
}

/* SEO Content Section */
.seo-content {
    margin-top: 80px;
    padding-top: 60px;
    border-top: 2px dashed #cfdee6;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.seo-content h2,
.seo-content h3,
.seo-content h4 {
    color: var(--tool-heading);
    margin-bottom: 16px;
}

.seo-content h2 {
    font-size: 28px;
    margin-bottom: 24px;
}

.seo-content h3 {
    font-size: 22px;
    margin-top: 40px;
}

.seo-content h4 {
    font-size: 18px;
    margin-top: 32px;
}

.seo-content p,
.seo-content ul,
.seo-content ol {
    color: var(--tool-muted);
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.seo-content ul,
.seo-content ol {
    padding-left: 24px;
}

.seo-content li {
    margin-bottom: 8px;
}

.seo-content strong {
    color: var(--tool-heading);
}

.seo-content hr {
    margin: 40px 0;
    border: 0;
    border-top: 1px solid var(--tool-border);
}

/* Modal de Vista Previa */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.preview-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    /* Fondo oscuro para enfocar */
    backdrop-filter: blur(4px);
}

.preview-modal-container {
    position: relative;
    width: 90%;
    max-width: 900px;
    height: 90%;
    background: #e6eef2;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.preview-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid var(--tool-border);
}

.preview-modal-header h2 {
    font-size: 18px;
    color: var(--tool-heading);
    margin: 0;
    font-weight: 600;
}

.preview-close-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--tool-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.preview-close-btn:hover {
    background: #f4f8fa;
    color: var(--tool-heading);
}

.preview-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

/* Scrollbar para el modal */
.preview-modal-body::-webkit-scrollbar {
    width: 10px;
}

.preview-modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.preview-modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.preview-modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.4);
}

.pdf-page-wrapper {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    border: 1px solid #ddd;
    /* Impedir selección y arrastre accidental */
    user-select: none;
    pointer-events: none;
    /* Deshabilita clicks también para mayor seguridad, la vista es solo visual */
}

/* Utilities */
.hidden {
    display: none !important;
}