/* 1. Global Reset & Fonts */
.pv-root * { box-sizing: border-box; margin: 0; padding: 0; }

.pv-root {
    --pv-sidebar-w: 240px;
    --pv-toolbar-h: 52px;
    --pv-bg: #f4f5f7;
    --pv-surface: #ffffff;
    --pv-surface-2: #edeef1;
    --pv-border: rgba(0,0,0,0.07);
    --pv-text: #1a1c24;
    --pv-text-muted: #6b6f7e;
    --pv-accent: #4f7df3;

    font-family: inherit;
    background: var(--pv-bg);
    color: var(--pv-text);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--pv-border);
    border-radius: 8px;
    height: 600px; /* Default height */
}

/* Dark Theme */
.pv-dark {
    --pv-bg: #0f1117;
    --pv-surface: #181a22;
    --pv-surface-2: #22252f;
    --pv-border: rgba(255,255,255,0.06);
    --pv-text: #e8e9ed;
    --pv-text-muted: #8a8d9b;
}

/* --- FULLSCREEN FIX --- */
.pv-root.fullscreen {
    position: fixed !important;
    inset: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999;
    border-radius: 0;
    border: none;
}

/* 2. Toolbar Layout */
.pv-toolbar {
    height: var(--pv-toolbar-h);
    background: var(--pv-surface);
    border-bottom: 1px solid var(--pv-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 20;
}

.pv-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pv-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--pv-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pv-btn:hover, .pv-btn.active {
    background: var(--pv-surface-2);
    color: var(--pv-text);
}

.pv-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Page Number Input */
.pv-page-input {
    width: 40px;
    height: 28px;
    text-align: center;
    border: 1px solid var(--pv-border);
    border-radius: 4px;
    background: var(--pv-bg);
    color: var(--pv-text);
    font-size: 14px;
}

/* --- SEARCH BAR HORIZONTAL FIX --- */
.pv-search-bar {
    display: none; 
    align-items: center;
    gap: 8px; /* Spaces out input, arrows, and X horizontally */
    background: var(--pv-surface-2);
    padding: 4px 8px;
    border-radius: 6px;
    margin-left: 8px;
}
.pv-search-bar.open {
    display: flex; /* Forces items into a row */
}
.pv-search-input {
    border: 1px solid var(--pv-border);
    background: var(--pv-surface);
    color: var(--pv-text);
    padding: 4px 8px;
    border-radius: 4px;
    width: 150px;
}

/* 3. Main Body & Sidebar (Fixes the "All Pages on Screen" issue) */
.pv-body {
    display: flex; /* Prevents vertical stacking of sidebar and canvas */
    flex: 1;
    overflow: hidden;
    position: relative;
}

.pv-sidebar {
    width: var(--pv-sidebar-w);
    background: var(--pv-surface);
    border-right: 1px solid var(--pv-border);
    display: flex;
    flex-direction: column;
    height: 100%; 
    max-height: 100%;
    min-height: 0;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 10;
}
.pv-sidebar.open {
    transform: translateX(0);
    position: relative; /* Pushes the canvas to the right when open */
}

/* Thumbnails */
/* Replace .pv-thumbs with the data attribute selector */
[data-el="thumbs"] {
    flex: 1 1 0%;      /* Forces the container to absorb exact remaining space */
    min-height: 0;     /* Overrides the flexbox 'auto' height protection */
    overflow-y: auto;  /* Triggers the scrollbar */
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* You will also need to update the thumbnail item selectors if they are missing classes */
[data-el="thumbs"] > div {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 4px;
    text-align: center;
    background: var(--pv-bg);
}

[data-el="thumbs"] > div.active { 
    border-color: var(--pv-accent); 
}

[data-el="thumbs"] canvas { 
    max-width: 100%; 
    height: auto; 
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); 
}
.pv-thumb-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 4px;
    text-align: center;
    background: var(--pv-bg);
}
.pv-thumb-item.active { border-color: var(--pv-accent); }
.pv-thumb-item canvas { max-width: 100%; height: auto; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.pv-thumb-label { display: block; font-size: 12px; margin-top: 4px; color: var(--pv-text-muted); }

/* Main Canvas Area */
.pv-canvas-wrap {
    flex: 1;
    overflow: auto;
    padding: 24px;
    background: var(--pv-bg);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.pv-canvas-wrap canvas {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    background: #fff;
}

/* Loader / Error */
.pv-loader, .pv-error {
    display: none;
    position: absolute;
    inset: 0;
    background: var(--pv-bg);
    z-index: 30;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.pv-loader.active, .pv-error.active { display: flex; }

/* 4. Status Bar (Footer) */
.pv-status {
    height: 32px;
    background: var(--pv-surface-2);
    border-top: 1px solid var(--pv-border);
    display: flex;
    align-items: center;
    justify-content: space-between; /* Pushes 'Loaded' left and '3 pages' right */
    padding: 0 16px;
    font-size: 13px;
    color: var(--pv-text-muted);
    z-index: 20;
}

/* Optional: If they are right next to each other on the left instead of split */
.pv-status-group {
    display: flex;
    align-items: center;
    gap: 12px; /* Adds space if they are in the same flex group */
}
