/*
Theme Name: Bíblia Alpha de Estudo
Theme URI: https://bibliaalpha.studiologos.com.br
Description: Plataforma de estudo bíblico — leitura integrada com ferramentas
Author: Studio Logos
Version: 3.0.0
Text Domain: bibliaalpha
*/

/* ══════ TOKENS ══════ */
:root {
    --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-reading: "Source Serif 4", "Georgia", "Cambria", "Times New Roman", serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --bg: #ffffff;
    --bg-secondary: #f7f6f3;
    --bg-hover: #f1f1ef;
    --bg-active: #ededec;
    --surface: #ffffff;

    --text: #37352f;
    --text-secondary: #73726e;
    --text-tertiary: #9b9a97;
    --text-placeholder: #c4c4c0;

    --border: #e9e9e7;
    --border-strong: #dbdbd7;
    --divider: #ebebea;

    --accent: #b8941f;
    --accent-bg: #faf5e4;
    --accent-hover: #a07d18;

    --blue: #2eaadc;
    --blue-bg: #e7f3f8;
    --red: #e03e3e;
    --red-bg: #fbe4e4;
    --green: #4dab5c;
    --green-bg: #ddf3e4;
    --orange: #cb912f;

    --radius: 3px;
    --radius-md: 6px;
    --shadow-sm: 0 1px 2px rgba(55,53,47,0.04);
    --shadow: 0 1px 3px rgba(55,53,47,0.04), 0 0 0 1px rgba(55,53,47,0.03);
    --shadow-md: 0 4px 12px rgba(55,53,47,0.08), 0 0 0 1px rgba(55,53,47,0.03);
    --shadow-lg: 0 12px 32px rgba(55,53,47,0.12);

    --sidebar-w: 240px;
    --panel-w: 340px;
    --toolbar-h: 44px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 150ms;

    --verse-num-color: var(--accent);
}

/* ══════ RESET ══════ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size:16px; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }
body { font-family:var(--font); color:var(--text); background:var(--bg); line-height:1.5; overflow:hidden; height:100vh; }
a { color:inherit; text-decoration:none; }
button { font:inherit; color:inherit; background:none; border:none; cursor:pointer; }
input, textarea, select { font:inherit; color:inherit; }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:var(--radius); }

/* ══════ APP SHELL — 3 panes ══════ */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr 0px;
    grid-template-rows: var(--toolbar-h) 1fr;
    height: 100vh;
    transition: grid-template-columns 200ms var(--ease);
}
.app.panel-open {
    grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
}
.app.sidebar-collapsed {
    grid-template-columns: 0px 1fr 0px;
}
.app.sidebar-collapsed.panel-open {
    grid-template-columns: 0px 1fr var(--panel-w);
}

/* ══════ TOOLBAR ══════ */
.toolbar {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 12px;
    height: var(--toolbar-h);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    z-index: 20;
    user-select: none;
}
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
    flex-shrink: 0;
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text); }
.toolbar-btn.active { background: var(--bg-active); color: var(--text); }
.toolbar-btn svg { width:18px; height:18px; }

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 6px;
    flex-shrink: 0;
}

.toolbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 4px;
    min-width: 0;
}
.toolbar-breadcrumb span { white-space: nowrap; }
.toolbar-breadcrumb .current { color: var(--text); font-weight: 500; }
.toolbar-breadcrumb .sep { color: var(--text-tertiary); font-size: 11px; }

.toolbar-spacer { flex: 1; }

.toolbar-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid transparent;
    font-size: 13px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}
