:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;

    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
}


* {
    box-sizing: border-box;
}


body {
    margin: 0;
}


/* ========================================
   BOTONES
======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: .5rem;

    border-radius: .5rem;

    padding: .55rem .8rem;

    font-size: .8rem;
    font-weight: 600;

    transition: .15s ease;
}


.btn-primary {
    color: white;
    background: var(--blue);
}


.btn-primary:hover {
    background: var(--blue-dark);
}


.btn-secondary {
    color: var(--slate-700);

    background: white;

    border: 1px solid var(--slate-200);
}


.btn-secondary:hover {
    background: var(--slate-50);
}



/* ========================================
   READER
======================================== */

.reader-card {
    overflow: hidden;

    border: 1px solid var(--slate-200);

    border-radius: .75rem;

    background: white;

    box-shadow:
        0 10px 30px rgba(15, 23, 42, .06);
}


.reader-toolbar,
.reader-footer {

    min-height: 52px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: .75rem;

    padding: .6rem .75rem;

    border-bottom: 1px solid var(--slate-200);
}


.reader-footer {

    border-top: 1px solid var(--slate-200);

    border-bottom: 0;
}


.tool-btn {

    width: 34px;
    height: 34px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    border: 1px solid var(--slate-200);

    border-radius: .45rem;

    background: white;

    color: var(--slate-700);

    font-weight: 600;

    cursor: pointer;

    transition: .15s ease;
}


.tool-btn:hover {

    background: var(--slate-50);

    border-color: var(--slate-300);
}


.tool-btn:disabled {

    opacity: .35;

    cursor: not-allowed;
}


.page-status {

    color: var(--slate-500);

    font-size: .75rem;

    font-weight: 500;
}



/* ========================================
   BOOK
======================================== */

.book-viewport {

    position: relative;

    min-height: 650px;

    height: min(72vh, 850px);

    display: flex;

    align-items: center;
    justify-content: center;

    overflow: hidden;

    background:
        radial-gradient(
            circle at center,
            #e2e8f0 0,
            #cbd5e1 45%,
            #b8c4d3 100%
        );
}

.book-viewport.zoom-active {
    cursor: grab;
}

.book-viewport.zoom-active:active {
    cursor: grabbing;
}

.book-viewport.zoom-active .book {
    transition: none;
}

/* ========================================
   ÁREA INTERNA PARA ZOOM
======================================== */

.book-zoom-area {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    min-width: 100%;
    min-height: 100%;
}


.book {

    position: relative;

    transform-origin: center center;

    transition: transform .2s ease;
}


.page {

    background: #fff;

    overflow: hidden;
}


.page canvas {

    display: block;

    width: 100%;
    height: 100%;
}



/* ========================================
   EMPTY STATE
======================================== */

.empty-state {

    position: absolute;

    inset: 0;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    background: rgba(248, 250, 252, .94);

    z-index: 10;
}


.empty-icon {

    width: 58px;
    height: 58px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 1rem;

    background: white;

    border: 1px solid var(--slate-200);

    font-size: 1.7rem;

    margin-bottom: .8rem;

    box-shadow:
        0 8px 20px rgba(15, 23, 42, .06);
}



/* ========================================
   LOADING
======================================== */

.loading {

    position: absolute;

    inset: 0;

    z-index: 20;

    display: flex;

    flex-direction: column;

    gap: .75rem;

    align-items: center;
    justify-content: center;

    background: rgba(248, 250, 252, .94);

    color: var(--slate-500);

    font-size: .8rem;
}


.spinner {

    width: 30px;
    height: 30px;

    border: 3px solid var(--slate-200);

    border-top-color: var(--blue);

    border-radius: 50%;

    animation: spin .7s linear infinite;
}


@keyframes spin {

    to {
        transform: rotate(360deg);
    }

}



/* ========================================
   SIDEBAR
======================================== */

.panel {

    overflow: hidden;

    border: 1px solid var(--slate-200);

    border-radius: .75rem;

    background: white;

    box-shadow:
        0 8px 24px rgba(15, 23, 42, .04);
}


.panel-header {

    min-height: 64px;

    padding: .8rem 1rem;

    display: flex;

    align-items: center;

    justify-content: space-between;

    border-bottom: 1px solid var(--slate-200);
}


.panel-title {

    margin: 0;

    color: var(--slate-800);

    font-size: .9rem;

    font-weight: 700;
}


.panel-subtitle {

    margin: .15rem 0 0;

    color: var(--slate-400);

    font-size: .7rem;
}


.status-dot {

    color: #22c55e;

    font-size: .65rem;
}



/* ========================================
   CHAT
======================================== */

.chat-messages {

    height: 260px;

    overflow-y: auto;

    padding: .9rem;

    background: var(--slate-50);
}


.chat-bubble {

    max-width: 88%;

    padding: .65rem .75rem;

    margin-bottom: .55rem;

    border-radius: .75rem;

    font-size: .76rem;

    line-height: 1.45;
}


.chat-bubble.bot {

    margin-right: auto;

    background: white;

    border: 1px solid var(--slate-200);

    color: var(--slate-700);
}


.chat-bubble.user {

    margin-left: auto;

    background: var(--blue);

    color: white;
}


