/* ==========================================================================
   Editor workspace side panels — Template Editor and Letter Review.

   When the window narrows, the side panels give way before the letter does:
     - at or below WorkspaceBreakpoints.RightRailMaxWidth (1440px) the right panel folds to an icon rail,
     - at or below WorkspaceBreakpoints.LeftRailMaxWidth (1200px) the left panel does too.
   An icon opens its panel as a drawer OVER the canvas (the letter doesn't reflow underneath), so tokens / clauses can
   still be dragged from it into the letter. The breakpoints live in C# (WorkspacePanels.cs); these rules key off the
   classes it produces, so there are no media queries here to keep in sync.
   ========================================================================== */

/* The row that holds rail | panel | canvas | panel | rail — the drawers position against it. */
.ws-workspace {
    position: relative;
}

/* ---- Icon rail ---- */
.ws-rail {
    width: var(--workspace-rail-width);
    flex: 0 0 var(--workspace-rail-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 0;
    background: var(--bg-primary);
    overflow-y: auto;
    scrollbar-width: none;
}

.ws-rail-left {
    border-right: 1px solid var(--border-primary);
}

.ws-rail-right {
    border-left: 1px solid var(--border-primary);
}

.ws-rail-btn {
    position: relative;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ws-rail-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ws-rail-btn.active {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

.ws-rail-img {
    width: 16px;
    height: 16px;
}

.ws-rail-badge {
    position: absolute;
    top: 1px;
    right: 0;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    box-sizing: border-box;
    border-radius: 12px;
    background: var(--color-info-bg);
    color: var(--color-info-text);
    font-size: 10px;
    font-weight: 600;
    line-height: 15px;
}

/* ---- Panel states ---- */
/* Folded behind its rail. Stays mounted (only hidden) so its state — tab, scroll, form input — survives. */
.ws-panel-hidden {
    display: none !important;
}

/* Open from the rail: floats over the canvas next to the rail, at the panel's own width. */
.ws-drawer {
    position: absolute !important;
    top: 0;
    bottom: 0;
    z-index: var(--workspace-drawer-z);
    max-width: calc(100% - 2 * var(--workspace-rail-width));
    box-shadow: var(--workspace-drawer-shadow);
}

.ws-drawer-left {
    left: var(--workspace-rail-width);
}

.ws-drawer-right {
    right: var(--workspace-rail-width);
}

/* ---- Action bar: gives way at the same breakpoints ----
   Letter Review's bar sits inside .review-container (which carries the ws-narrow-* classes); the Template Editor's bar
   is a sibling just before .template-editor-page. Labels drop first, primary actions keep theirs; every button that
   goes icon-only has a title. */

/* <= 1440px: back button goes icon-only, the title truncates, the pathway caption drops. */
.review-container.ws-narrow-right .action-bar-left,
.template-action-bar:has(~ .ws-narrow-right) .action-bar-left {
    flex-shrink: 1;
    min-width: 0;
}

.review-container.ws-narrow-right .btn-back > span,
.template-action-bar:has(~ .ws-narrow-right) .btn-back > span,
.review-container.ws-narrow-right .pathway-progress-label {
    display: none;
}

.review-container.ws-narrow-right .document-title,
.template-action-bar:has(~ .ws-narrow-right) .document-title {
    flex: 1 1 auto;
    min-width: 0;
}

.review-container.ws-narrow-right .title-input {
    min-width: 0;
    width: 100%;
    text-overflow: ellipsis;
}

.template-action-bar:has(~ .ws-narrow-right) .template-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* <= 1200px: secondary buttons go icon-only and the mode caption drops. */
.review-container.ws-narrow-left .action-bar-right .btn-secondary > span:not(.spinner),
.template-action-bar:has(~ .ws-narrow-left) .action-bar-right .btn-secondary > span:not(.spinner),
.template-action-bar:has(~ .ws-narrow-left) .btn-preview-mode > span,
.template-action-bar:has(~ .ws-narrow-left) .editor-mode-indicator .mode-label,
.template-action-bar:has(~ .ws-narrow-left) .action-bar-divider {
    display: none;
}

.template-action-bar:has(~ .ws-narrow-left) .pending-notice,
.template-action-bar:has(~ .ws-narrow-left) .rejected-notice {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* <= 960px: primary actions go icon-only too (each keeps its title), and the save status truncates. */
.review-container.ws-compact .action-bar-right .btn-primary > span:not(.spinner),
.review-container.ws-compact .action-bar-right .btn-success > span:not(.spinner),
.review-container.ws-compact .action-bar-right .btn-danger-outline > span:not(.spinner),
.template-action-bar:has(~ .ws-compact) .action-bar-right .btn-primary > span:not(.spinner),
.template-action-bar:has(~ .ws-compact) .action-bar-right .btn-success > span:not(.spinner),
.template-action-bar:has(~ .ws-compact) .action-bar-right .btn-danger-outline > span:not(.spinner),
.template-action-bar:has(~ .ws-compact) .btn-edit-mode > span {
    display: none;
}

.review-container.ws-compact .save-status {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.review-container.ws-compact .action-bar-left {
    gap: 12px;
}

/* The dots keep their width; the title is what truncates. */
.review-container.ws-compact .action-bar-center {
    flex-shrink: 0;
    padding: 0 8px;
}

/* Pathway dots tighten up so they fit between the title and the actions. */
.review-container.ws-compact .action-bar-center > .workflow-progress {
    padding: 0 4px;
}

.review-container.ws-compact .workflow-dot-connector {
    width: 8px;
}
