/* ==========================================
   PDF LAB v2 — Sidebar + Tool Grid + Workspace
   Rediseño modular con glassmorphism premium
   ========================================== */

/* --- PDF-SPECIFIC TOKENS --- */
:root {
    --pdf-red: #dc2626;
    --pdf-red-light: rgba(239, 68, 68, 0.1);
    --pdf-red-glow: rgba(220, 38, 38, 0.2);
    --sidebar-width: 68px;
    --sidebar-expanded: 220px;
    --shell-bg: #f8f9fc;
    --shell-surface: #ffffff;
    --shell-border: #e8ecf1;
}

body.pdf-lab-body {
    background: var(--premium-gradient-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================
   HEADER — PREMIUM GLASSMORPHISM (reused)
   ========================================== */
.header {
    padding: 14px 24px;
    min-height: 64px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(7, 0, 79, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(13, 0, 158, 0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.logo-container:hover { transform: scale(1.02); }

.logo-img { width: 44px; height: 44px; }
.logo-mobile { display: none; height: 38px; width: auto; }

.logo-text {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--premium-primary);
    font-family: 'Outfit';
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
}

.logo-transition {
    background: linear-gradient(to right, var(--premium-primary), var(--pdf-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-red { color: var(--pdf-red); }

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--premium-primary);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    padding: 8px 16px;
    background: rgba(66, 99, 235, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(66, 99, 235, 0.15);
    text-decoration: none;
}

.btn-back:hover {
    background: rgba(66, 99, 235, 0.12);
    transform: translateY(-2px);
    border-color: var(--premium-primary);
}

/* Auth UI overrides for white header */
#headerAuth .auth-ui-user-avatar {
    border: 2px solid var(--premium-primary) !important;
    background: var(--premium-accent-light) !important;
    color: var(--premium-primary) !important;
    box-shadow: 0 4px 12px rgba(13, 0, 158, 0.1) !important;
    font-weight: 700 !important;
}

/* ==========================================
   APP SHELL — SIDEBAR + WORKSPACE
   ========================================== */
.app-shell {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* --- SIDEBAR --- */
.pdf-sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--shell-border);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    gap: 0.25rem;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    overflow: hidden;
    flex-shrink: 0;
}

.pdf-sidebar:hover {
    width: var(--sidebar-expanded);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    margin: 0 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    color: var(--premium-text-light);
    font-family: 'Outfit', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    min-height: 44px;
}

.sidebar-item:hover {
    background: rgba(66, 99, 235, 0.08);
    color: var(--premium-primary);
}

.sidebar-item.active {
    background: var(--pdf-red-light);
    color: var(--pdf-red);
}

.sidebar-item svg {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
}

.sidebar-item .sidebar-label {
    opacity: 0;
    transition: opacity 0.2s ease 0.1s;
}

.pdf-sidebar:hover .sidebar-label {
    opacity: 1;
}

.sidebar-divider {
    height: 1px;
    background: var(--shell-border);
    margin: 0.75rem 16px;
}

/* --- WORKSPACE (dynamic content) --- */
.workspace {
    flex: 1;
    min-width: 0;
    padding: 2rem 1.5rem 5rem;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.workspace.wide {
    max-width: none;
}

.workspace-inner {
    max-width: 900px;
    margin: 0 auto;
    transition: max-width 0.3s ease;
}

.workspace-inner.wide {
    max-width: 1400px;
}

/* ==========================================
   TOOL GRID HOME — La pantalla de bienvenida
   ========================================== */
.tool-grid-home {
    animation: fadeInUp 0.4s ease forwards;
}

.tool-grid-home .home-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.tool-grid-home .home-header h1 {
    font-family: 'Outfit';
    font-size: 2rem;
    font-weight: 800;
    color: var(--premium-primary);
    margin-bottom: 0.5rem;
}

.tool-grid-home .home-header p {
    color: var(--premium-text-light);
    font-size: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    max-width: 700px;
    margin: 0 auto;
}

.tool-card {
    background: white;
    border: 1px solid var(--shell-border);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    box-shadow: var(--premium-shadow-subtle);
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--pdf-red), var(--premium-primary));
    opacity: 0;
    transition: opacity 0.3s;
}

.tool-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--premium-shadow-hover);
    border-color: rgba(220, 38, 38, 0.2);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    background: var(--pdf-red-light);
    color: var(--pdf-red);
    transition: all 0.3s;
}

.tool-card:hover .tool-card-icon {
    background: var(--pdf-red);
    color: white;
    transform: scale(1.08);
}

.tool-card h3 {
    font-family: 'Outfit';
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--premium-text);
    margin-bottom: 0.4rem;
}