.toolbar-search:hover { border-color: var(--border); background: var(--bg-hover); }
.toolbar-search svg { width:14px; height:14px; opacity:0.6; }
.toolbar-search kbd {
    font-family: var(--font);
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ══════ SIDEBAR — Book Navigation ══════ */
.sidebar {
    grid-row: 2;
    grid-column: 1;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    transition: opacity 200ms var(--ease);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.sidebar-collapsed .sidebar { opacity: 0; pointer-events: none; overflow: hidden; }

.sidebar-section-label {
    padding: 16px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 14px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 0;
    transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
    min-height: 30px;
    line-height: 1.3;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-item.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.sidebar-item .abbr {
    display: inline-block;
    width: 32px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    flex-shrink: 0;
    text-transform: uppercase;
}
.sidebar-item.active .abbr { color: var(--accent); }

.sidebar-chapters {
    display: none;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px 14px 8px 54px;
}
.sidebar-item.expanded + .sidebar-chapters { display: flex; }
.ch-btn {
    width: 28px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: var(--radius);
    transition: all var(--duration) var(--ease);
}
.ch-btn:hover { background: var(--bg-hover); color: var(--text); }
.ch-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ══════ MAIN — Bible Reader ══════ */
.reader {
    grid-row: 2;
    grid-column: 2;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.reader::-webkit-scrollbar { width: 6px; }
.reader::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.reader-inner {
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 48px 120px;
}

.reader-title {
    font-family: var(--font);
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.reader-subtitle {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 32px;
}

.reader-text {
    font-family: var(--font-reading);
    font-size: 18px;
    line-height: 1.85;
    color: var(--text);
}
.reader-text .v {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
    color: var(--verse-num-color);
    vertical-align: super;
    margin-right: 2px;
    cursor: default;
    user-select: none;
    opacity: 0.8;
}
.reader-text .verse {
    cursor: pointer;
    border-radius: 2px;
    transition: background var(--duration) var(--ease);
    padding: 1px 0;
}
.reader-text .verse:hover { background: var(--accent-bg); }
.reader-text .verse.selected { background: var(--accent-bg); }
.reader-text .verse.highlighted {
    background: #fff3bf;
    border-bottom: 2px solid var(--accent);
}

.reader-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--divider);
}
.reader-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--duration) var(--ease);
}
.reader-nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.reader-nav-btn svg { width: 14px; height: 14px; }

/* ══════ VERSE TOOLBAR (appears on selection) ══════ */
.verse-toolbar {
    display: none;
    position: fixed;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    gap: 2px;
}
.verse-toolbar.visible { display: flex; }
.verse-toolbar button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: var(--radius);
    white-space: nowrap;
    transition: all var(--duration) var(--ease);
}
.verse-toolbar button:hover { background: var(--bg-hover); color: var(--text); }
.verse-toolbar button svg { width: 13px; height: 13px; }

/* ══════ RIGHT PANEL ══════ */
.panel {
    grid-row: 2;
    grid-column: 3;
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 200ms var(--ease);
}
.app:not(.panel-open) .panel { opacity:0; pointer-events:none; }

.panel-header {
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 40px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}
.panel-tabs {
    display: flex;
    gap: 0;
    flex: 1;
    min-width: 0;
}
.panel-tab {
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    border-bottom: 2px solid transparent;
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}
.panel-tab:hover { color: var(--text-secondary); }
.panel-tab.active { color: var(--text); border-bottom-color: var(--text); }

.panel-close {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.panel-close:hover { background: var(--bg-hover); color: var(--text); }
.panel-close svg { width: 14px; height: 14px; }

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.panel-body::-webkit-scrollbar { width: 5px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.panel-section { display: none; }
.panel-section.active { display: block; }

/* Panel: Notes */
.note-card {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.note-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.note-card-title { font-size: 13px; font-weight: 500; margin-bottom: 2px; }
.note-card-preview { font-size: 12px; color: var(--text-tertiary); line-height: 1.4; }
.note-card-date { font-size: 11px; color: var(--text-placeholder); margin-top: 4px; }

.note-editor { display: none; }
.note-editor.active { display: flex; flex-direction: column; height: 100%; }
.note-editor-title {
    width: 100%;
    border: none;
    font-size: 16px;
    font-weight: 600;
    padding: 0 0 8px;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 8px;
    background: transparent;
}
.note-editor-title:focus { outline: none; border-bottom-color: var(--accent); }
.note-editor-body {
    flex: 1;
    width: 100%;
    border: none;
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    background: transparent;
}
.note-editor-body:focus { outline: none; }
.note-editor-actions {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--divider);
    margin-top: 8px;
}

/* Panel: Search */
.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    transition: border-color var(--duration) var(--ease);
}
.search-input-wrap:focus-within { border-color: var(--accent); }
.search-input-wrap svg { width: 15px; height: 15px; color: var(--text-tertiary); flex-shrink: 0; }
.search-input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
}
.search-input-wrap input:focus { outline: none; }
.search-input-wrap input::placeholder { color: var(--text-placeholder); }

