:root {
    --bg-color: #0f172a; /* Slate 900 */
    --panel-bg: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    --accent: #8b5cf6; /* Violet 500 */
    --accent-hover: #7c3aed; /* Violet 600 */
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 15px;
    width: 100%;
}

/* Background Animations */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: rgba(139, 92, 246, 0.4);
    top: -100px;
    left: -100px;
    animation: float 10s ease-in-out infinite alternate;
}

.shape-2 {
    width: 500px;
    height: 500px;
    background: rgba(56, 189, 248, 0.3);
    bottom: -150px;
    right: -100px;
    animation: float 12s ease-in-out infinite alternate-reverse;
}

@keyframes float {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(50px) scale(1.1); }
}

/* Container & UI */
.app-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    z-index: 1;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 2.5rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #a78bfa, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-group input {
    width: 100%;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

.primary-btn {
    width: 100%;
    padding: 1.2rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 1rem;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--accent);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loader animado */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.status-msg {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
    min-height: 20px;
}

/* ==========================================================================
   ESTILOS PARA O E-BOOK / PDF (Invisível na tela, apenas para exportação)
   ========================================================================== */
   
.ebook-document {
    width: 794px; /* Largura A4 em 96 DPI */
    background: white;
    color: #1e293b;
    font-family: 'Outfit', Arial, sans-serif;
}

.ebook-page {
    width: 794px;
    position: relative;
    overflow: hidden;
}

/* Página de Capa Premium */
.cover-page {
    width: 100%;
    aspect-ratio: 1 / 1.414; /* Proporção exata da folha A4 */
    background: linear-gradient(135deg, #0f172a 0%, #312e81 50%, #4c1d95 100%);
    background-size: cover;
    background-position: center;
    position: relative;
    page-break-after: always; /* A capa sempre preenche exatamente 1 folha */
}

.cover-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(circle at 50% 0%, rgba(139, 92, 246, 0.5) 0%, transparent 60%);
    z-index: 0;
}

.cover-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    padding: 60px 40px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 30px;
    width: 80%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.cover-content h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    line-height: 1.2;
    background: linear-gradient(to right, #ffffff, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.cover-content p {
    font-size: 1.4rem;
    font-weight: 300;
    color: #cbd5e1;
}

/* Páginas de Conteúdo (Markdown) */
.content-page {
    padding: 60px 80px;
    height: auto; 
    min-height: 1123px;
    page-break-after: auto;
    background: white;
}

.markdown-body {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #334155;
}

/* REGRAS CRÍTICAS PARA NÃO CORTAR TEXTO NAS PÁGINAS */
.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body p, 
.markdown-body li {
    page-break-inside: avoid; /* Evita que a linha corte no meio */
    break-inside: avoid;
}

.markdown-body h1 {
    font-size: 2.5rem;
    color: #0f172a;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    -webkit-text-fill-color: #0f172a;
    /* REMOVIDO page-break-before para evitar páginas em branco duplicadas */
}

.markdown-body h2 {
    font-size: 2rem;
    color: #1e293b;
    margin-top: 0;
    margin-bottom: 1rem;
    page-break-before: always; /* Força CADA DICA/CAPÍTULO a começar numa folha separada */
    padding-top: 40px; /* Garante que o texto não cole no topo da nova página */
}

.markdown-body h3 {
    font-size: 1.5rem;
    color: #475569;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
}

.markdown-body p {
    margin-bottom: 1.2rem;
}

/* ==========================================================================
   TELA DE INICIALIZAÇÃO (SPLASH SCREEN)
   ========================================================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.splash-content {
    text-align: center;
    animation: fadeIn 1s ease-in-out;
}

.splash-icon {
    font-size: 6rem;
    animation: bounce 2s infinite;
}

.splash-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-top: 15px;
    background: linear-gradient(to right, #38bdf8, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.splash-subtitle {
    font-size: 1.2rem;
    color: #cbd5e1;
    margin-top: 10px;
    opacity: 0.8;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

@keyframes fadeIn {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-30px); }
    60% { transform: translateY(-15px); }
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.2rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body strong {
    color: #0f172a;
}