.tool-card p {
    font-size: 0.85rem;
    color: var(--premium-text-light);
    line-height: 1.5;
}

.tool-card-badge {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-card-badge.coming {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

/* ==========================================
   TOOL VIEW — Contenedor de cada herramienta
   ========================================== */
.tool-view {
    display: none;
}

.tool-view.active {
    display: block;
    animation: fadeInUp 0.4s ease forwards;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-header h2 {
    font-family: 'Outfit';
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--premium-primary);
    margin-bottom: 0.25rem;
}

.tool-header p {
    color: var(--premium-text-light);
    font-size: 0.95rem;
}

/* ==========================================
   DROPZONE
   ========================================== */
.dropzone-container {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border: 2px dashed var(--premium-border-dark);
    border-radius: 20px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    margin-bottom: 2rem;
    box-shadow: var(--premium-shadow-subtle);
}

.dropzone-container:hover,
.dropzone-container.dragover {
    border-color: var(--pdf-red);
    background: var(--pdf-red-light);
    transform: translateY(-2px);
    box-shadow: var(--premium-shadow-card);
}

.dropzone-icon { width: 48px; height: 48px; color: var(--pdf-red); margin-bottom: 1rem; opacity: 0.8; }
.dropzone-text { font-weight: 700; color: var(--premium-text); font-size: 1.1rem; margin-bottom: 0.25rem; }
.dropzone-subtext { color: var(--premium-text-light); font-size: 0.9rem; }
input[type="file"] { display: none; }

/* ==========================================
   FILE LIST (MERGE)
   ========================================== */
.file-list { display: flex; flex-direction: column; gap: 0.75rem; }

.file-item {
    background: white;
    border: 1px solid var(--premium-border);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--premium-shadow-subtle);
    cursor: grab;
}

.file-icon { color: var(--pdf-red); flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 0.95rem; color: var(--premium-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.75rem; color: var(--premium-text-disabled); }

.btn-remove {
    background: none;
    border: none;
    color: var(--premium-text-disabled);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-remove:hover {
    color: var(--pdf-red);
    background: var(--pdf-red-light);
}

/* ==========================================
   PREVIEW GRID (ORGANIZE/EXTRACT)
   ========================================== */
.preview-container { display: none; margin-top: 1rem; }

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--min-card-width, 140px), 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.page-card {
    background: white;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: var(--premium-shadow-subtle);
}

.page-card:hover { transform: translateY(-4px); box-shadow: var(--premium-shadow-card); }
.page-card.selected { border-color: var(--pdf-red); background: var(--pdf-red-light); }
.page-card canvas { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--shell-border); }

.page-number {
    position: absolute; top: 12px; left: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: white; padding: 2px 8px; border-radius: 4px;
    font-size: 0.75rem; font-weight: 700;
}

.page-check {
    position: absolute; top: 12px; right: 12px;
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid white; background: rgba(0, 0, 0, 0.2);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: all 0.2s;
}

.page-card.selected .page-check { opacity: 1; background: var(--pdf-red); }

.btn-page-rotate {
    position: absolute; bottom: 12px; right: 12px;
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--shell-border);
    color: var(--premium-primary);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.2s; z-index: 5; padding: 0; cursor: pointer;
}