.search-result {
    padding: 8px 0;
    border-bottom: 1px solid var(--divider);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}
.search-result:hover { background: var(--bg-hover); margin: 0 -16px; padding: 8px 16px; }
.search-result-ref { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.search-result-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.search-result-text mark { background: var(--accent-bg); color: var(--text); font-weight: 500; border-radius: 2px; padding: 0 1px; }
.search-count { font-size: 12px; color: var(--text-tertiary); margin-bottom: 12px; }
.search-empty { text-align: center; padding: 32px 0; color: var(--text-tertiary); font-size: 13px; }

/* Panel: Dictionary */
.dict-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}
.dict-tab-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    transition: all var(--duration) var(--ease);
}
.dict-tab-btn:hover { background: var(--bg-hover); }
.dict-tab-btn.active { background: var(--text); color: var(--bg); }

.dict-entry {
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
}
.dict-entry-term { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.dict-entry-def { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* Panel: Sermon notes */
.sermon-card {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.sermon-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.sermon-card-title { font-size: 13px; font-weight: 500; }
.sermon-card-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ══════ BUTTONS ══════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all var(--duration) var(--ease);
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 3px 8px; font-size: 12px; }

/* ══════ SEARCH MODAL (Cmd+K) ══════ */
.search-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(55,53,47,0.4);
    z-index: 999;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}
.search-modal-overlay.visible { display: flex; }
.search-modal {
    width: 560px;
    max-width: 90vw;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.search-modal-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.search-modal-input-wrap svg { width: 18px; height: 18px; color: var(--text-tertiary); flex-shrink: 0; }
.search-modal-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
}
.search-modal-input:focus { outline: none; }
.search-modal-input::placeholder { color: var(--text-placeholder); }
.search-modal-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
}
.search-modal-results:empty::after {
    content: "Digite para buscar na Bíblia";
    display: block;
    text-align: center;
    padding: 24px;
    color: var(--text-tertiary);
    font-size: 13px;
}
.search-modal-item {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--duration) var(--ease);
}
.search-modal-item:hover { background: var(--bg-hover); }
.search-modal-item-ref { font-size: 12px; font-weight: 600; color: var(--accent); }
.search-modal-item-text { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.search-modal-item-text mark { background: var(--accent-bg); color: var(--text); border-radius: 2px; padding: 0 1px; }
.search-modal-footer {
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    gap: 12px;
}
.search-modal-footer kbd {
    font-family: var(--font);
    font-size: 10px;
    padding: 1px 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-secondary);
}

/* ══════ EMPTY STATES ══════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-tertiary);
}
.empty-state-title { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state-desc { font-size: 13px; line-height: 1.5; }

/* ══════ LOGIN PROMPT ══════ */
.login-prompt {
    text-align: center;
    padding: 24px 16px;
}
.login-prompt p { font-size: 13px; color: var(--text-tertiary); margin-bottom: 12px; }
.login-prompt a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-md);
    transition: opacity var(--duration) var(--ease);
}
.login-prompt a:hover { opacity: 0.85; }

/* ══════ LOADING ══════ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-tertiary);
    font-size: 13px;
    gap: 8px;
}
.loading::before {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════ RESPONSIVE ══════ */
@media (max-width: 860px) {
    :root { --sidebar-w: 220px; --panel-w: 300px; }
    .reader-inner { padding: 32px 24px 80px; }
    .reader-title { font-size: 26px; }
    .reader-text { font-size: 17px; }
    .toolbar-search kbd { display: none; }
}
@media (max-width: 640px) {
    .app {
        grid-template-columns: 0px 1fr 0px;
    }
    .app.sidebar-open {
        grid-template-columns: 260px 1fr 0px;
    }
    .app.panel-open {
        grid-template-columns: 0px 1fr 0px;
    }
    .app.panel-open .panel {
        position: fixed;
        inset: var(--toolbar-h) 0 0 0;
        width: 100%;
        z-index: 50;
    }
    .app.sidebar-open .sidebar {
        position: fixed;
        top: var(--toolbar-h);
        left: 0;
        bottom: 0;
        width: 260px;
        z-index: 50;
    }
    .reader-inner { padding: 24px 16px 80px; }
    .reader-title { font-size: 22px; }
    .reader-text { font-size: 16px; line-height: 1.75; }
}
