/**
 * WordCraft Web - Side Panels (Navigation Pane, Comments Pane & Backstage View)
 * Ported from crates/ui-egui/src/panes.rs & backstage.rs
 * License: MIT
 */

/* Side Panes (Navigation, Review) */
.word-side-pane {
    width: 260px;
    background-color: #f8fafc;
    border-right: 1px solid var(--word-border);
    display: none;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    z-index: 85;
}

.word-side-pane.active {
    display: flex;
}

.word-side-pane.pane-right {
    border-right: none;
    border-left: 1px solid var(--word-border);
}

.word-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 36px;
    padding: 0 12px;
    border-bottom: 1px solid var(--word-border);
    font-weight: 600;
    font-size: 13px;
    color: #1e293b;
    background-color: #ffffff;
}

.word-pane-close {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    padding: 2px 6px;
}

.word-pane-close:hover {
    color: #0f172a;
}

.word-pane-tabs {
    display: flex;
    background-color: #ffffff;
    border-bottom: 1px solid var(--word-border);
}

.word-pane-tab-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 11px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #64748b;
    border-bottom: 2px solid transparent;
}

.word-pane-tab-btn.active {
    color: var(--word-blue);
    border-bottom-color: var(--word-blue);
    font-weight: 600;
}

.word-pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Headings Tree */
.word-heading-item {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #334155;
}

.word-heading-item:hover {
    background-color: #e2e8f0;
}

.word-heading-item.level-1 { font-weight: 600; }
.word-heading-item.level-2 { padding-left: 16px; color: #475569; }
.word-heading-item.level-3 { padding-left: 24px; color: #64748b; }

/* Comment Cards */
.word-comment-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.word-comment-author {
    font-weight: 600;
    font-size: 11px;
    color: var(--word-blue);
    margin-bottom: 2px;
}

.word-comment-time {
    font-size: 10px;
    color: #94a3b8;
    margin-bottom: 6px;
}

.word-comment-text {
    font-size: 12px;
    color: #1e293b;
    line-height: 1.3;
}

/* Backstage View (File Menu Fullscreen Overlay) */
.word-backstage-view {
    display: none;
    position: fixed;
    inset: 0;
    background-color: #ffffff;
    z-index: 999;
}

.word-backstage-view.active {
    display: flex;
}

.word-backstage-nav {
    width: 220px;
    background-color: var(--word-blue);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    flex-shrink: 0;
}

.word-backstage-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    color: #ffffff;
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
}

.word-backstage-back-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.word-backstage-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    font-size: 13px;
    color: #e0e7ff;
    cursor: pointer;
    transition: background-color 0.15s;
}

.word-backstage-nav-item:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.word-backstage-nav-item.active {
    background-color: #ffffff;
    color: var(--word-blue);
    font-weight: 600;
}

.word-backstage-body {
    flex: 1;
    overflow-y: auto;
    padding: 36px 48px;
    background-color: #f8fafc;
}

.word-backstage-pane {
    display: none;
    max-width: 900px;
}

.word-backstage-pane.active {
    display: block;
}

.word-backstage-title {
    font-size: 26px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 20px;
}

/* Backstage Sections & Cards */
.word-backstage-card {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.word-backstage-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.word-backstage-card-desc {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 14px;
    line-height: 1.5;
}

.word-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.word-prop-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12px;
}

.word-prop-label {
    width: 110px;
    color: #64748b;
    flex-shrink: 0;
}

.word-prop-input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    font-size: 12px;
    color: #1e293b;
    outline: none;
    background: #fff;
}

.word-prop-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb;
}

.word-stats-list {
    font-size: 12px;
    color: #334155;
    line-height: 2.0;
}

.word-stats-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #e2e8f0;
    padding: 2px 0;
}

/* Template Cards Grid */
.word-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 18px;
    margin-top: 16px;
}

.word-template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.word-template-card:hover {
    border-color: var(--word-blue);
    box-shadow: 0 6px 16px rgba(24, 90, 189, 0.18);
    transform: translateY(-2px);
}