.btn-page-rotate:hover { background: var(--premium-primary); color: white; transform: scale(1.1); }

/* ==========================================
   ZOOM CONTROLS
   ========================================== */
.zoom-controls {
    display: flex; align-items: center; gap: 0.75rem;
    background: white; padding: 0.4rem 0.8rem; border-radius: 12px;
    border: 1px solid var(--shell-border); box-shadow: var(--premium-shadow-subtle);
}

.zoom-controls svg { color: var(--premium-text-light); width: 16px; height: 16px; }

.zoom-slider {
    -webkit-appearance: none; appearance: none;
    width: 100px; height: 4px;
    background: var(--shell-border); border-radius: 2px; outline: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--premium-primary); cursor: pointer; transition: transform 0.1s;
}

.zoom-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

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

/* ==========================================
   ACTION BAR
   ========================================== */
.action-bar {
    position: fixed; bottom: 1.5rem; left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem); max-width: 450px;
    z-index: 100; display: none; transition: all 0.3s;
}

.action-bar.visible {
    display: block;
    animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.btn-process {
    width: 100%; background: var(--pdf-red); color: white;
    border: none; padding: 1rem 1.5rem; border-radius: 18px;
    font-weight: 800; font-size: 1rem;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    box-shadow: 0 10px 30px var(--pdf-red-glow);
    cursor: pointer; transition: all 0.2s;
}

.btn-process:hover { transform: translateY(-2px); filter: brightness(1.1); }

/* ==========================================
   LOADING OVERLAY
   ========================================== */
.loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(13, 0, 158, 0.05); backdrop-filter: blur(6px);
    z-index: 2000; display: none;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 1rem;
}

.loader {
    width: 48px; height: 48px;
    border: 5px solid white; border-bottom-color: var(--pdf-red);
    border-radius: 50%; animation: rotation 1s linear infinite;
}

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

/* ==========================================
   SAVE MODAL (input premium)
   ========================================== */
.input-premium {
    width: 100%; padding: 12px 16px; border-radius: 12px;
    border: 2px solid var(--premium-border);
    font-family: 'Outfit'; font-size: 1rem; color: var(--premium-text);
    transition: all 0.2s; background: white; outline: none;
}

.input-premium:focus { border-color: var(--pdf-red); box-shadow: 0 0 0 4px var(--pdf-red-light); }

/* ==========================================
   FOOTER
   ========================================== */
footer {
    margin-top: auto; text-align: center; padding: 2.5rem 1.5rem;
    background: var(--shell-surface); border-top: 1px solid var(--shell-border);
    color: var(--premium-text-light); font-size: 0.85rem; width: 100%;
}

footer p { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 1.25rem; }
footer .heart { color: #ef4444; display: inline-block; animation: heartBeat 1.5s ease-in-out infinite; }

@keyframes heartBeat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }

.footer-logo { margin-bottom: 1.25rem; opacity: 0.7; transition: opacity 0.3s; }
.footer-logo:hover { opacity: 1; }

