/**
 * AJT MSP Hub — BookStack CM Documents Tab Styles.
 *
 * Covers: toolbar, filter pills, book card grid, link/create modals,
 * category badges, visibility toggles, empty state, loading skeleton.
 *
 * Uses CSS custom properties from the AJT UX Design System.
 * Must work in both wp-admin CM and Glass Portal contexts.
 *
 * @package AJT_MSP_Hub
 * @since   3.0.0
 */

/* ── Wrapper ──────────────────────────────────────────────── */

.ajt-bs-cm-wrap {
    padding: 0;
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Toolbar ──────────────────────────────────────────────── */

.ajt-bs-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ajt-bs-toolbar-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ajt-bs-toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Filter Pills ─────────────────────────────────────────── */

.ajt-bs-filter-pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.ajt-bs-pill {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    background: var(--ajt-card-bg, #fff);
    color: var(--ajt-gray-500, #6b7280);
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1.4;
}

.ajt-bs-pill:hover {
    border-color: var(--ajt-independence, #534B62);
    color: var(--ajt-independence, #534B62);
}

.ajt-bs-pill.active {
    background: var(--ajt-independence, #534B62);
    color: #fff;
    border-color: var(--ajt-independence, #534B62);
}

/* ── Book Card Grid ───────────────────────────────────────── */

.ajt-bs-book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.ajt-bs-book-card {
    background: var(--ajt-card-bg, #fff);
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: var(--ajt-radius, 10px);
    padding: 20px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: ajtBsCardFadeIn 0.3s ease forwards;
}

.ajt-bs-book-card:hover {
    box-shadow: var(--ajt-shadow-md, 0 4px 6px rgba(0,0,0,0.07));
    border-color: var(--ajt-gray-300, #d1d5db);
}

@keyframes ajtBsCardFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ajt-bs-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.ajt-bs-card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--ajt-gray-900, #111827);
    line-height: 1.3;
    word-break: break-word;
}

/* ── Category Badges ──────────────────────────────────────── */

.ajt-bs-category-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ajt-bs-category-badge[data-cat="network"]    { background: #dbeafe; color: #1e40af; }
.ajt-bs-category-badge[data-cat="passwords"]  { background: #fef3c7; color: #92400e; }
.ajt-bs-category-badge[data-cat="procedures"] { background: #d1fae5; color: #065f46; }
.ajt-bs-category-badge[data-cat="assets"]     { background: #ede9fe; color: #5b21b6; }
/* Fallback for custom categories. */
.ajt-bs-category-badge:not([data-cat="network"]):not([data-cat="passwords"]):not([data-cat="procedures"]):not([data-cat="assets"]) {
    background: var(--ajt-gray-100, #f3f4f6);
    color: var(--ajt-gray-600, #4b5563);
}

/* ── Card Meta ────────────────────────────────────────────── */

.ajt-bs-card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.ajt-bs-meta-item {
    font-size: 12px;
    color: var(--ajt-gray-400, #9ca3af);
}

/* ── Card Actions ─────────────────────────────────────────── */

.ajt-bs-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--ajt-gray-100, #f3f4f6);
}

.ajt-bs-card-actions .button {
    font-size: 12px;
    padding: 2px 10px;
    min-height: 28px;
}

/* ── Modal ────────────────────────────────────────────────── */

.ajt-bs-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100050;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ajt-bs-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(37, 40, 61, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ajt-bs-modal-content {
    position: relative;
    background: var(--ajt-card-bg, #fff);
    border-radius: 16px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: ajtBsModalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ajtBsModalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ajt-bs-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ajt-card-border, #DBD8DE);
}

.ajt-bs-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ajt-space, #25283D);
}

.ajt-bs-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--ajt-gray-400, #9ca3af);
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.ajt-bs-modal-close:hover {
    color: var(--ajt-gray-700, #374151);
    background: var(--ajt-gray-100, #f1f5f9);
}

.ajt-bs-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* ── Search Input ─────────────────────────────────────────── */

.ajt-bs-search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: var(--ajt-radius-sm, 6px);
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.ajt-bs-search-input:focus {
    outline: none;
    border-color: var(--ajt-independence, #534B62);
    box-shadow: 0 0 0 2px rgba(83, 75, 98, 0.15);
}

/* ── Link Results ─────────────────────────────────────────── */

.ajt-bs-link-results {
    max-height: 400px;
    overflow-y: auto;
}

.ajt-bs-link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--ajt-radius-sm, 6px);
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.1s;
}

.ajt-bs-link-item:hover {
    background: var(--ajt-gray-50, #f9fafb);
}

.ajt-bs-link-item.linked {
    opacity: 0.5;
    cursor: default;
}

.ajt-bs-link-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--ajt-gray-800, #1f2937);
}

.ajt-bs-link-item-desc {
    font-size: 11px;
    color: var(--ajt-gray-400, #9ca3af);
    margin-top: 2px;
}

.ajt-bs-link-item-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ajt-bs-link-item.linked .ajt-bs-link-item-badge {
    background: var(--ajt-gray-100, #f3f4f6);
    color: var(--ajt-gray-500, #6b7280);
}

/* ── Form Groups ──────────────────────────────────────────── */

.ajt-bs-form-group {
    margin-bottom: 14px;
}

.ajt-bs-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--ajt-gray-700, #374151);
}

.ajt-bs-form-group input,
.ajt-bs-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: var(--ajt-radius-sm, 6px);
    font-size: 14px;
    box-sizing: border-box;
}

/* ── Empty State ──────────────────────────────────────────── */

.ajt-bs-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
    color: var(--ajt-gray-400, #9ca3af);
}

.ajt-bs-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.ajt-bs-empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ajt-gray-600, #4b5563);
    margin: 0 0 8px;
}

.ajt-bs-empty-state p {
    font-size: 14px;
    margin: 0 0 20px;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Loading ──────────────────────────────────────────────── */

.ajt-bs-loading {
    text-align: center;
    padding: 24px;
    color: var(--ajt-gray-400, #9ca3af);
    font-style: italic;
    font-size: 13px;
}

/* ── Skeleton Cards ───────────────────────────────────────── */

.ajt-bs-skeleton-card {
    background: var(--ajt-gray-50, #f9fafb);
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: var(--ajt-radius, 10px);
    padding: 20px;
    animation: ajtBsPulse 1.5s ease-in-out infinite;
}

.ajt-bs-skeleton-card .skel-line {
    height: 12px;
    background: var(--ajt-gray-200, #e5e7eb);
    border-radius: 4px;
    margin-bottom: 10px;
}

.ajt-bs-skeleton-card .skel-line:first-child {
    width: 70%;
    height: 16px;
}

.ajt-bs-skeleton-card .skel-line:last-child {
    width: 40%;
    margin-bottom: 0;
}

@keyframes ajtBsPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 640px) {
    .ajt-bs-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .ajt-bs-toolbar-left,
    .ajt-bs-toolbar-right {
        justify-content: flex-start;
    }
    .ajt-bs-book-grid {
        grid-template-columns: 1fr;
    }
    .ajt-bs-modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* ══════════════════════════════════════════════════════════════
 * CONTENT READER (Session 4)
 * ══════════════════════════════════════════════════════════════ */

/* ── Reader Layout ────────────────────────────────────────── */

.ajt-bs-reader {
    display: flex;
    gap: 0;
    min-height: 500px;
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: var(--ajt-radius, 10px);
    overflow: hidden;
    background: var(--ajt-card-bg, #fff);
}

/* ── Reader Toolbar ───────────────────────────────────────── */

.ajt-bs-reader-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--ajt-gray-50, #f9fafb);
    border-bottom: 1px solid var(--ajt-card-border, #e5e7eb);
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    border-radius: var(--ajt-radius, 10px);
}

.ajt-bs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ajt-gray-500, #6b7280);
    flex-wrap: wrap;
    min-width: 0;
}

.ajt-bs-breadcrumb-item {
    cursor: pointer;
    color: var(--ajt-independence, #534B62);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.ajt-bs-breadcrumb-item:hover {
    text-decoration: underline;
}

.ajt-bs-breadcrumb-sep {
    color: var(--ajt-gray-300, #d1d5db);
    flex-shrink: 0;
}

.ajt-bs-breadcrumb-current {
    font-weight: 700;
    color: var(--ajt-gray-800, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.ajt-bs-reader-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */

.ajt-bs-sidebar {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--ajt-card-border, #e5e7eb);
    background: var(--ajt-gray-50, #f9fafb);
    overflow-y: auto;
    padding: 12px 0;
    flex-shrink: 0;
}

.ajt-bs-sidebar-chapter {
    margin-bottom: 4px;
}

.ajt-bs-sidebar-chapter-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--ajt-gray-500, #6b7280);
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}

.ajt-bs-sidebar-chapter-title:hover {
    background: var(--ajt-gray-100, #f3f4f6);
}

.ajt-bs-sidebar-chapter-title .ajt-bs-chevron {
    font-size: 10px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.ajt-bs-sidebar-chapter.collapsed .ajt-bs-chevron {
    transform: rotate(-90deg);
}

.ajt-bs-sidebar-chapter.collapsed .ajt-bs-sidebar-pages {
    display: none;
}

.ajt-bs-sidebar-page {
    display: block;
    padding: 6px 16px 6px 32px;
    font-size: 13px;
    color: var(--ajt-gray-600, #4b5563);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    text-decoration: none;
    border-left: 3px solid transparent;
    word-break: break-word;
}

.ajt-bs-sidebar-page:hover {
    background: var(--ajt-gray-100, #f3f4f6);
    color: var(--ajt-gray-900, #111827);
}

.ajt-bs-sidebar-page.active {
    background: #ede9fe;
    color: var(--ajt-independence, #534B62);
    border-left-color: var(--ajt-independence, #534B62);
    font-weight: 600;
}

/* Top-level pages (no chapter) */
.ajt-bs-sidebar-page.top-level {
    padding-left: 16px;
}

/* ── Content Area ─────────────────────────────────────────── */

.ajt-bs-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    min-width: 0;
}

.ajt-bs-content-loading,
.ajt-bs-content-error {
    text-align: center;
    padding: 48px 24px;
    color: var(--ajt-gray-400, #9ca3af);
}

.ajt-bs-content-error {
    color: #dc2626;
}

/* ── BookStack Content Typography ─────────────────────────── */

.ajt-bs-page-html {
    line-height: 1.7;
    color: var(--ajt-gray-800, #1f2937);
    font-size: 14px;
}

.ajt-bs-page-html h1 { font-size: 24px; font-weight: 700; margin: 28px 0 12px; color: var(--ajt-gray-900, #111827); }
.ajt-bs-page-html h2 { font-size: 20px; font-weight: 700; margin: 24px 0 10px; color: var(--ajt-gray-900, #111827); }
.ajt-bs-page-html h3 { font-size: 17px; font-weight: 700; margin: 20px 0 8px; color: var(--ajt-gray-900, #111827); }
.ajt-bs-page-html h4 { font-size: 15px; font-weight: 700; margin: 16px 0 6px; color: var(--ajt-gray-800, #1f2937); }
.ajt-bs-page-html h5,
.ajt-bs-page-html h6 { font-size: 14px; font-weight: 700; margin: 14px 0 4px; }

.ajt-bs-page-html p { margin: 0 0 12px; }

.ajt-bs-page-html a {
    color: var(--ajt-independence, #534B62);
    text-decoration: underline;
}

.ajt-bs-page-html img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    cursor: pointer;
}

/* Tables */
.ajt-bs-page-html table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.ajt-bs-page-html th,
.ajt-bs-page-html td {
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}

.ajt-bs-page-html th {
    background: var(--ajt-gray-50, #f9fafb);
    font-weight: 700;
    font-size: 12px;
}

.ajt-bs-page-html tr:nth-child(even) td {
    background: var(--ajt-gray-50, #f9fafb);
}

/* Code Blocks */
.ajt-bs-page-html pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 12px 0;
}

.ajt-bs-page-html code {
    background: var(--ajt-gray-100, #f3f4f6);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.9em;
    color: #be185d;
}

.ajt-bs-page-html pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Callout Boxes (BookStack .callout pattern) */
.ajt-bs-page-html .callout,
.ajt-bs-page-html [class*="callout"] {
    padding: 14px 18px;
    border-radius: 6px;
    margin: 12px 0;
    border-left: 4px solid;
    font-size: 13px;
}

.ajt-bs-page-html .callout.info,
.ajt-bs-page-html .callout-info {
    background: #eff6ff;
    border-left-color: #3b82f6;
    color: #1e40af;
}

.ajt-bs-page-html .callout.success,
.ajt-bs-page-html .callout-success {
    background: #f0fdf4;
    border-left-color: #22c55e;
    color: #166534;
}

.ajt-bs-page-html .callout.warning,
.ajt-bs-page-html .callout-warning {
    background: #fffbeb;
    border-left-color: #f59e0b;
    color: #92400e;
}

.ajt-bs-page-html .callout.danger,
.ajt-bs-page-html .callout-danger {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #991b1b;
}

/* Blockquotes */
.ajt-bs-page-html blockquote {
    border-left: 4px solid var(--ajt-gray-200, #e5e7eb);
    margin: 12px 0;
    padding: 8px 16px;
    color: var(--ajt-gray-500, #6b7280);
    font-style: italic;
}

/* Collapsible details/summary */
.ajt-bs-page-html details {
    margin: 12px 0;
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: 6px;
    padding: 0;
}

.ajt-bs-page-html summary {
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    background: var(--ajt-gray-50, #f9fafb);
    border-radius: 6px;
}

.ajt-bs-page-html details[open] summary {
    border-bottom: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: 6px 6px 0 0;
}

.ajt-bs-page-html details > *:not(summary) {
    padding: 0 14px;
}

/* Lists */
.ajt-bs-page-html ul,
.ajt-bs-page-html ol {
    margin: 8px 0 12px 24px;
}

.ajt-bs-page-html li {
    margin-bottom: 4px;
}

/* Horizontal rules */
.ajt-bs-page-html hr {
    border: none;
    border-top: 1px solid var(--ajt-gray-200, #e5e7eb);
    margin: 20px 0;
}

/* ── Image Lightbox ───────────────────────────────────────── */

.ajt-bs-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100060;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    animation: ajtBsFadeIn 0.2s ease;
}

.ajt-bs-lightbox img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
    cursor: default;
}

.ajt-bs-lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.8;
    line-height: 1;
}

.ajt-bs-lightbox-close:hover {
    opacity: 1;
}

@keyframes ajtBsFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Reader Responsive ────────────────────────────────────── */

@media (max-width: 768px) {
    .ajt-bs-reader {
        flex-direction: column;
    }
    .ajt-bs-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--ajt-card-border, #e5e7eb);
    }
    .ajt-bs-content {
        padding: 16px;
    }
    .ajt-bs-breadcrumb-item { max-width: 120px; }
    .ajt-bs-breadcrumb-current { max-width: 160px; }
}

/* ══════════════════════════════════════════════════════════════
 * EDITOR IFRAME MODAL (Session 5)
 * ══════════════════════════════════════════════════════════════ */

.ajt-bs-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100070;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ajtBsFadeIn 0.2s ease;
}

.ajt-bs-editor-container {
    width: 95vw;
    height: 90vh;
    background: var(--ajt-card-bg, #fff);
    border-radius: var(--ajt-radius, 10px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    position: relative;
}

.ajt-bs-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--ajt-gray-50, #f9fafb);
    border-bottom: 1px solid var(--ajt-card-border, #e5e7eb);
    flex-shrink: 0;
}

.ajt-bs-editor-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--ajt-gray-800, #1f2937);
}

.ajt-bs-editor-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ajt-bs-editor-connect {
    font-size: 12px;
    font-weight: 600;
    color: var(--ajt-plum, #A04398);
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid var(--ajt-plum-light, #C06AB9);
    border-radius: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}

.ajt-bs-editor-connect:hover {
    background: rgba(160, 67, 152, 0.08);
    color: var(--ajt-plum-dark, #8A3784);
}

.ajt-bs-editor-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--ajt-gray-400, #9ca3af);
    padding: 0 4px;
    line-height: 1;
}

.ajt-bs-editor-close:hover {
    color: var(--ajt-gray-700, #374151);
}

.ajt-bs-editor-iframe {
    flex: 1;
    width: 100%;
    border: none;
}

.ajt-bs-editor-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--ajt-gray-400, #9ca3af);
    font-size: 14px;
    pointer-events: none;
}

/* ── Sidebar Action Buttons ───────────────────────────────── */

.ajt-bs-sidebar-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--ajt-card-border, #e5e7eb);
}

.ajt-bs-sidebar-actions .button {
    font-size: 11px;
    padding: 2px 8px;
    min-height: 24px;
}

/* ══════════════════════════════════════════════════════════════
 * SESSION 6 — POLISH & INLINE EDIT
 * ══════════════════════════════════════════════════════════════ */

/* ── Inline Rename Input ──────────────────────────────────── */

.ajt-bs-rename-input {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid var(--ajt-independence, #534B62);
    border-radius: var(--ajt-radius-sm, 6px);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    color: var(--ajt-gray-900, #111827);
    outline: none;
    box-sizing: border-box;
}

/* ── Category Select on Card ──────────────────────────────── */

.ajt-bs-category-select {
    padding: 2px 6px;
    border: 1px solid var(--ajt-card-border, #e5e7eb);
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    background: var(--ajt-gray-50, #f9fafb);
    color: var(--ajt-gray-600, #4b5563);
    cursor: pointer;
    flex-shrink: 0;
    max-width: 120px;
    appearance: auto;
}

.ajt-bs-category-select:focus {
    border-color: var(--ajt-independence, #534B62);
    outline: none;
}

/* ── Sidebar Delete Buttons ───────────────────────────────── */

.ajt-bs-sidebar-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    padding: 0 2px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.ajt-bs-sidebar-page:hover .ajt-bs-sidebar-delete,
.ajt-bs-sidebar-chapter-title:hover .ajt-bs-sidebar-delete {
    opacity: 0.5;
}

.ajt-bs-sidebar-delete:hover {
    opacity: 1 !important;
}

/* ── Sidebar Label (flex with delete button) ──────────────── */

.ajt-bs-sidebar-page {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ajt-bs-sidebar-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chapter title already has display:flex from reader section;
   just push delete button to the right via margin-left:auto. */
.ajt-bs-sidebar-chapter-title .ajt-bs-sidebar-delete {
    margin-left: auto;
}

/* ── Card Title Cursor Hint ───────────────────────────────── */

.ajt-bs-card-title {
    cursor: default;
}

.ajt-bs-card-title:hover {
    cursor: text;
    text-decoration-style: dotted;
    text-decoration-line: underline;
    text-decoration-color: var(--ajt-gray-300, #d1d5db);
}
