/* style.css - Estilos globais da plataforma Essência */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #3b5998;
    --secondary-color: #8b9dc3;
    --text-color: #333333;
    --text-light: #555555;
    --bg-color: #fcfcfc;
    --bg-alt: #f1f5f9;
    --border-color: #e2e8f0;
    --hover-color: #f8fafc;
    --font-family: 'Inter', sans-serif;
    --content-font-size: 1.1rem;
    --chapter-content-width: 900px;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --tooltip-bg: #2d3748;
    --tooltip-text: #f7fafc;
    --violet-accent: #8a2be2;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

h1, h2, h3, h4 {
    color: var(--primary-color);
    margin-top: 0;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.w-100 { width: 100%; }
.mb-1 { margin-bottom: 1rem; }
.mt-1 { margin-top: 1rem; }

/* Botões */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}
.btn-primary:hover {
    background-color: #2d4373;
}

.btn-secondary {
    background-color: #cbd5e1;
    color: #333;
}
.btn-secondary:hover {
    background-color: #94a3b8;
}

.btn-danger {
    background-color: #ef4444;
    color: #fff;
}
.btn-danger:hover {
    background-color: #dc2626;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-light);
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-family);
    font-size: 1rem;
}

/* Tabelas */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    background-color: var(--bg-alt);
    color: var(--text-light);
}

/* -------------------------------------------
   FRONTEND - PÚBLICO
--------------------------------------------- */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--bg-alt);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
}
.sidebar-header h1 {
    color: white;
    font-size: 1.25rem;
    margin: 0 0 1rem 0;
}
.search-input {
    width: 100%;
    padding: 0.5rem;
    border-radius: 4px;
    border: none;
    outline: none;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.chapter-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-nav-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 400;
}

.chapter-nav-item:hover, .chapter-nav-item.active {
    background-color: #e2e8f0;
    color: var(--primary-color);
    font-weight: 600;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 50;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    background-color: var(--bg-color);
}

.reader-container {
    max-width: calc(var(--chapter-content-width) + 4rem);
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.reader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.font-controls button {
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    margin-left: 0.5rem;
    font-size: 1.1rem;
}

.chapter-title {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.chapter-body {
    font-size: var(--content-font-size);
    color: var(--text-color);
    transition: font-size 0.3s;
    padding: 0;
    max-width: var(--chapter-content-width);
    width: 100%;
    margin: 0 auto;
}

.chapter-body h1,
.chapter-body h2,
.chapter-body h3 {
    color: var(--primary-color);
}

.reader-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* -------------------------------------------
   TEXTOS BÍBLICOS - INTERATIVIDADE
--------------------------------------------- */
.biblical-reference {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px dashed var(--primary-color);
    position: relative;
}

.biblical-reference:hover {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

/* Popup / Tooltip */
.verse-tooltip {
    position: fixed;
    background-color: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    width: 450px;
    max-width: 90vw;
    z-index: 1000;
    font-size: 1rem;
    line-height: 1.5;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Evita vazamento de texto em qualquer cenário */
}

.verse-tooltip.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Quando "travado" com Shift */
.verse-tooltip.locked {
    pointer-events: auto;
    resize: both;
}

.verse-tooltip.maximized {
    top: 5vh !important;
    left: 5vw !important;
    width: 90vw !important;
    max-width: 90vw;
    height: 90vh;
    max-height: 90vh;
}

.verse-tooltip.maximized .verse-tooltip-content {
    max-height: none;
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    background: linear-gradient(135deg, #1f2937 0%, #243244 100%);
    cursor: grab;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    touch-action: none; /* Impede scroll da página ao arrastar o cabeçalho */
    flex-shrink: 0;
}

.verse-tooltip.locked .tooltip-header {
    display: flex;
}

.tooltip-header:active {
    cursor: grabbing;
}

.tooltip-drag-label {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.78;
    user-select: none;
    color: #d7dfeb;
    flex-grow: 1;
}

.popup-maximize, .tooltip-close {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    color: #f2f6fd;
    padding: 0;
    margin-left: 8px;
    transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.popup-maximize:hover, .tooltip-close:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.popup-maximize:active, .tooltip-close:active {
    transform: translateY(0);
}

.verse-tooltip-content {
    overflow-y: auto;
    overscroll-behavior: contain; /* Impede scroll bleed */
    -webkit-overflow-scrolling: touch; /* Scroll suave iOS */
    flex: 1;
    min-height: 50px;
    max-height: 50vh; /* Altura máxima baseada na tela para forçar a barra de rolagem */
    margin-right: -0.5rem;
    padding-right: 0.5rem;
    word-wrap: break-word;
    scrollbar-width: thin; /* Para Firefox */
    scrollbar-color: #4a5568 transparent;
}

/* Custom scrollbar para o tooltip */
.verse-tooltip-content::-webkit-scrollbar {
    width: 6px;
}
.verse-tooltip-content::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 3px;
}

.tooltip-close {
    font-size: 1.1rem;
}

/* Formatação de números dentro do popup */
.verse-tooltip .verse-number {
    vertical-align: super;
    font-size: 0.75em;
    font-weight: bold;
    color: var(--violet-accent);
    margin-right: 2px;
}

/* Responsivo */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        height: 100%;
        z-index: 40;
    }
    
    .sidebar.open {
        transform: translateX(300px);
    }
    
    .mobile-toggle {
        display: block;
    }
    
    .reader-container {
        padding: 4rem 1rem 2rem 1rem;
    }
    
    .verse-tooltip {
        max-width: 90vw;
    }
}