.footer-links { display: flex; justify-content: center; gap: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.footer-link {
    color: var(--premium-text-light); text-decoration: none; font-weight: 500;
    transition: all 0.2s; position: relative; background: none; border: none;
    cursor: pointer; font-size: 0.85rem; font-family: inherit;
}

.footer-link:hover { color: var(--premium-accent); transform: translateY(-1px); }

.footer-link::after {
    content: ''; position: absolute; bottom: -3px; left: 50%;
    width: 0; height: 1.5px; background: var(--premium-accent);
    transition: all 0.3s ease; transform: translateX(-50%);
}

.footer-link:hover::after { width: 100%; }

/* ==========================================
   RESPONSIVE — MOBILE FIRST
   ========================================== */
@media (max-width: 768px) {
    .pdf-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: auto;
        flex-direction: row;
        justify-content: space-around;
        padding: 0.5rem 0;
        gap: 0;
        border-right: none;
        border-top: 1px solid var(--shell-border);
        z-index: 90;
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
    }

    .pdf-sidebar:hover { width: 100% !important; }
    .sidebar-label { display: none !important; }
    .sidebar-divider { display: none; }

    .sidebar-item {
        flex-direction: column;
        gap: 2px;
        padding: 8px 6px;
        margin: 0;
        border-radius: 10px;
        font-size: 0.65rem;
        min-height: unset;
    }

    .sidebar-item svg { width: 20px; height: 20px; }

    .sidebar-item .sidebar-label-mobile {
        display: block !important;
        font-size: 0.6rem;
        opacity: 1 !important;
    }

    .workspace { padding: 1rem 0.75rem 7rem; }

    .tools-grid { grid-template-columns: 1fr; max-width: 400px; }

    .tool-grid-home .home-header h1 { font-size: 1.5rem; }

    .btn-back span { display: none; }
    .btn-back { padding: 8px; border-radius: 50%; width: 44px; height: 44px; justify-content: center; }

    .dropzone-container { padding: 1.5rem 1rem; margin-bottom: 1.5rem; }
    .dropzone-icon { width: 40px; height: 40px; margin-bottom: 0.5rem; }
    .dropzone-text { font-size: 1.1rem; }
    .dropzone-subtext { font-size: 0.8rem; }

    .preview-header-wrapper {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .preview-grid { gap: 0.5rem !important; }

    .zoom-controls { width: 100%; justify-content: center; background: rgba(255, 255, 255, 0.7); }
    .zoom-slider { flex: 1; }

    #btn-deselect-all, #btn-select-all { font-size: 0.75rem !important; padding: 6px 10px !important; }
    .page-card { padding: 6px; border-radius: 10px; }
    .page-number { top: 8px; left: 8px; padding: 1px 6px; font-size: 0.65rem; }
}

@media (max-width: 480px) {
    .header { padding: 10px 16px; min-height: 64px; }
    .logo-text, .logo-img { display: none; }
    .logo-mobile { display: block; height: 38px; }
    .header-content { gap: 8px; }

    .btn-back { padding: 8px; width: 40px; height: 40px; border: 1px solid var(--shell-border); background: white; }

    #headerAuth .auth-ui-user-button {
        border-radius: 50% !important; width: 40px; height: 40px;
        padding: 0 !important; display: flex; align-items: center;
        justify-content: center; overflow: hidden;
    }

    #headerAuth .auth-ui-user-avatar {
        margin: 0 !important; width: 40px !important; height: 40px !important; border: none !important;
    }

    .preview-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
}

@media (max-width: 600px) {
    .main-container { padding: 1rem 0.75rem 6rem; }
    .action-bar { bottom: 5.5rem; }

    .preview-container .preview-header-wrapper {
        flex-direction: column; align-items: flex-start !important; gap: 1rem;
    }

    #btn-deselect-all { width: 100%; text-align: center; }
}

/* ==========================================
   SELECTOR DE FORMATO (CONVERT TOOL)
   ========================================== */
.format-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 6px;
    border-radius: 14px;
    margin-bottom: 2rem;
    gap: 4px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.format-pill {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-family: 'Outfit';
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--premium-text-light);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.format-pill svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0; /* Evita que el icono desaparezca si el texto es largo en móviles */
}

.format-pill:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--premium-primary);
}

.format-pill.active {
    background: white;
    color: var(--premium-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.format-pill.active svg {
    opacity: 1;
    stroke: currentColor; /* Asegura que el icono tome el color del texto activo */
}

/* Modificadores por tipo */
.format-pill[data-type="word"].active { color: #2b579a; }
.format-pill[data-type="excel"].active { color: #217346; }
.format-pill[data-type="ppt"].active { color: #d24726; }
.format-pill[data-type="image"].active { color: var(--premium-primary); }

@media (max-width: 600px) {
    .format-selector {
        overflow-x: auto;
        justify-content: flex-start;
        padding: 4px;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    .format-selector::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    .format-pill {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
}