.chat-suggestions {

    display: flex;

    flex-wrap: wrap;

    gap: .35rem;

    padding: .65rem .75rem;

    border-top: 1px solid var(--slate-200);
}


.suggestion {

    border: 1px solid var(--slate-200);

    background: white;

    color: var(--slate-500);

    border-radius: 999px;

    padding: .35rem .55rem;

    font-size: .65rem;

    cursor: pointer;
}


.suggestion:hover {

    background: var(--slate-50);

    color: var(--slate-700);
}


.chat-input-wrap {

    display: flex;

    gap: .4rem;

    padding: .7rem;

    border-top: 1px solid var(--slate-200);
}


.chat-input {

    min-width: 0;

    flex: 1;

    border: 1px solid var(--slate-200);

    border-radius: .5rem;

    padding: .55rem .65rem;

    outline: none;

    font-size: .75rem;
}


.chat-input:focus {

    border-color: #93c5fd;

    box-shadow:
        0 0 0 3px rgba(59, 130, 246, .08);
}


.send-btn {

    width: 35px;

    border: 0;

    border-radius: .5rem;

    background: var(--blue);

    color: white;

    cursor: pointer;
}



/* ========================================
   AUDIO
======================================== */

.chapter-list {

    padding: .6rem;

    max-height: 230px;

    overflow-y: auto;
    /*display: none;*/
}


.chapter {

    display: flex;

    align-items: center;

    gap: .65rem;

    width: 100%;

    padding: .65rem;

    border: 1px solid transparent;

    border-radius: .55rem;

    background: white;

    text-align: left;

    cursor: pointer;
}


.chapter:hover {

    background: var(--slate-50);
}


.chapter.active {

    background: #eff6ff;

    border-color: #bfdbfe;
}


.chapter-number {

    width: 28px;
    height: 28px;

    flex: 0 0 28px;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: .45rem;

    background: var(--slate-100);

    color: var(--slate-500);

    font-size: .7rem;

    font-weight: 700;
}


.chapter.active .chapter-number {

    background: var(--blue);

    color: white;
}


.chapter-name {

    font-size: .75rem;

    font-weight: 600;

    color: var(--slate-700);
}


.chapter-duration {

    margin-left: auto;

    color: var(--slate-400);

    font-size: .65rem;
}


.audio-player {

    margin: .4rem .7rem .7rem;

    padding: .8rem;

    border: 1px solid var(--slate-200);

    border-radius: .65rem;

    background: var(--slate-50);
    /*display: none;*/
}


.play-btn {

    width: 38px;
    height: 38px;

    border: 0;

    border-radius: 50%;

    background: var(--blue);

    color: white;

    cursor: pointer;
}


.audio-range {

    width: 100%;

    accent-color: var(--blue);
}



/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 1279px) {

    .book-viewport {

        height: 68vh;

        min-height: 560px;
    }

}


@media (max-width: 640px) {

    .reader-toolbar,
    .reader-footer {

        flex-wrap: wrap;
    }


    .book-viewport {

        min-height: 470px;

        height: 65vh;
    }

}

.chat-page-link {
    color: #2563eb;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.chat-page-link:hover {
    color: #1d4ed8;
}

.chat-page-link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
    border-radius: 3px;
}

.chat-bubble.bot {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.chat-bubble.bot strong {
    font-weight: 700;
}

/* ========================================
   MENSAJE DE BIENVENIDA DE JULIETTE
======================================== */

.chat-bubble.bot.chat-welcome {
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.6;
}

.chat-welcome p {
    margin: 0.6rem 0 0;
}

.chat-welcome strong {
    font-weight: 700;
}

/* ========================================
   JULIETTE - INDICADOR DE ESCRITURA
======================================== */

.chat-typing {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;

    font-size: 12px;
    color: #64748b;

    white-space: normal !important;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;

    background: #64748b;
    border-radius: 50%;

    animation: julietteTyping 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes julietteTyping {

    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .typing-dots span {
        animation: none;
    }
}

/* ========================================
   JULIETTE - LISTAS EN LAS RESPUESTAS
======================================== */

.chat-bubble.bot .juliette-list {
    margin: 0.45rem 0;
    padding-left: 1.3rem;
    white-space: normal;
}

.chat-bubble.bot ul.juliette-list {
    list-style-type: disc;
}

.chat-bubble.bot ol.juliette-list {
    list-style-type: decimal;
}

.chat-bubble.bot .juliette-list li {
    margin-bottom: 0.35rem;
    line-height: 1.6;
}

.chat-bubble.bot .juliette-list li:last-child {
    margin-bottom: 0;
}

/* ========================================
   JULIETTE - FORMATO DE LISTAS
======================================== */

/* Separación entre elementos de la lista */
.chat-bubble.bot .juliette-list li {
    margin-bottom: 12px;
    line-height: 1.7;
}

/* Números y viñetas en negritas */
.chat-bubble.bot .juliette-list li::marker {
    font-weight: 700;
}

/* Separación de la lista respecto al texto */
.chat-bubble.bot .juliette-list {
    margin-top: 12px;
    margin-bottom: 16px;
    padding-left: 1.5rem;
}

/* Separación entre párrafos normales */
.chat-bubble.bot .juliette-paragraph {
    margin-bottom: 10px;
    line-height: 1.7;
}

