/* ============================================================
   OMNICONVERT PRO — styles.css
   Interfaz rediseñada: glassmorphism, gradientes y micro-interacciones
   ============================================================ */

/* ------------------------------------------------------------
   VARIABLES GLOBALES DE TEMA
   ------------------------------------------------------------ */
:root {
    --brand-1: #6366f1;   /* indigo  */
    --brand-2: #8b5cf6;   /* violet  */
    --brand-3: #ec4899;   /* pink    */
    --ink:     #0f172a;
    --ink-soft:#475569;
    --line:    #e2e8f0;
    --line-soft:#eef2f7;
}

/* ------------------------------------------------------------
   FONDO: malla de gradientes animada + grid sutil
   ------------------------------------------------------------ */
.grid-bg {
    position: relative;
    background-color: #eef2ff;
    background-image:
        radial-gradient(circle at 18% 18%, rgba(99,102,241,0.18), transparent 42%),
        radial-gradient(circle at 82% 12%, rgba(236,72,153,0.16), transparent 40%),
        radial-gradient(circle at 75% 85%, rgba(139,92,246,0.18), transparent 45%),
        radial-gradient(circle at 25% 80%, rgba(16,185,129,0.14), transparent 42%),
        radial-gradient(#c7d2fe 1px, transparent 1px);
    background-size:
        100% 100%,
        100% 100%,
        100% 100%,
        100% 100%,
        26px 26px;
    background-attachment: fixed;
}

/* Manchas de color que se desplazan lentamente */
.grid-bg::before {
    content: "";
    position: fixed;
    inset: -20%;
    z-index: -1;
    background:
        radial-gradient(closest-side, rgba(99,102,241,0.25), transparent),
        radial-gradient(closest-side, rgba(236,72,153,0.22), transparent),
        radial-gradient(closest-side, rgba(16,185,129,0.20), transparent);
    background-size: 55vmax 55vmax, 45vmax 45vmax, 40vmax 40vmax;
    background-position:
        0% 0%,
        90% 10%,
        50% 100%;
    background-repeat: no-repeat;
    animation: meshFloat 22s ease-in-out infinite alternate;
    filter: blur(40px);
    pointer-events: none;
}
@keyframes meshFloat {
    0%   { transform: translate3d(-3%, -2%, 0) rotate(0deg);   }
    100% { transform: translate3d(3%,  3%, 0)  rotate(8deg);   }
}

/* ------------------------------------------------------------
   GLASS PANEL (tarjetas con efecto cristal)
   ------------------------------------------------------------ */
.glass-panel,
.glass-card {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.6) inset,
        0 10px 30px -12px rgba(30,41,59,0.18),
        0 2px 6px -2px rgba(30,41,59,0.08);
}

/* ------------------------------------------------------------
   HEADER — LOGO CON DEGRADADO
   ------------------------------------------------------------ */
.brand-logo {
    background: linear-gradient(120deg, var(--brand-1), var(--brand-2) 55%, var(--brand-3));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-chip {
    background: linear-gradient(120deg, rgba(99,102,241,0.12), rgba(236,72,153,0.12));
    border: 1px solid rgba(99,102,241,0.18);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px -2px rgba(99,102,241,0.25);
}
.brand-chip.emerald { background: linear-gradient(120deg, rgba(16,185,129,0.14), rgba(5,150,105,0.12)); border-color: rgba(16,185,129,0.22); box-shadow: 0 2px 8px -2px rgba(16,185,129,0.25); }
.brand-chip.amber   { background: linear-gradient(120deg, rgba(245,158,11,0.14), rgba(217,119,6,0.12));  border-color: rgba(245,158,11,0.24);  box-shadow: 0 2px 8px -2px rgba(245,158,11,0.28); }

/* ------------------------------------------------------------
   SIDEBAR — CONTENEDOR CON SCROLL VERTICAL
   ------------------------------------------------------------ */
.sidebar-scroll {
    display: flex;
    flex-direction: column;
    max-height: 78vh;           /* Limita la altura al viewport */
    overflow: hidden;
}
.sidebar-scroll #format-selectors {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* ------------------------------------------------------------
   SIDEBAR — BOTONES DE FORMATO
   ------------------------------------------------------------ */
#format-selectors {
    scrollbar-width: thin;
    scrollbar-color: #c7d2fe transparent;
    padding-right: 4px;
    gap: 0.4rem;
    align-content: flex-start;
}
#format-selectors::-webkit-scrollbar { width: 6px; }
#format-selectors::-webkit-scrollbar-track { background: transparent; }
#format-selectors::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--brand-1), var(--brand-2));
    border-radius: 99px;
}

.format-btn {
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
    flex-shrink: 0;
    min-height: 2.75rem;
    line-height: 1.4;
    transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease, color .2s ease, border-color .2s ease;
}
.format-btn::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(var(--brand-1), var(--brand-3));
    transform: scaleY(0);
    transform-origin: center;
    transition: transform .25s ease;
}
.format-btn:hover {
    transform: translateX(2px);
    background: rgba(99,102,241,0.06);
}
.format-btn:hover::before { transform: scaleY(0.5); }