.word-template-thumb {
    width: 105px;
    height: 140px;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.word-template-name {
    font-size: 12px;
    font-weight: 500;
    color: #1e293b;
    text-align: center;
}

/* Export & Save As Formats Grid */
.word-export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.word-export-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.15s;
}

.word-export-item:hover {
    border-color: #2563eb;
    background-color: #eff6ff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.word-export-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.word-export-info h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #0f172a;
}

.word-export-info p {
    margin: 0;
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
}

/* Print View Layout */
.word-print-layout {
    display: flex;
    gap: 32px;
}

.word-print-controls {
    width: 320px;
    flex-shrink: 0;
}

.word-print-preview-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #e2e8f0;
    padding: 24px;
    border-radius: 6px;
    min-height: 500px;
    max-height: 620px;
    overflow-y: auto;
}

/* ========================================== */
/* VIEW TAB STYLES: READ MODE, SPLIT & LAYOUT */
/* ========================================== */

/* 1. Full-screen Read Mode Overlay */
.word-read-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    background-color: #f1f5f9;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.word-read-mode-header {
    height: 48px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(203, 213, 225, 0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.word-read-mode-book-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 24px;
    overflow-y: auto;
}

.word-read-mode-page {
    width: 480px;
    height: 680px;
    background: #ffffff;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    padding: 36px 40px;
    box-sizing: border-box;
    position: relative;
}

.word-read-mode-page.left {
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.word-read-mode-page.right {
    border-left: 1px solid rgba(0, 0, 0, 0.06);
}

.word-read-mode-page-header {
    font-size: 11px;
    color: #94a3b8;
    text-align: right;
    margin-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
}

.word-read-mode-content {
    flex: 1;
    overflow-y: auto;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 15px;
    line-height: 1.7;
}

.word-read-mode-footer {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background-color: rgba(255, 255, 255, 0.85);
    border-top: 1px solid rgba(203, 213, 225, 0.8);
    flex-shrink: 0;
}

/* 2. Side to Side Page Movement */
#word_pages_container.movement-side-to-side {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 24px !important;
    overflow-x: auto !important;
    padding: 24px !important;
}

#word_pages_container.movement-side-to-side .word-page-card {
    flex-shrink: 0 !important;
    margin: 0 !important;
}

/* 3. Web Layout Mode */
#word_pages_container.view-mode-web {
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
}

#word_pages_container.view-mode-web .word-page-card {
    box-shadow: none !important;
    border: none !important;
    border-bottom: 1px dashed #cbd5e1 !important;
    margin: 0 auto !important;
    width: 90% !important;
    max-width: 960px !important;
}

/* 4. Split Screen Splitter & Bottom Viewport */
.word-split-pane-bottom {
    display: none;
    flex-direction: column;
    flex: 1;
    height: 50%;
    border-top: 4px solid #0284c7;
    position: relative;
    background: #cbd5e1;
    overflow: auto;
}

.word-split-bar {
    height: 6px;
    background: #0284c7;
    cursor: row-resize;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 100;
}

.word-split-content {
    flex: 1;
    overflow: auto;
    padding: 24px;
    display: flex;
    justify-content: center;
}

/* 5. Outline View Toolbar & Items */
.word-outline-toolbar {
    height: 40px;
    background: #f8fafc;
    border-bottom: 1px solid #cbd5e1;
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 90;
    flex-shrink: 0;
}

.word-outline-item {
    transition: background 0.1s;
    border-radius: 4px;
    padding: 4px 6px !important;
}

.word-outline-item:hover {
    background: #f1f5f9;
}

.word-outline-item.is-heading {
    border-left: 3px solid #0284c7;
}

/* 6. Read Mode Navigation Arrows */
.word-read-nav-arrow {
    width: 44px;
    height: 64px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 28px;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    user-select: none;
    flex-shrink: 0;
}

.word-read-nav-arrow:hover:not(:disabled) {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
    transform: scale(1.05);
}

.word-read-nav-arrow:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

/* 7. Hide White Space Between Pages */
#word_pages_container.hide-white-space .word-page-card {
    margin-bottom: 2px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}


