/* ═══ Viewer Specific Styles — Scroll-Based Layout ═══ */

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* ═══ Button Refinements ═══ */
.btn {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon {
    border-radius: 50%;
    width: 42px; 
    height: 42px;
    background: transparent;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.05) !important;
}

.btn-icon:active {
    background: rgba(0, 0, 0, 0.1) !important;
}
.btn-dark {
    background: #000 !important;
    color: #fff !important;
}
.btn-dark:active {
    background: #444 !important;
}

.btn-icon .material-symbols-outlined {
    font-size: 22px;
}

/* ═══ Viewer Toolbar ═══ */
.viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-bottom: 2px solid #000;
    padding: 0 4px;
    height: 56px;
    z-index: 100;
    flex-shrink: 0;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0;
}

.toolbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.toolbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.toolbar-chapter { 
    font-weight: 600; 
    color: var(--text-secondary); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

/* ═══ Viewer More Menu & Items ═══ */
.toolbar-more {
    position: relative;
}

.more-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    border: 2px solid #000;
    border-radius: 12px;
    padding: 8px;
    width: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.more-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.more-menu-item:hover {
    background: var(--bg-color);
}

.more-menu-item .material-symbols-outlined {
    font-size: 18px;
}

/* AI FAB */
.ai-fab-wrapper {
    margin-left: 20px;
    pointer-events: auto;
}

.ai-fab {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    border: 2px solid #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.2s;
}

.ai-fab:hover {
    background: #222;
}

.ai-fab .material-symbols-outlined {
    font-size: 24px;
}

/* ═══ Scrollable Viewer Container ═══ */
.viewer-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #e8e8e8;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    scrollbar-gutter: stable both-edges;
}

.protection-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10;
    background: transparent;
    pointer-events: none;
}

/* ═══ Modals ═══ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: white;
    border: 3px solid var(--border-dark);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    transform: none;
    transition: none;
}
.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ═══ AI Chat ═══ */
.ai-fullscreen-chat {
    position: fixed;
    top: 0; right: 0;
    transform: translateX(100%);
    width: 100%; height: 100%;
    background: white;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
    overflow: hidden;
}
.ai-fullscreen-chat.active { transform: translateX(0); }

.ai-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.ai-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

#ai-chat-messages {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    will-change: transform;
}

#ai-chat-messages pre {
    touch-action: pan-x;
    -webkit-overflow-scrolling: auto;
}

@media (max-width: 768px) {
    .viewer-toolbar { height: 50px; }
    .toolbar-brand { display: none; }
    .toolbar-chapter { font-size: 0.85rem; max-width: 150px; }
}