/* Estado activo del botón de formato */
.format-btn.active {
    background: linear-gradient(120deg, rgba(99,102,241,0.12), rgba(236,72,153,0.10));
    color: #4338ca;
    border: 1px solid rgba(99,102,241,0.30);
    box-shadow: 0 6px 18px -8px rgba(99,102,241,0.55);
}
.format-btn.active::before { transform: scaleY(1); }

.format-separator {
    font-size: 0.65rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 0.55rem 0.25rem 0.25rem;
    border-top: 1px dashed #e2e8f0;
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    line-height: 1.4;
}
.format-separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, #e2e8f0, transparent);
}
.format-separator:first-child { border-top: none; margin-top: 0; }

/* ------------------------------------------------------------
   ZONA DE CARGA (DROP ZONE)
   ------------------------------------------------------------ */
#drop-zone {
    position: relative;
    background:
        linear-gradient(rgba(255,255,255,0.85), rgba(255,255,255,0.92)),
        linear-gradient(120deg, rgba(99,102,241,0.08), rgba(236,72,153,0.08));
    background-blend-mode: normal;
    border: 2px dashed transparent;
    border-image: linear-gradient(120deg, var(--brand-1), var(--brand-3)) 1;
    transition: transform .25s ease, box-shadow .25s ease, background-color .25s ease;
    box-shadow: 0 10px 30px -16px rgba(99,102,241,0.40);
}
/* fallback para navegadores sin border-image */
#drop-zone { border: 2px dashed #c7d2fe; }

#drop-zone:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px -18px rgba(99,102,241,0.55);
}
#drop-zone:hover .drop-icon-wrap {
    transform: translateY(-4px) scale(1.05);
}
.drop-icon-wrap {
    width: 84px; height: 84px;
    margin: 0 auto;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(236,72,153,0.15));
    box-shadow:
        0 0 0 8px rgba(99,102,241,0.06),
        0 10px 25px -10px rgba(99,102,241,0.45);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.drop-icon-wrap svg {
    animation: floaty 3.5s ease-in-out infinite;
}
@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}

/* ------------------------------------------------------------
   BARRA DE HERRAMIENTAS DE EXPORTACIÓN
   ------------------------------------------------------------ */
#export-toolbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(14px);
    box-shadow: 0 8px 24px -16px rgba(30,41,59,0.25);
}
#file-name-display {
    background: linear-gradient(120deg, rgba(99,102,241,0.10), rgba(236,72,153,0.08));
    border: 1px solid rgba(99,102,241,0.18);
}
#export-buttons button {
    position: relative;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
    box-shadow: 0 6px 14px -8px rgba(30,41,59,0.45);
}
#export-buttons button:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
    box-shadow: 0 10px 22px -10px rgba(30,41,59,0.55);
}
#export-buttons button:active { transform: translateY(0); }

/* ------------------------------------------------------------
   ÁREA DE VISTA PREVIA
   ------------------------------------------------------------ */
#preview-wrapper {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 40px -20px rgba(30,41,59,0.30);
    animation: rise .45s cubic-bezier(.22,1,.36,1);
}
@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
#preview-wrapper > div:first-child {
    background: linear-gradient(120deg, #1e293b, #312e81 60%, #6d28d9);
    position: relative;
    overflow: hidden;
}
#preview-wrapper > div:first-child::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 85% 20%, rgba(236,72,153,0.35), transparent 45%);
    pointer-events: none;
}

