/*
 * PDF viewer and toolbar layout styles for Paper Assistant.
 *
 * Defines the main application layout: toolbar at top, PDF viewer in the
 * centre, and chat panel on the right.
 */

/* ── Toolbar ─────────────────────────────────────────────────────────── */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-height);
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--toolbar-sep-color);
    padding: 0 4px;
    flex-shrink: 0;
}

.toolbar__left,
.toolbar__right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.toolbar__right {
    padding-right: var(--toolbar-label-right-padx);
}

.toolbar__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--toolbar-bg);
    color: var(--toolbar-fg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.1s;
}

.toolbar__btn:hover {
    background: var(--toolbar-btn-active);
}

.toolbar__btn:active {
    background: var(--toolbar-btn-active);
}

.toolbar__btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.toolbar__btn:disabled:hover {
    background: var(--toolbar-bg);
}

.toolbar__sep {
    width: var(--toolbar-sep-width);
    height: calc(var(--toolbar-height) - 2 * var(--toolbar-sep-pady));
    background: var(--toolbar-sep-color);
    margin: 0 var(--toolbar-sep-padx);
    flex-shrink: 0;
}

.toolbar__label {
    font-size: var(--toolbar-font-size);
    color: var(--toolbar-fg);
    padding: 0 4px;
    white-space: nowrap;
    user-select: none;
}

/* ── Menu Dropdown ──────────────────────────────────────────────────── */

.toolbar__menu-wrapper {
    position: relative;
}

.toolbar__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 200px;
    background: var(--toolbar-bg);
    border: 1px solid var(--toolbar-sep-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
    margin-top: 2px;
}

.toolbar__dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--toolbar-fg);
    font-size: var(--toolbar-font-size);
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.toolbar__dropdown-item:hover:not(:disabled) {
    background: var(--toolbar-btn-active);
}

.toolbar__dropdown-item:disabled {
    opacity: 0.4;
    cursor: default;
}

.toolbar__dropdown-item--empty {
    opacity: 0.5;
    cursor: default;
    font-style: italic;
}

/* Leading check on a selected option (e.g. the active Quality level).
   Kept in layout (visibility, not display) so every item's label stays
   aligned whether or not it is the active one. */
.toolbar__check {
    visibility: hidden;
}

.toolbar__dropdown-item--active .toolbar__check {
    visibility: visible;
}

.toolbar__dropdown-sep {
    height: 1px;
    background: var(--toolbar-sep-color);
    margin: 4px 0;
}

/* ── Nested Submenus ───────────────────────────────────────────────── */

.toolbar__submenu-parent {
    position: relative;
}

.toolbar__dropdown-item--parent {
    justify-content: flex-start;
}

.toolbar__submenu-arrow {
    margin-left: auto;
}

.toolbar__submenu {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    z-index: 1001;
    min-width: 200px;
    background: var(--toolbar-bg);
    border: 1px solid var(--toolbar-sep-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
}

.toolbar__submenu-parent:hover > .toolbar__submenu,
.toolbar__submenu-parent--active > .toolbar__submenu {
    display: block;
}

.toolbar__submenu-parent:hover > .toolbar__dropdown-item--parent {
    background: var(--toolbar-btn-active);
}

/* Nested submenu (e.g. Past Chats inside AI Chat) */
.toolbar__submenu-parent--nested {
    position: relative;
}

/* Conditional visibility — hidden by default, shown via JS */
[data-debug-only] { display: none; }
[data-client-only] { display: none; }

/* ── Progress Bar ────────────────────────────────────────────────────── */

.toolbar__progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 var(--toolbar-progress-padx);
}

.toolbar__progress-bar {
    width: var(--toolbar-progress-length);
    height: 6px;
    background: var(--scrollbar-track);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.toolbar__progress-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress-value, 0%);
    background: var(--overlay-border);
    border-radius: 3px;
    transition: width 0.2s ease;
}

/* ── Main Content ────────────────────────────────────────────────────── */

.main-content {
    display: flex;
    height: calc(100vh - var(--toolbar-height));
    overflow: hidden;
}

/* ── PDF Viewer ──────────────────────────────────────────────────────── */

.pdf-viewer-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.pdf-viewer {
    width: 100%;
    height: 100%;
    overflow: auto;
    background: #808080;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 10px;
}

.pdf-viewer__page-wrapper {
    position: relative;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.pdf-viewer__page-canvas {
    display: block;
}

/* ── Overlay Container ───────────────────────────────────────────────── */

.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* ── Summary Overlays ───────────────────────────────────────────────── */

.summary-overlay {
    position: absolute;
    overflow: hidden;
    padding: 4px;
    background: rgba(245, 245, 245, 0.92);
    border: 1.5px solid var(--overlay-border, #0055AA);
    border-radius: 6px;
    color: #1a1a1a;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.25;
    cursor: pointer;
    pointer-events: auto;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.summary-overlay--hidden {
    display: none !important;
}