/* Prose Document Styles */
.prose-doc table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.prose-doc th, .prose-doc td { border: 1px solid #e2e8f0; padding: 0.5rem; }
.prose-doc th { background-color: #f8fafc; text-align: left; }

/* Editable Cells */
[contenteditable="true"]:focus {
    outline: 2px solid #6366f1;
    background-color: #eef2ff;
    border-radius: 4px;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}

/* ============================================================
   IMAGE PREVIEW
   ============================================================ */
#preview-content img.img-preview {
    max-width: 100%;
    max-height: 520px;
    height: auto;
    border-radius: 14px;
    display: block;
    margin: 0 auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.image-meta {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: #64748b;
    font-weight: 600;
}

/* ============================================================
   PPTX SLIDE PREVIEW
   ============================================================ */
.slide-container {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.slide {
    background: white;
    border: 1px solid #e2e8f0;
    border-left: 4px solid transparent;
    border-image: linear-gradient(var(--brand-1), var(--brand-3)) 1;
    border-radius: 12px;
    padding: 1.75rem 2rem;
    min-height: 140px;
    position: relative;
    box-shadow: 0 4px 14px -8px rgba(30,41,59,0.20);
    transition: transform .22s ease, box-shadow .22s ease;
}
.slide { border-left: 4px solid #6366f1; }
.slide:hover {
    transform: translateX(4px);
    box-shadow: 0 14px 30px -12px rgba(99,102,241,0.30);
}
.slide-number {
    position: absolute;
    top: 0.6rem;
    right: 0.9rem;
    font-size: 10px;
    color: #6366f1;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: linear-gradient(120deg, rgba(99,102,241,0.12), rgba(236,72,153,0.10));
    padding: 3px 10px;
    border-radius: 99px;
    border: 1px solid rgba(99,102,241,0.18);
}
.slide-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.65rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.slide-body {
    color: #475569;
    font-size: 0.875rem;
    line-height: 1.75;
    white-space: pre-wrap;
}

/* ============================================================
   PDF LAYOUT PREVIEW (imagen + overlay texto seleccionable)
   ============================================================ */
.pdf-layout {
    max-width: 100%;
    overflow-x: auto;
}
.pdf-page {
    page-break-inside: avoid;
    break-inside: avoid;
    pointer-events: none;
}
.pdf-page img {
    pointer-events: auto;
    transition: box-shadow .22s ease;
}
.pdf-page:hover img {
    box-shadow: 0 8px 28px rgba(99,102,241,0.25) !important;
}
.pdf-text-overlay {
    pointer-events: none;
}
.pdf-text-overlay span {
    pointer-events: auto;
    user-select: text;
}

/* ============================================================
   PDF WARNING NOTICE
   ============================================================ */
.mode-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: linear-gradient(120deg, #fef9c3, #fef3c7);
    border: 1px solid #f59e0b;
    border-radius: 0.75rem;
    padding: 0.7rem 1rem;
    font-size: 0.74rem;
    color: #78350f;
    font-weight: 600;
    margin-top: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 6px 16px -8px rgba(245,158,11,0.45);
}
.mode-warning .warn-icon { font-size: 0.95rem; flex-shrink: 0; margin-top: 0.05rem; }

/* ============================================================
   EPUB CONTENT
   ============================================================ */
.epub-content {
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.95;
    color: #1e293b;
    font-size: 0.95rem;
}
.epub-content h1, .epub-content h2, .epub-content h3 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #0f172a;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
    font-weight: 800;
}
.epub-content p { margin-bottom: 1rem; }
.epub-content img { max-width: 100%; height: auto; border-radius: 6px; }
.epub-content hr { border: none; border-top: 1px solid #e2e8f0; margin: 2rem 0; }

/* ============================================================
   JSON FORMATTED VIEW
   ============================================================ */
.json-view {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.65;
    background: #0f172a;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    color: #e2e8f0;
    border: 1px solid #1e293b;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
}

/* ============================================================
   LOADING ANIMATION
   ============================================================ */
@keyframes pulse-slow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.98); }
}
.animate-pulse-slow { animation: pulse-slow 1.5s ease-in-out infinite; }

/* Spinner de carga */
.loader-dots {
    display: inline-flex;
    gap: 6px;
    margin-right: 8px;
    vertical-align: middle;
}
.loader-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--brand-1);
    animation: bounceDot 1.2s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { background: var(--brand-2); animation-delay: .15s; }
.loader-dots span:nth-child(3) { background: var(--brand-3); animation-delay: .3s; }
@keyframes bounceDot {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40%           { transform: translateY(-7px); opacity: 1; }
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(226,232,240,0.7);
}
footer p {
    background: linear-gradient(120deg, var(--ink-soft), var(--brand-1));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================================
   ENTRADA DE ELEMENTOS (animación inicial)
   ============================================================ */
.anim-in { animation: rise .5s cubic-bezier(.22,1,.36,1) both; }
.anim-in.delay-1 { animation-delay: .05s; }
.anim-in.delay-2 { animation-delay: .12s; }
.anim-in.delay-3 { animation-delay: .2s; }

/* ============================================================
   SCROLLBAR GLOBAL SUTIL
   ============================================================ */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .drop-icon-wrap { width: 68px; height: 68px; }
    #preview-wrapper > div:first-child { font-size: 11px; }
}

/* ============================================================
   ESTILOS DE IMPRESIÓN (PDF desde navegador)
   ============================================================ */
@media print {
    /* Reset fondo y márgenes */
    html, body {
        background: #ffffff !important;
        margin: 0;
        padding: 0;
    }

    /* Ocultar todo excepto la vista previa */
    .grid-bg::before,
    header,
    footer,
    aside,
    #drop-zone,
    #export-toolbar,
    .sidebar-scroll,
    #mode-warning {
        display: none !important;
    }

    /* Asegurar que el wrapper ocupe todo */
    #preview-wrapper {
        display: block !important;
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        backdrop-filter: none;
        animation: none;
        overflow: visible;
    }

    #preview-wrapper > div:first-child {
        background: transparent !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Contenido sin límite de altura para imprimir todo */
    #preview-content {
        overflow: visible !important;
        max-height: none !important;
        padding: 0 !important;
    }

    /* Tablas se imprimen completas */
    #preview-content table {
        page-break-inside: auto;
        width: 100%;
    }
    #preview-content tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* Slides, pdf y epub se imprimen con saltos de página */
    #preview-content .slide,
    #preview-content .pdf-page,
    #preview-content .epub-content hr {
        page-break-after: always;
    }

    /* Imágenes ajustadas al ancho de página */
    #preview-content img {
        max-width: 100% !important;
        max-height: auto !important;
        page-break-inside: avoid;
    }

    /* Forzar colores de fondo en impresión */
    .format-btn.active,
    th, td,
    .slide {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
