/* ============================================
   BIẾN MÀU VÀ THIẾT ĐẶT CHUNG
   NOTE: All variables are now defined in _variables.css
   ============================================ */

/* ============================================
   CẤU HÌNH CHUNG
   ============================================ */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background-color: var(--bg-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ============================================
   MENU BAR
   ============================================ */

.menu-bar {
    /* Glassmorphism hiện đại */
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    height: 32px;
    align-items: center;
    padding: 0 var(--spacing-md);
    gap: var(--spacing-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 20000; /* cao hơn toolbar và dropdown */
}

.menu-item-container {
    position: relative;
}

.menu-button {
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(0,0,0,0.06);
    padding: 6px 10px;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
}
.menu-button:hover {
    background: rgba(255,255,255,0.8);
    box-shadow: 0 6px 12px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.menu-button:hover {
    background-color: var(--primary-blue-lightest);
    color: var(--primary-blue);
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--bg-white);
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    min-width: 160px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 100002;
    margin-top: 4px;
}

.menu-dropdown.open {
    display: block;
}

.menu-option {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: background-color 0.15s;
    color: var(--text-primary);
}

.menu-option:hover {
    background-color: var(--primary-blue-lightest);
    color: var(--primary-blue);
}

.menu-icon {
    font-size: var(--font-size-md);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}

.menu-icon svg {
    width: 100%;
    height: 100%;
}

.menu-label {
    flex: 1;
}

.menu-separator {
    height: 1px;
    background-color: #e0e0e0;
    margin: var(--spacing-xs) 0;
}

/* ============================================
   TOOLBAR (hiện đại)
   ============================================ */

.toolbar {
    /* Glassmorphism */
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    height: 64px;
    align-items: center;
    padding: 6px 12px;
    gap: 12px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    overflow-x: auto;
    z-index: 1000;
}

.toolbar-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.toolbar-button-container:hover {
    transform: translateY(-1px);
    background: rgba(255,255,255,0.7);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}

.toolbar-button-container.active {
    background: rgba(30,90,150,0.08);
    border: 1px solid rgba(30,90,150,0.25);
}

.toolbar-button {
    background: none;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    transition: all 0.15s;
}

.toolbar-button:hover {
    transform: scale(1.05);
}

.toolbar-icon {
    font-size: var(--font-size-xxl);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.toolbar-icon svg {
    width: 100%;
    height: 100%;
}

.toolbar-label {
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

/* ============================================
   CONTAINER CHÍNH
   ============================================ */

#container {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
    position: relative; /* để đặt các nút toggle panel */
}

/* ============================================
   FILE EXPLORER (LEFT PANEL)
   ============================================ */

#controls {
    /* Cố định flex-basis để tránh bị bóp khi expand */
    flex: 0 0 280px;
    width: 280px; /* fallback */
    background-color: var(--bg-white);
    border-right: 1px solid #d0d0d0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.05);
    transition: flex-basis 0.25s ease, width 0.25s ease;
    will-change: flex-basis, width;
}

/* Trạng thái thu gọn panel trái */
#controls.collapsed {
    flex-basis: 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
    overflow: hidden;
}

#controls h1 {
  font-size: var(--font-size-base);
    margin: var(--spacing-md) var(--spacing-md) var(--spacing-sm) var(--spacing-md);
    color: var(--primary-blue);
    font-weight: 600;
}

#controls p {
  font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin: 0 var(--spacing-md) var(--spacing-md) var(--spacing-md);
    line-height: 1.4;
}

#file-input {
    margin: var(--spacing-md);
    font-size: var(--font-size-sm);
    padding: 8px 12px;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255,255,255,0.65);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease;
}
#file-input:hover {
    transform: translateY(-1px);
    background: rgba(255,255,255,0.8);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}
#file-input::file-selector-button {
    padding: 6px 10px;
    border: none;
    margin-right: 10px;
    border-radius: 8px;
    background: var(--primary-blue);
    color: white;
    cursor: pointer;
}
#file-input::-webkit-file-upload-button {
    padding: 6px 10px;
    border: none;
    margin-right: 10px;
    border-radius: 8px;
    background: var(--primary-blue);
    color: white;
    cursor: pointer;
}


#file-explorer-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    border-top: 1px solid #e0e0e0;
}

#file-explorer-container h2 {
    font-size: var(--font-size-md);
    margin: 0 0 var(--spacing-md) 0;
    color: var(--primary-blue);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary-blue-lightest);
}

#file-explorer-output {
    max-height: 100%;
    overflow-y: auto;
}

/* ============================================
   FILE EXPLORER TREE (ThatOpen Style - Div Structure)
   ============================================ */

.spatial-tree {
    width: 100%;
    min-width: max-content;
    font-size: var(--font-size-sm);
}

/* Đảm bảo tree-item full width và không bị wrap - TẤT CẢ elements cùng width */
.tree-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    border-radius: 3px;
    margin: 2px 0;
    width: 100%;
    min-width: max-content;
    box-sizing: border-box;
}

/* Horizontal scroll cho panel-body chứa spatial-tree */
.panel-body.scrollable {
    overflow-x: auto;
    overflow-y: auto;
}

.viewer-left-3d .panel-body.scrollable,
.bim-view-left-file-explorer .panel-body {
    overflow-x: auto;
    overflow-y: auto;
}

/* Đảm bảo viewer-left-3d có horizontal scroll */
.viewer-left-3d {
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
}

.bim-view-left-file-explorer {
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
}

.tree-folder-item {
    font-weight: 500;
    background-color: var(--bg-light);
    border: 1px solid #e0e0e0;
}

.tree-folder-item:hover {
    background-color: var(--primary-blue-lightest);
    border-color: var(--primary-blue-lighter);
}

.tree-folder-item.expanded {
    background-color: var(--primary-blue-lightest);
    border-color: var(--primary-blue-lighter);
}

.tree-leaf-item {
    background-color: var(--bg-white);
    border: 1px solid #e0e0e0;
}

.tree-leaf-item:hover {
    background-color: #f9f9f9;
    border-color: var(--primary-blue-lighter);
}

.tree-leaf-item.selected {
    background-color: var(--primary-blue-lightest);
    border-color: var(--primary-blue-lighter);
    box-shadow: inset 0 0 3px rgba(30, 90, 150, 0.2);
}

.tree-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    transition: transform 0.15s;
    color: var(--primary-blue);
    flex-shrink: 0;
}

.tree-toggle svg {
    width: 100%;
    height: 100%;
}

.tree-toggle.open {
    transform: rotate(90deg);
}

.tree-toggle-spacer {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tree-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tree-icon svg {
    width: 100%;
    height: 100%;
}

.tree-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    min-width: max-content;
}

.tree-name {
    color: var(--text-primary);
    font-weight: 400;
    white-space: nowrap;
    /* Không truncate, cho phép full width */
}

.tree-folder-item .tree-name {
    font-weight: 500;
}

.tree-count {
    color: var(--text-light);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.tree-type {
    color: var(--text-light);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.tree-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.tree-checkbox svg {
    width: 100%;
    height: 100%;
}

.tree-children {
    display: none;
}

.tree-children[style*="block"] {
    display: block;
}

/* Legacy support - giữ lại cho backward compatibility */
.file-explorer-tree-container {
    width: 100%;
}

.file-explorer-tree,
.file-explorer-tree ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.file-explorer-tree li {
    margin: 0;
}

.item-checkbox {
    font-size: var(--font-size-sm);
    min-width: 14px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-checkbox svg {
    width: 14px;
    height: 14px;
}

.item-icon {
    font-size: var(--font-size-md);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
}

.item-icon svg {
    width: 100%;
    height: 100%;
}

.item-name {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-type {
    color: var(--text-light);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

/* ============================================
   VIEWER (CENTER)
   ============================================ */

#viewer-container {
    flex: 1 1 auto;
    background-color: #e8e8e8;
    min-width: 0; /* cho phép co giãn đúng trong flex */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================
   PROPERTIES PANEL (RIGHT)
   ============================================ */

#properties-container {
    /* Cố định flex-basis để tránh bị bóp khi expand */
    flex: 0 0 320px;
    width: 320px; /* fallback */
    background-color: var(--bg-white);
    border-left: 1px solid #d0d0d0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: -1px 0 3px rgba(0, 0, 0, 0.05);
    transition: flex-basis 0.25s ease, width 0.25s ease;
    will-change: flex-basis, width;
}

/* Trạng thái thu gọn panel phải */
#properties-container.collapsed {
    flex-basis: 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    border-left: none;
    overflow: hidden;
}

#properties-container h2 {
  font-size: var(--font-size-base);
    margin: var(--spacing-md) var(--spacing-md) var(--spacing-sm) var(--spacing-md);
    color: var(--primary-blue);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary-blue-lightest);
}

#properties-output {
    flex: 1;
    overflow-y: hidden;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
}

/* ============================================
   PROPERTY DETAIL
   ============================================ */

.property-detail-container {
    width: 100%;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.property-detail-header {
    border-bottom: 2px solid var(--primary-blue-lightest);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.property-detail-type {
  font-size: var(--font-size-base);
    color: var(--primary-blue);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.property-detail-name {
  font-size: var(--font-size-base);
    color: var(--text-primary);
    font-weight: 500;
}

.property-detail-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ============================================
   COLLAPSIBLE SECTION
   ============================================ */

.collapsible-section {
    margin-bottom: var(--spacing-sm);
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    background-color: var(--bg-white);
}

.collapsible-header {
    background-color: var(--bg-light);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    user-select: none;
    transition: background-color 0.15s;
    font-size: var(--font-size-base);
}

.collapsible-header:hover {
    background-color: #efefef;
}

.collapsible-toggle {
    display: inline-block;
    margin-right: var(--spacing-sm);
    font-size: var(--font-size-xs);
    transition: transform 0.15s;
    min-width: 12px;
}

.collapsible-title {
    flex: 1;
}

.collapsible-body {
    max-height: 2000px;
    overflow-y: auto;
    background-color: var(--bg-white);
    transition: max-height 0.3s ease-out;
}

/* ============================================
   PROPERTY SECTION
   ============================================ */

.property-section {
    margin-bottom: var(--spacing-sm);
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    background-color: var(--bg-white);
}

.property-section-header {
    background-color: var(--bg-light);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    user-select: none;
    transition: background-color 0.15s;
    font-size: var(--font-size-base);
}

.property-section-header:hover {
    background-color: #efefef;
}

.section-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: var(--spacing-sm);
    font-size: var(--font-size-xs);
    transition: transform 0.15s;
    min-width: 12px;
    width: 12px;
    height: 12px;
}

.section-toggle svg {
    width: 100%;
    height: 100%;
}

.section-name {
    flex: 1;
}

.empty-indicator {
    color: var(--text-light);
    font-size: var(--font-size-xs);
    font-weight: normal;
    margin-left: var(--spacing-sm);
}

.property-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: var(--bg-white);
}

.property-section-content.open {
    max-height: 2000px;
    overflow-y: auto;
}

.property-item-row {
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid #f0f0f0;
    font-size: var(--font-size-xs);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.property-item-row:last-child {
    border-bottom: none;
}

.property-item-row strong {
    color: var(--text-primary);
    font-weight: 600;
  font-size: var(--font-size-base);
}

.property-value-text {
    color: var(--text-secondary);
    word-break: break-word;
    white-space: pre-wrap;
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: var(--font-size-xs);
    background-color: var(--bg-light);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 2px;
    display: block;
    line-height: 1.4;
}

.empty-row {
    padding: var(--spacing-md) !important;
    text-align: center;
}

.empty-text {
    color: var(--text-light);
    font-style: italic;
    font-size: var(--font-size-xs);
}

.no-data {
    color: var(--text-light);
  font-size: var(--font-size-xs);
    text-align: center;
    padding: var(--spacing-lg);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #c0c0c0;
    border-radius: 4px;
    transition: background-color 0.15s;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-blue-lighter);
}

/* ============================================
   PANEL TOGGLE BUTTONS (Thu gọn/mở rộng panel)
   ============================================ */

.panel-toggle-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.06);
    background: rgba(255,255,255,0.7);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1200;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}
.panel-toggle-button:hover {
    transform: translateY(-50%) scale(1.05);
    background: rgba(255,255,255,0.85);
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}
.panel-toggle-left {
    left: 0; /* sẽ bị override bằng JS theo width thực tế của panel trái */
}
.panel-toggle-right {
    right: 0; /* sẽ bị override bằng JS theo width thực tế của panel phải */
}
.panel-toggle-button svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   RESPONSIVE & UTILITY
   ============================================ */

@media (max-width: 1200px) {
    #controls {
        width: 240px;
    }
    
    #properties-container {
        width: 280px;
    }
}

@media (max-width: 768px) {
    #controls,
    #properties-container {
        width: 200px;
    }
    
    .toolbar {
        height: 60px;
    }
}

/* Ẩn scrollbar nhưng vẫn có thể scroll */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ============================================
   IFC FILE EXPLORER — custom plain-HTML tree
   ============================================ */

#file-explorer-output {
  background: var(--bg-surface);
  font-family: var(--font-family-primary);
  font-size: var(--font-size-xs);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Shell ── */
.ift-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── Controls ── */
.ift-controls {
  flex-shrink: 0;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-surface);
}

.ift-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-color);
  font-size: var(--font-size-xs);
  font-family: var(--font-family-primary);
  outline: none;
}
.ift-search:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(0,102,204,0.12);
}

.ift-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.ift-filter-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ift-filter-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  line-height: 1.2;
}

.ift-select {
  height: 26px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-color);
  font-size: var(--font-size-xs);
  font-family: var(--font-family-primary);
  padding: 0 4px;
  outline: none;
  cursor: pointer;
}
.ift-select:focus { border-color: var(--color-primary); }

.ift-reset-btn {
  height: 24px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted, #6b7280);
  font-size: var(--font-size-xs);
  font-family: var(--font-family-primary);
  font-weight: 500;
  cursor: pointer;
}
.ift-reset-btn:hover { background: var(--bg-hover); color: var(--text-color); }

/* ── Loading ── */
.ift-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--text-muted, #9ca3af);
}
.ift-loading-text {
  font-size: var(--font-size-xs);
}

/* ── Tree container ── */
.ift-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  min-height: 0;
  padding: 4px 0;
}

/* ── Tree rows ── */
.ift-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding-top: 1px;
  padding-bottom: 1px;
  padding-right: 8px;
  cursor: pointer;
  user-select: none;
  border-left: 2px solid transparent;
  white-space: nowrap;
}
.ift-row:hover {
  background: rgba(0, 102, 204, 0.05);
}
.ift-row--selected {
  background: rgba(0, 102, 204, 0.08) !important;
  border-left-color: var(--color-primary, #0066cc) !important;
}

/* ── Caret ── */
.ift-caret {
  flex-shrink: 0;
  width: 14px;
  font-size: 10px;
  color: var(--text-muted, #9ca3af);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Label ── */
.ift-label {
  flex: 1;
  font-size: var(--font-size-xs);
  color: var(--text-color, #111827);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Search match highlight */
.ift-match {
  background: #fef08a;
  color: #1a1a1a;
  border-radius: 2px;
  padding: 0 1px;
}

/* Search: dim non-matching rows */
.ift-row--search-miss {
  opacity: 0.3;
}
.ift-row--search-match .ift-label {
  color: var(--text-color, #111827);
}

/* ── Eye icon ── */
.ift-eye {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #9ca3af);
  opacity: 0;
  cursor: pointer;
  border-radius: 3px;
  padding: 1px;
  transition: opacity 0.1s, color 0.1s;
}
.ift-eye svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.ift-row:hover .ift-eye {
  opacity: 1;
}
.ift-eye:hover {
  color: var(--color-primary, #0066cc);
  background: rgba(0,102,204,0.08);
}
.ift-eye--ghosted {
  opacity: 1 !important;
  color: var(--text-muted, #9ca3af);
}
.ift-eye--ghosted:hover {
  color: var(--color-primary, #0066cc);
}
/* Ghosted rows: dim the label */
.ift-row:has(.ift-eye--ghosted) .ift-label {
  opacity: 0.4;
  font-style: italic;
}

/* ── Toolbar row (reset + tree actions) ── */
.ift-toolbar-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ift-toolbar-row .ift-reset-btn {
  flex: 1;
}

/* ── Tree action buttons (Collapse/Expand All) ── */
.ift-tree-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.ift-action-btn {
  width: 26px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ift-action-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.ift-action-btn:hover {
  background: var(--bg-hover);
  color: var(--color-primary, #0066cc);
  border-color: var(--color-primary, #0066cc);
}

/* ── IFT resize handle (right edge of file-explorer panel) ── */
.ift-resize-handle {
  flex-shrink: 0;
  width: 4px;
  height: 100%;
  background: transparent;
  cursor: col-resize;
  user-select: none;
  position: relative;
  transition: background-color 0.15s;
}
.ift-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background 0.15s;
}
.ift-resize-handle--hovered::after {
  background: var(--color-primary, #0066cc);
  opacity: 0.35;
}
.ift-resize-handle--resizing::after {
  background: var(--color-primary, #0066cc);
  opacity: 0.8;
}

/* ── Custom dropdown ── */
.ift-dropdown {
  position: relative;
  width: 100%;
  font-size: var(--font-size-xs);
  font-family: var(--font-family-primary);
}

.ift-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-color);
  cursor: pointer;
  user-select: none;
  gap: 4px;
  transition: border-color 0.15s;
}
.ift-dropdown-trigger:hover {
  border-color: var(--color-primary, #0066cc);
}
.ift-dropdown--open .ift-dropdown-trigger {
  border-color: var(--color-primary, #0066cc);
  box-shadow: 0 0 0 2px rgba(0,102,204,0.12);
}

.ift-dropdown-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-xs);
}

.ift-dropdown-arrow {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted, #9ca3af);
  line-height: 1;
}

.ift-dropdown-menu {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 180px;
  overflow-y: auto;
  padding: 2px 0;
}

.ift-dropdown-item {
  padding: 5px 10px;
  font-size: var(--font-size-xs);
  color: var(--text-color);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
}
.ift-dropdown-item:hover {
  background: rgba(0,102,204,0.06);
}
.ift-dropdown-item--active {
  color: var(--color-primary, #0066cc);
  font-weight: 600;
  background: rgba(0,102,204,0.06);
}

/* ── Empty state ── */
.ift-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted, #9ca3af);
  font-size: var(--font-size-xs);
}

/* ============================================
   CDE NAVIGATOR V3 STYLES
   Following ISO 19650 / QĐ 348/BXD standards
   NOTE: CDE variables are now defined in _variables.css
   ============================================ */

/* Topbar */
.cde-topbar {
  height: 52px;
  background: var(--cde-surface);
  border-bottom: 1.5px solid var(--cde-border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  z-index: 100;
}

.cde-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--cde-text2);
  flex-shrink: 0;
}

.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--cde-text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.logo-text {
  font-family: var(--font-family-primary);
  font-weight: 500;
}

.t-sep {
  width: 1px;
  height: 18px;
  background: var(--cde-border);
  flex-shrink: 0;
}

.cde-proj-info {
  font-size: var(--font-size-base);
  color: var(--cde-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cde-proj-info .proj-name {
  color: var(--cde-text);
  font-weight: 600;
}

.badge {
  font-family: var(--font-family-primary, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  font-size: var(--font-size-base);
  font-weight: 600;
  background: var(--cde-s2);
  border: 1px solid var(--cde-border);
  color: var(--cde-text2);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: .05em;
}

.cde-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.t-btn {
  /* font-family: var(--font-family-mono); */
  font-size: var(--cde-fs-sm);
  padding: 8px 14px;
  border-radius: 6px;
  border: 1.5px solid var(--cde-border2);
  background: var(--cde-surface);
  color: var(--cde-text2);
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.t-btn:hover {
  background: var(--cde-s2);
  border-color: var(--cde-text2);
  color: var(--cde-text);
}

.t-btn.primary {
  background: var(--cde-blue);
  border-color: var(--cde-blue);
  color: #fff;
}

.t-btn.primary:hover {
  background: #0e51a0;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cde-search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 320px;
  background: var(--cde-surface);
  border: 1px solid var(--cde-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1200;
  overflow: hidden;
}

.cde-search-suggest-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
}

.cde-search-suggest-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cde-search-suggest-item:hover,
.cde-search-suggest-item.active {
  background: var(--cde-s2);
}

.cde-search-suggest-title {
  font-size: var(--cde-fs-sm);
  font-weight: 700;
  color: var(--cde-text);
  line-height: 1.35;
}

.cde-search-suggest-sub {
  font-size: var(--cde-fs-xs);
  color: var(--cde-text2);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cde-search-suggest-empty {
  padding: 10px 12px;
  font-size: var(--cde-fs-sm);
  color: var(--cde-text2);
}

.cde-search-scope-btn {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--cde-border);
  background: var(--cde-s2);
  color: var(--cde-blue);
  font-size: var(--cde-fs-sm);
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.cde-search-scope-btn:hover {
  background: #e8f1fb;
}

.search-wrap svg {
  position: absolute;
  left: 9px;
  color: var(--cde-muted);
  pointer-events: none;
}

.search-input {
  background: var(--cde-s2);
  border: 1.5px solid var(--cde-border);
  border-radius: 6px;
  color: var(--cde-text);
  /* font-family: var(--font-family-mono); */
  font-size: var(--cde-fs-sm);
  padding: 8px 12px 8px 34px;
  width: 220px;
  outline: none;
  transition: all .15s;
}

.search-input:focus {
  border-color: var(--cde-blue);
  box-shadow: 0 0 0 3px rgba(20,96,184,.12);
  width: 260px;
  background: var(--cde-surface);
}

.search-input::placeholder {
  color: var(--cde-muted2);
}

/* Filter Bar */
.filterbar {
  height: 44px;
  background: var(--cde-surface);
  border-bottom: 1.5px solid var(--cde-border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 8px;
  flex-shrink: 0;
}

.fb-lbl {
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  color: var(--cde-text2);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-right: 6px;
}

.zf {
  /* font-family: var(--font-family-mono); */
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  letter-spacing: .03em;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--cde-border2);
  background: transparent;
  cursor: pointer;
  transition: all .13s;
}

.zf[data-z="ALL"] { color: var(--cde-text2); }
.zf[data-z="WIP"] { color: var(--cde-wip); }
.zf[data-z="SHARED"] { color: var(--cde-shared); }
.zf[data-z="PUBLISH"] { color: var(--cde-publish); }
.zf[data-z="ARCHIVE"] { color: var(--cde-archive); }

.zf.on[data-z="ALL"] { background: var(--cde-s3); border-color: var(--cde-border2); }
.zf.on[data-z="WIP"] { background: var(--cde-wip-bg); border-color: var(--cde-wip-b); }
.zf.on[data-z="SHARED"] { background: var(--cde-shared-bg); border-color: var(--cde-shared-b); }
.zf.on[data-z="PUBLISH"] { background: var(--cde-publish-bg); border-color: var(--cde-publish-b); }
.zf.on[data-z="ARCHIVE"] { background: var(--cde-archive-bg); border-color: var(--cde-archive-b); }

.zf:not(.on) { opacity: .42; }

.fb-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sf {
  /* font-family removed - using var(--font-family-mono) from root */
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  letter-spacing: .03em;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1.5px solid;
  cursor: pointer;
  transition: all .13s;
  opacity: .5;
}

.sf.on { opacity: 1; }

.sf[data-s="S0"] { color: #777; border-color: #ccc; }
.sf.on[data-s="S0"] { background: #f5f5f5; }

.sf[data-s="S1"] { color: var(--cde-shared); border-color: var(--cde-shared-b); }
.sf.on[data-s="S1"] { background: var(--cde-shared-bg); }

.sf[data-s="S2"] { color: #1460b8; border-color: #99c0f0; }
.sf.on[data-s="S2"] { background: #e8f2ff; }

.sf[data-s="S3"] { color: #0e4fa0; border-color: #88b8f0; }
.sf.on[data-s="S3"] { background: #deeeff; }

.sf[data-s="S4"] { color: var(--cde-red); border-color: #f0b0a8; }
.sf.on[data-s="S4"] { background: #fff0ee; }

.sf[data-s="A1"] { color: var(--cde-publish); border-color: var(--cde-publish-b); }
.sf.on[data-s="A1"] { background: var(--cde-publish-bg); }

.sf[data-s="B1"] { color: var(--cde-wip); border-color: var(--cde-wip-b); }
.sf.on[data-s="B1"] { background: var(--cde-wip-bg); }

.fb-sep {
  width: 1px;
  height: 18px;
  background: var(--cde-border);
  margin: 0 4px;
}

/* Body Layout */
.cde-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.cde-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--cde-surface);
  border-right: 1px solid var(--cde-border);
  overflow-y: auto;
  padding: 8px 0 24px;
}

.cde-sidebar::-webkit-scrollbar { width: 4px; }
.cde-sidebar::-webkit-scrollbar-thumb { background: var(--cde-border2); border-radius: 2px; }

.sb-zone { margin-bottom: 2px; }

.sb-zone-hdr {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px 6px 8px;
  cursor: pointer;
  user-select: none;
  border-left: 3px solid transparent;
  transition: background .1s;
}

.sb-zone-hdr:hover { background: var(--cde-s2); }
.sb-zone-hdr.active { background: var(--cde-s2); }

.sb-zone[data-zone="WIP"] .sb-zone-hdr { border-color: var(--cde-wip); }
.sb-zone[data-zone="SHARED"] .sb-zone-hdr { border-color: var(--cde-shared); }
.sb-zone[data-zone="PUBLISH"] .sb-zone-hdr { border-color: var(--cde-publish); }
.sb-zone[data-zone="ARCHIVE"] .sb-zone-hdr { border-color: var(--cde-archive); }

/* Zone hidden state - controlled by zone filter bar buttons */
.sb-zone.zone-hidden {
  display: none;
}

/* CDE Sidebar Chevron - larger for easier clicking */
.sb-chv {
  color: var(--cde-muted2);
  transition: transform .18s, background .15s, color .15s;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Tăng kích thước vùng click */
  margin-right: 2px;
}

.sb-chv:hover {
  background: var(--cde-s2);
  color: var(--cde-blue);
}

.sb-chv.open { transform: rotate(90deg); }

/* CDE Sidebar Resize Handle */
.cde-sidebar-resize-handle {
  position: relative;
  width: 2px;
  height: 100%;
  background: transparent;
  cursor: col-resize;
  user-select: none;
  flex-shrink: 0;
  transition: background-color 0.15s, opacity 0.15s;
}

.cde-sidebar-resize-handle.hovered {
  background: var(--cde-blue);
  opacity: 0.3;
}

.cde-sidebar-resize-handle.resizing {
  background: var(--cde-blue);
  opacity: 0.8;
}

/* Double-click animation to reset sidebar width */
@keyframes sidebarReset {
  0% { width: var(--current-width, 230px); }
  50% { width: calc(var(--current-width, 230px) * 0.95); }
  100% { width: 230px; }
}

.cde-sidebar.resetting {
  animation: sidebarReset 0.3s ease;
}

/* Chevron placeholder - same size as chevron for alignment */
.sb-chv-placeholder {
  display: inline-block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Sidebar item toggle area - always reserve space for chevron */
.sb-item-toggle {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s, color .15s;
}

.sb-item-toggle:hover {
  background: var(--cde-s2);
  color: var(--cde-blue);
}

.sb-item-toggle svg {
  width: 16px;
  height: 16px;
}

.sb-item-toggle.open svg {
  transform: rotate(90deg);
}

.sb-zone-label {
  /* font-size: var(--font-size-xs); */
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-zone[data-zone="WIP"] .sb-zone-label { color: var(--cde-wip); }
.sb-zone[data-zone="SHARED"] .sb-zone-label { color: var(--cde-shared); }
.sb-zone[data-zone="PUBLISH"] .sb-zone-label { color: var(--cde-publish); }
.sb-zone[data-zone="ARCHIVE"] .sb-zone-label { color: var(--cde-archive); }

.sb-cnt {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  color: var(--cde-muted);
  flex-shrink: 0;
}

.sb-body { display: none; }
.sb-body.open { display: block; }

.sb-item { display: flex; align-items: center; gap: 5px; padding: 5px 10px; cursor: pointer; border-left: 2px solid transparent; transition: all .1s; color: var(--cde-text2); white-space: nowrap; overflow: hidden; }

.sb-item:hover { background: var(--cde-s2); }
.sb-item.sel { background: var(--cde-shared-bg); border-left-color: var(--cde-shared); color: var(--cde-shared); font-weight: 600; }
.sb-item.item-hidden { display: none; }
.sb-item svg { flex-shrink: 0; }
.sb-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Sidebar more button (3 dots) */
.sb-more-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cde-text2);
}

.sb-item:hover .sb-more-btn {
  opacity: 1;
}

.sb-more-btn:hover {
  background: var(--cde-s1);
}

.sb-more-btn svg {
  display: block;
}

/* Subfolder children - collapsible */
.sb-children { display: none; }
.sb-children.open { display: block; }

.sb-root {
  /* font-size: var(--font-size-xs); */
  font-weight: 700;
  color: var(--cde-text);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  border-bottom: 1px solid var(--cde-border);
  cursor: pointer;
}

.sb-root:hover { background: var(--cde-s2); }
.sb-root.sel { color: var(--cde-blue); }

/* Main Content */
.cde-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Breadcrumb + Actions */
.content-top {
  height: 44px;
  background: var(--cde-surface);
  border-bottom: 1px solid var(--cde-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-base);
  color: var(--cde-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.bc-part { color: var(--cde-text2); cursor: pointer; white-space: nowrap; }
.bc-part:hover { color: var(--cde-blue); text-decoration: underline; }
.bc-part.cur { color: var(--cde-text); font-weight: 600; cursor: default; }
.bc-part.cur:hover { color: var(--cde-text); text-decoration: none; }
.bc-sep { color: var(--cde-muted2); }

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

.act-btn {
  font-size: var(--cde-fs-sm);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1.5px solid var(--cde-border);
  background: var(--cde-surface);
  color: var(--cde-text2);
  cursor: pointer;
  transition: all .13s;
  display: flex;
  align-items: center;
  gap: 6px;
  /* font-family: var(--font-family-primary); */
  font-weight: 500;
}

.act-btn:hover { background: var(--cde-s2); border-color: var(--cde-border2); }
.act-btn.prim { background: var(--cde-blue); border-color: var(--cde-blue); color: #fff; }
.act-btn.prim:hover { background: #0e51a0; }

.sort-info {
  font-size: var(--cde-fs-sm);
  color: var(--cde-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

/* Table */
.table-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--cde-surface);
}
.table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--cde-border2); border-radius: 3px; }

#cde-main-table { width: 100%; border-collapse: collapse; table-layout: fixed; }

#cde-main-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--cde-s2);
}

#cde-main-table thead tr { border-bottom: 2px solid var(--cde-border2); }

#cde-main-table th {
  padding: 0;
  font-size: var(--cde-fs-sm);
  font-weight: 700;
  color: var(--cde-text2);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  user-select: none;
  position: relative;
}

/* Column resize handle */
.resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  z-index: 10;
  transition: background .15s;
}

.resize-handle:hover,
.resize-handle.active {
  background: var(--cde-blue);
}

.th-inner {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background .1s;
  height: 40px;
  user-select: none;
}

.th-inner:hover {
  background: var(--cde-s3);
}

/* Sort indicator */
.th-inner .sort-arrow {
  opacity: 0.3;
  font-size: var(--font-size-xs);
}

#cde-main-table th.sorted .sort-arrow {
  opacity: 1;
  color: var(--cde-blue);
}

#cde-main-table th.sort-asc .sort-arrow::before {
  content: '↑';
}

#cde-main-table th.sort-desc .sort-arrow::before {
  content: '↓';
}

.th-inner:hover { background: var(--cde-s3); color: var(--cde-text2); }
th.sorted .th-inner { color: var(--cde-blue); }
.sort-arrow { opacity: .4; font-size: var(--font-size-xs); margin-left: 2px; }
th.sorted .sort-arrow { opacity: 1; color: var(--cde-blue); }

/* Column Widths */
.col-check { width: 36px; }
.col-name { width: 280px; }
/* Frozen first column - Name column stays fixed when scrolling horizontally */
#cde-main-table th.col-name {
  position: sticky;
  left: 0;
  z-index: 15;
  background: var(--cde-s2);
  border-right: 2px solid var(--cde-border2);
}
#cde-main-table td.col-name {
  position: sticky;
  left: 0;
  z-index: 14;
  background: var(--cde-surface);
  border-right: 2px solid var(--cde-border2);
}
#cde-main-table tr:hover td.col-name {
  background: var(--cde-s2);
}
.col-code { width: 200px; }
.col-status { width: 80px; }
.col-ver { width: 80px; }
.col-zone { width: 95px; }
.col-type { width: 56px; }
.col-size { width: 72px; }
.col-updated { width: 130px; }
.col-updby { width: 110px; }
.col-review { width: 100px; }
.col-access { width: 90px; }
.col-more { width: 100px; }

/* Table Rows */
#cde-main-table tbody tr {
  border-bottom: 1px solid var(--cde-border);
  transition: background .08s;
  cursor: pointer;
}

#cde-main-table tbody tr:hover { background: var(--cde-s2); }
#cde-main-table tbody tr.tr-sel { background: #eef5ff; }
#cde-main-table tbody tr.tr-hidden { display: none; }

/* Zone Header Row */
#cde-main-table tbody tr.zone-row {
  background: var(--cde-s2);
  cursor: default;
  border-bottom: 2px solid var(--cde-border2);
}

#cde-main-table tbody tr.zone-row td {
  padding: 6px 10px;
  font-weight: 700;
  font-size: var(--font-size-xs);
  letter-spacing: .04em;
}

/* Folder Row */
#cde-main-table tbody tr.folder-row td .row-name { font-weight: 600; color: var(--cde-text); }

#cde-main-table td {
  padding: 0;
  vertical-align: middle;
  overflow: hidden;
}

.td-inner {
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  overflow: hidden;
}

.td-name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }

.convert-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  color: #b86e00;
  background: #fff3e0;
  border: 1px solid #ffe0a0;
  border-radius: 10px;
  padding: 1px 7px 1px 5px;
  white-space: nowrap;
}
.convert-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1.5px solid #f0c060;
  border-top-color: #b86e00;
  border-radius: 50%;
  animation: convert-spin 0.8s linear infinite;
}
@keyframes convert-spin { to { transform: rotate(360deg); } }

/* Uploading file badge */
.file-status-uploading {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  color: #1976d2;
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 10px;
  padding: 1px 7px 1px 5px;
  white-space: nowrap;
}
.upload-spinner {
  display: inline-block;
  font-size: 9px;
  animation: upload-float 0.6s ease-in-out infinite;
}
@keyframes upload-float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-2px); }
}

/* Uploading file row styling */
tr.row-uploading {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}
tr.row-uploading .row-name {
  cursor: not-allowed;
}
tr.row-uploading .row-name:hover {
  color: inherit;
  text-decoration: none;
}

/* Converting file row styling */
tr.converting {
  opacity: 0.6;
  cursor: not-allowed;
}
tr.converting .row-name {
  cursor: not-allowed;
}
tr.converting .row-name:hover {
  color: inherit;
  text-decoration: none;
}

.row-name {
  font-size: var(--cde-fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, text-decoration 0.15s ease;
}

.row-name:hover {
  color: var(--cde-blue);
  text-decoration: underline;
}

.row-code {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  color: var(--cde-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-ver {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  font-weight: 700;
}

.row-size {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  color: var(--cde-text2);
  font-weight: 500;
}

.row-date { font-size: var(--cde-fs-sm); color: var(--cde-text2); white-space: nowrap; font-weight: 500; }
.row-by { font-size: var(--cde-fs-sm); color: var(--cde-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }

/* Revision / checkedOut / access — previously missing, caused font inheritance from body */
.row-rev {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  color: var(--cde-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-co {
  font-size: var(--cde-fs-sm);
  color: var(--cde-text2);
  font-weight: 500;
  white-space: nowrap;
}
.row-access {
  font-size: var(--cde-fs-sm);
  color: var(--cde-text2);
  font-weight: 500;
}

.dash { color: var(--cde-muted2); font-family: var(--font-family-mono); font-size: var(--cde-fs-sm); }

/* Chips */
.chip {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip-S0 { background: #f4f4f4; border-color: #ccc; color: #888; }
.chip-S1 { background: var(--cde-shared-bg); border-color: var(--cde-shared-b); color: var(--cde-shared); }
.chip-S2 { background: #e8f2ff; border-color: #99c0f0; color: #1460b8; }
.chip-S3 { background: #deeeff; border-color: #88b8f0; color: #0e4fa0; }
.chip-S4 { background: #fff0ee; border-color: #f0b0a8; color: var(--cde-red); }
.chip-A1 { background: var(--cde-publish-bg); border-color: var(--cde-publish-b); color: var(--cde-publish); }
.chip-B1 { background: var(--cde-wip-bg); border-color: var(--cde-wip-b); color: var(--cde-wip); }
.chip-none { display: none; }

/* Zone Pill */
.zone-pill {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  letter-spacing: .05em;
  padding: 3px 9px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
}

.zp-WIP { background: var(--cde-wip); }
.zp-SHARED { background: var(--cde-shared); }
.zp-PUBLISH { background: var(--cde-publish); }
.zp-ARCHIVE { background: var(--cde-archive); }

/* File Type Dot */
.ext-dot {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* Tags pill */
.tag-pill {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--cde-blue-bg);
  color: var(--cde-blue);
  border: 1px solid #c8daf5;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Description cell */
.td-desc {
  font-size: var(--cde-fs-sm);
  color: var(--cde-text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Review / Access */
.rev-chip {
  font-size: var(--cde-fs-xs);
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}

.rev-none { color: var(--cde-muted2); border-color: var(--cde-muted2); background: transparent; }
.rev-approved { color: var(--cde-publish); border-color: var(--cde-publish-b); background: var(--cde-publish-bg); }
.rev-pending { color: var(--cde-wip); border-color: var(--cde-wip-b); background: var(--cde-wip-bg); }
.rev-rejected { color: var(--cde-red); border-color: #f0b0a8; background: #fff0ee; }

/* Indent */
.indent-1 { padding-left: 18px; }
.indent-2 { padding-left: 34px; }
.indent-3 { padding-left: 50px; }

.move-picker-field {
  margin-bottom: 8px;
}

.move-picker-toolbar {
  margin-bottom: 8px;
}

.move-tree-search {
  min-height: 34px;
}

.move-tree {
  border: 1px solid var(--cde-border2);
  border-radius: 8px;
  background: var(--cde-surface);
  max-height: 50vh;
  min-height: 260px;
  overflow: auto;
  padding: 6px;
}

.move-tree-item {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--cde-text2);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  padding-left: calc(10px + var(--move-depth, 0) * 18px);
  transition: background-color .12s ease, color .12s ease;
}

.move-tree-item:hover {
  background: var(--cde-s2);
  color: var(--cde-text);
}

.move-tree-item.selected {
  background: var(--cde-blue-bg);
  color: var(--cde-blue);
  font-weight: 600;
}

.move-tree-folder-icon {
  flex-shrink: 0;
  color: var(--cde-muted2);
}

.move-tree-item.selected .move-tree-folder-icon {
  color: var(--cde-blue);
}

.move-tree-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.move-dialog-hint {
  margin-top: 8px;
  font-size: var(--cde-fs-xs);
  color: var(--cde-muted2);
}

/* Checkbox */
input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--cde-blue);
}

/* Row Actions */
.more-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cde-muted);
  opacity: 0;
  transition: all .1s;
}

tr:hover .more-btn { opacity: 1; }
.more-btn:hover { background: var(--cde-s3); color: var(--cde-text); }

/* ============================================
   CDE DRAWER - DOCKED STATE
   ============================================ */

.cde-drawer-wrapper {
  position: relative;
}

.drawer {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 380px;
  max-width: 90%;
  background: var(--cde-surface);
  border-left: 1.5px solid var(--cde-border);
  box-shadow: -4px 0 24px rgba(0,0,0,.1);
  z-index: 300;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  border-radius: 8px 0 0 8px;
}

/* Drawer docked - peek mode */
.drawer.docked {
  transform: translateX(calc(100% - 44px));
}

/* Drawer docked layout - drawer is sibling of section-data in project-main */

/* project-main needs relative positioning to contain absolute drawer */
html body #app-container .project-detail-view .project-main {
  position: relative !important;
}

/* section-data when drawer is docked - resize to leave room for drawer on right */
html body #app-container .project-detail-view .project-main #section-data {
  transition: width 0.3s ease;
}

/* Drawer when docked - sibling of section-data, positioned absolutely on right */
html body #app-container .project-detail-view .project-main > .drawer.docked {
  position: absolute !important;
  right: 0 !important;
  top: 0 !important;
  width: 350px !important;
  height: 100% !important;
  flex-shrink: 0 !important;
  transform: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  z-index: 100 !important;
  opacity: 1 !important;
  pointer-events: all !important;
  margin-top: 0 !important;
}

/* Hide peek UI when in docked layout mode */
html body #app-container .project-detail-view .project-shell #section-data.drawer-docked-layout > .drawer.docked .drawer-peek {
  display: none;
}

.drawer.docked .drawer-inner {
  opacity: 0;
  pointer-events: none;
}

.drawer.docked:hover .drawer-inner {
  opacity: 1;
  pointer-events: all;
}

.drawer.docked .drawer-peek {
  display: flex;
}

.drawer-peek {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 80px;
  background: var(--cde-surface);
  border: 1px solid var(--cde-border);
  border-left: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--cde-muted);
}

.drawer-peek:hover {
  background: var(--cde-s2);
  color: var(--cde-text);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity .15s;
}

.drawer-top {
  position: relative;
  padding: 16px 18px 14px;
  border-bottom: 1.5px solid var(--cde-border);
  background: var(--cde-s2);
  flex-shrink: 0;
}

.drawer-zone-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-right: 42px; }

.drawer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1.5px solid var(--cde-border);
  background: var(--cde-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cde-muted);
  transition: all .1s;
  z-index: 10;
}

.drawer-close:hover { background: var(--cde-s3); color: var(--cde-text); }

.drawer-dock-btn {
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 48px;
  background: var(--cde-surface);
  border: 1.5px solid var(--cde-border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cde-muted);
  z-index: 10;
  transition: all .15s;
}

.drawer-dock-btn:hover {
  background: var(--cde-s2);
  color: var(--cde-blue);
}

.drawer.docked .drawer-dock-btn {
  /* left: 0; */
  border-radius: 6px;
  background: var(--cde-blue);
  border-color: var(--cde-blue);
  color: #fff;
}

.drawer-name { font-size: var(--cde-fs-lg); font-weight: 700; line-height: 1.3; color: var(--cde-text); }
.drawer-code {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-xs);
  color: var(--cde-muted);
  margin-top: 4px;
  word-break: break-all;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 24px;
}

.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--cde-border2); border-radius: 2px; }

.d-sec { margin-bottom: 16px; }

.d-sec-title {
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cde-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--cde-border);
}

.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }

.d-card {
  background: var(--cde-s2);
  border: 1px solid var(--cde-border);
  border-radius: 5px;
  padding: 9px 11px;
}

.d-card.full { grid-column: 1 / -1; }

.d-card-lbl {
  font-size: var(--cde-fs-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--cde-muted);
  margin-bottom: 5px;
}

.d-card-val {
  font-family: var(--font-family-mono);
  font-size: var(--cde-fs-md);
  font-weight: 700;
  color: var(--cde-text);
}

.d-card-sub { font-size: var(--cde-fs-sm); color: var(--cde-text2); margin-top: 4px; font-family: var(--font-family-primary); font-weight: 500; }
.d-card-pretext { white-space: pre-wrap; font-size: var(--font-size-sm); font-family: var(--font-family-primary); font-weight: 400; }
.d-card-capitalize { text-transform: capitalize; }

/* Thumbnail for IFC files */
.d-card-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  height: 200px;
  background: var(--cde-s3);
  border-radius: 6px;
  margin-bottom: 12px;
}

.d-thumbnail-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
  object-fit: contain;
}

.ver-tl { display: flex; align-items: center; flex-wrap: wrap; }
.ver-n { display: flex; align-items: center; }
.ver-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

.ver-line { width: 12px; height: 2px; background: var(--cde-border2); }
.ver-past .ver-dot { border-color: var(--cde-border2); color: var(--cde-muted); background: var(--cde-s2); }
.ver-cur .ver-dot { border-color: var(--cde-shared); color: var(--cde-shared); background: var(--cde-shared-bg); }
.ver-fin .ver-dot { border-color: var(--cde-publish); color: var(--cde-publish); background: var(--cde-publish-bg); }

.acc-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--cde-border); font-size: var(--font-size-xs); }
.acc-row:last-child { border: none; }
.acc-role { flex: 1; color: var(--cde-text2); }

.acc-perm {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid transparent;
}

.p-full { background: #e8faf0; border-color: #7ecfa0; color: var(--cde-publish); }
.p-edit { background: var(--cde-shared-bg); border-color: var(--cde-shared-b); color: var(--cde-shared); }
.p-view { background: var(--cde-s2); border-color: var(--cde-border2); color: var(--cde-text2); }
.p-approve { background: var(--cde-wip-bg); border-color: var(--cde-wip-b); color: var(--cde-wip); }
.p-none { background: #fff0ee; border-color: #f0b0a8; color: var(--cde-red); }
.p-upload { background: var(--cde-archive-bg); border-color: var(--cde-archive-b); color: var(--cde-archive); }

.d-note {
  background: var(--cde-s2);
  border: 1px solid var(--cde-border);
  border-left: 3px solid var(--cde-border2);
  border-radius: 5px;
  padding: 9px 12px;
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  line-height: 1.65;
}

/* ── Expandable Version History (CDE drawer) ─────────────────────────────── */
.ver-history-wrap { padding: 4px 0; }

.ver-panel-cur {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  flex-wrap: wrap;
}
.ver-dot-cur {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  background: var(--cde-shared-bg);
  color: var(--cde-shared);
  border: 1.5px solid var(--cde-shared);
  flex-shrink: 0;
}
.ver-dot-old {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--cde-s2);
  color: var(--cde-muted);
  border: 1px solid var(--cde-border2);
  flex-shrink: 0;
}
.ver-cur-meta {
  flex: 1;
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ver-view-btn {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 4px;
  border: 1px solid var(--cde-shared);
  background: transparent;
  color: var(--cde-shared);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ver-view-btn:hover { background: var(--cde-shared); color: #fff; }
.ver-view-btn-disabled { opacity: 0.4; cursor: not-allowed; }
.ver-view-btn-disabled:hover { background: transparent; color: var(--cde-shared); }
.ver-expand-btn {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--cde-border);
  background: var(--cde-s2);
  color: var(--cde-text2);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: background .15s;
}
.ver-expand-btn:hover { background: var(--cde-border2); }

/* Version list panel */
.ver-list-panel {
  border: 1px solid var(--cde-border);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 4px;
}
.ver-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-xs);
}
.ver-table th {
  background: var(--cde-s2);
  color: var(--cde-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  font-size: 10px;
  padding: 4px 8px;
  text-align: left;
}
.ver-table td { padding: 5px 8px; border-top: 1px solid var(--cde-border2); }
.ver-table tr:first-child td { border-top: none; }
.ver-th-ver  { width: 80px; }
.ver-th-actions { text-align: right !important; }
.ver-td-ver { color: var(--cde-text); }
.ver-td-date { color: var(--cde-text2); }
.ver-td-actions {
  text-align: right;
  white-space: nowrap;
}
.ver-td-actions .ver-download-btn {
  color: var(--cde-shared);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}
.ver-td-actions .ver-view-btn {
  padding: 2px 8px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}
.ver-restore-btn {
  width: 20px;
  height: 20px;
  border: 1px solid var(--cde-border2);
  border-radius: 4px;
  background: var(--cde-s1);
  color: var(--cde-text2);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ver-restore-btn:hover {
  background: var(--cde-border2);
}
.ver-restore-btn:disabled {
  opacity: .6;
  cursor: default;
}
.ver-restore-btn-hide {
  visibility: hidden;
  pointer-events: none;
}
.ver-compare-bar {
  padding: 6px 8px;
  border-top: 1px solid var(--cde-border2);
  display: flex;
  justify-content: flex-end;
}
.ver-compare-btn {
  padding: 4px 14px;
  border-radius: 4px;
  border: 1.5px solid var(--cde-shared);
  background: var(--cde-shared);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ver-compare-btn:hover { background: var(--cde-shared-dark, var(--cde-shared)); opacity: .85; }

/* ── Drawer Edit Form ─────────────────────────────────────────────────────── */
.drawer-edit-form {
  padding: 4px 0;
}
.d-form-section-hd {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--cde-muted);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--cde-border2);
  margin-bottom: 10px;
}
.d-form-section-hd:first-child { padding-top: 2px; }
.d-form-section-ro {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
}
.d-form-static {
  font-size: var(--font-size-sm);
  color: var(--cde-text2);
  padding: 5px 8px;
  background: var(--cde-s2);
  border-radius: 4px;
  border: 1px solid var(--cde-border2);
  min-height: 28px;
  display: flex;
  align-items: center;
}
.d-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.d-form-row.d-form-full { grid-column: 1 / -1; }
.d-form-lbl {
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.d-form-sel, .d-form-inp {
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: var(--font-size-sm);
  background: var(--cde-bg);
  color: var(--cde-text);
  width: 100%;
  box-sizing: border-box;
}
.d-form-sel:focus, .d-form-inp:focus {
  outline: none;
  border-color: var(--cde-shared);
}
.d-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.d-btn {
  padding: 6px 14px;
  border-radius: 4px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .15s;
}
.d-btn:hover { opacity: .85; }
.d-btn-save {
  background: var(--cde-shared);
  color: #fff;
  border-color: var(--cde-shared);
}
.d-btn-cancel {
  background: transparent;
  color: var(--cde-text2);
  border-color: var(--cde-border);
}
/* ── Drawer Edit Button ──────────────────────────────────────────────────── */
.drawer-edit-btn {
  margin-left: auto;
  padding: 3px 10px;
  font-size: var(--font-size-sm);
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: var(--cde-text2);
  transition: all .15s;
  flex-shrink: 0;
}
.drawer-edit-btn:hover {
  background: var(--cde-s3);
  color: var(--cde-text);
  border-color: var(--cde-border2);
}

/* ── Drawer Form Checkbox Row ─────────────────────────────────────────────── */
.d-form-row-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.d-form-check {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--cde-shared);
}
.d-form-check-lbl {
  font-size: var(--font-size-sm);
  color: var(--cde-text);
  cursor: pointer;
}

/* ── Zone Transfer Panel (inline in drawer body) ─────────────────────────── */
.zt-panel {
  padding: 4px 0;
}
.zt-section-title {
  font-size: var(--font-size-xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cde-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--cde-border);
}
.zt-zone-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.zt-zone-btn {
  padding: 7px 6px;
  border-radius: 5px;
  border: 1.5px solid var(--cde-border);
  background: var(--cde-s2);
  cursor: pointer;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--cde-text2);
  text-align: center;
  transition: all .15s;
}
.zt-zone-btn:hover { border-color: var(--cde-shared); color: var(--cde-shared); }
.zt-zone-btn.zt-active { border-color: var(--cde-shared); background: var(--cde-shared-bg); color: var(--cde-shared); }
.zt-zone-btn.zt-wip    { border-color: var(--cde-wip);    }
.zt-zone-btn.zt-shared  { border-color: var(--cde-shared); }
.zt-zone-btn.zt-publish { border-color: var(--cde-publish);}
.zt-zone-btn.zt-archive { border-color: var(--cde-archive);}
.zt-zone-btn.zt-active.zt-wip    { background: var(--cde-wip-bg);     color: var(--cde-wip);    }
.zt-zone-btn.zt-active.zt-shared  { background: var(--cde-shared-bg);  color: var(--cde-shared); }
.zt-zone-btn.zt-active.zt-publish { background: var(--cde-publish-bg); color: var(--cde-publish);}
.zt-zone-btn.zt-active.zt-archive { background: var(--cde-archive-bg); color: var(--cde-archive);}
.zt-lbl {
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 4px;
}
.zt-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  opacity: .7;
}
.zt-folder-sel {
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: var(--font-size-sm);
  background: var(--cde-bg);
  color: var(--cde-text);
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
}
.zt-folder-sel:focus { outline: none; border-color: var(--cde-shared); }
/* ── Zone transfer folder tree ─────────────────────────────────────────────── */
.zt-tree-hint {
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  padding: 4px 0 6px;
}
#zt-folder-tree {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  padding: 4px 0;
  background: var(--cde-bg);
}
.zt-tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 3px;
  font-size: var(--font-size-sm);
  color: var(--cde-text);
  white-space: nowrap;
  transition: background .1s;
}
.zt-tree-row:hover { background: var(--cde-s2); }
.zt-tree-row.zt-tree-sel {
  background: var(--cde-selected-bg);
  color: var(--cde-shared);
  font-weight: 600;
}
.zt-tree-chevron {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 3px;
  transition: transform .15s, background .1s;
  color: var(--cde-muted);
}
.zt-tree-chevron:hover { background: var(--cde-s2); color: var(--cde-text); }
.zt-tree-chevron.open { transform: rotate(90deg); }
.zt-tree-children { padding-left: 18px; }
.zt-tree-icon {
  flex-shrink: 0;
  color: var(--cde-muted);
}
.zt-tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.zt-tree-check {
  flex-shrink: 0;
  color: var(--cde-shared);
  font-size: 12px;
  width: 16px;
  text-align: center;
}
.zt-new-folder-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}
.zt-new-folder-label {
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  font-weight: 600;
}
.zt-new-inp {
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: var(--font-size-sm);
  background: var(--cde-bg);
  color: var(--cde-text);
  width: 100%;
  box-sizing: border-box;
}
.zt-new-inp:focus { outline: none; border-color: var(--cde-shared); }
.zt-no-folders {
  font-size: var(--font-size-xs);
  color: var(--cde-muted);
  font-style: italic;
  padding: 4px 0 10px;
}
.zt-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.zt-error {
  color: #e53935;
  font-size: var(--font-size-xs);
  padding: 6px 0 4px;
  display: none;
}
.zt-error.zt-error-show { display: block; }
.zt-scope-notice {
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.zt-scope-notice::before { content: '⚠'; }
.zt-type-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--cde-text2);
  padding-bottom: 6px;
}
.zt-type-indicator svg { vertical-align: middle; }
/* ── Zone row wrapper (replaces inline style) ─────────────────────────────── */
.d-form-zone-wrap { display: flex; align-items: center; gap: 8px; }

/* ── Version history clickable dot ─────────────────────────────────────────── */
.ver-clickable { cursor: pointer; }
.ver-clickable:hover .ver-dot { background: var(--cde-shared); color: #fff; border-color: var(--cde-shared); }

/* ── Permissions panel ──────────────────────────────────────────────────────── */
.acc-empty-note { font-size: var(--font-size-sm); color: var(--cde-text2); margin-bottom: 8px; font-style: italic; }
.perm-manage-btn { margin-top: 8px; padding: 3px 10px; font-size: var(--font-size-sm); border: 1px solid var(--cde-border); border-radius: 4px; background: transparent; cursor: pointer; color: var(--cde-text2); transition: all .15s; }
.perm-manage-btn:hover { background: var(--cde-s3); color: var(--cde-text); }
.perm-entry-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--cde-border); }
.perm-entry-user { flex: 1; font-size: var(--font-size-sm); color: var(--cde-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.perm-role-badge { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 10px; background: var(--cde-s3, #f1f5f9); color: var(--cde-text2, #64748b); border: 1px solid var(--cde-border, #e2e8f0); white-space: nowrap; flex-shrink: 0; }
.perm-entry-sel { padding: 2px 4px; font-size: var(--font-size-xs); border: 1px solid var(--cde-border); border-radius: 3px; }
.perm-entry-remove { padding: 1px 6px; font-size: var(--font-size-sm); border: 1px solid var(--cde-border); border-radius: 3px; background: transparent; cursor: pointer; color: var(--cde-danger, #e53e3e); line-height: 1.4; }
.perm-entry-remove:hover { background: #fff0f0; }
.perm-add-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.perm-new-user { flex: 1; max-width: 100px;}
.perm-new-level { padding: 4px 6px; font-size: var(--font-size-xs); border: 1px solid var(--cde-border); border-radius: 3px; }
.perm-add-btn { white-space: nowrap; flex-shrink: 0; }

/* ──────────────────────────────────────────────────────────────────────────── */

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 0;
  color: var(--cde-muted2);
}

.empty-state p { font-size: var(--font-size-base); }

/* Selection Bar - inside project-main - Light Theme */
.sel-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cde-surface, #fff);
  color: var(--cde-text, #1c1f26);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15), 0 0 0 1px var(--cde-border, #e1e4e8);
  font-size: var(--cde-fs-md, 13px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.sel-bar.show { opacity: 1; pointer-events: all; transform: translateX(-50%) translateY(0); }

.sel-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid var(--cde-border, #e1e4e8);
  padding-left: 12px;
}

.sel-bar-btn {
  font-size: var(--cde-fs-sm, 12px);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--cde-border, #e1e4e8);
  background: var(--cde-surface, #fff);
  color: var(--cde-text, #1c1f26);
  cursor: pointer;
  transition: all .15s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.sel-bar-btn:hover {
  background: var(--cde-s2, #f7f8fa);
  border-color: var(--cde-blue, #1460b8);
}

.sel-bar-btn:active {
  transform: scale(0.97);
}

.sel-bar-btn.sel-danger {
  color: var(--cde-red, #c0392b);
}

.sel-bar-btn.sel-danger:hover {
  background: #fff0ee;
  border-color: var(--cde-red, #c0392b);
}

.sel-bar-btn.sel-clear {
  padding: 6px 8px;
  border: none;
  background: transparent;
}

.sel-bar-btn.sel-clear:hover {
  background: var(--cde-s3, #eef0f3);
  border-color: transparent;
}

/* ============================================
   CDE CONTEXT MENU
   ============================================ */

.cde-context-menu {
  background: var(--cde-surface, #fff);
  border: 1px solid var(--cde-border, #e0e0e0);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  min-width: 180px;
  padding: 4px 0;
  animation: ctxFadeIn 0.15s ease;
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: var(--font-size-base);
  color: #333;
  transition: background .1s;
}

.ctx-item:hover {
  background: var(--cde-row-hover, #f0f4ff);
}

.ctx-item svg {
  flex-shrink: 0;
  color: #666;
}

.ctx-item:hover svg {
  color: var(--primary-blue, #2563eb);
}

.ctx-divider {
  height: 1px;
  background: var(--cde-border, #e0e0e0);
  margin: 4px 8px;
}

.ctx-danger {
  color: #dc2626;
}

.ctx-danger svg {
  color: #dc2626;
}



/* ============================================
   PDF VIEWER - App Design Style
   ============================================ */

:root {
  --pdf-toolbar-bg: var(--bg-white);
  --pdf-sidebar-bg: var(--bg-lighter);
  --pdf-main-bg: var(--bg-secondary);
  --pdf-page-bg: #fff;
  --pdf-thumbnail-selected: var(--color-primary);
  --pdf-text-primary: var(--text-primary);
  --pdf-text-secondary: var(--text-secondary);
  --pdf-text-muted: var(--text-muted);
  --pdf-border: var(--cde-border);
  --pdf-btn-hover: var(--primary-blue-lightest);
  --pdf-btn-active: var(--color-primary-bg);
  --pdf-annotation-yellow: rgba(255, 235, 59, 0.4);
  --pdf-annotation-green: rgba(76, 175, 80, 0.3);
  --pdf-annotation-blue: rgba(33, 150, 243, 0.3);
  --pdf-annotation-pink: rgba(233, 30, 99, 0.3);
  --pdf-shadow: var(--shadow-md);
  --pdf-shadow-lg: var(--shadow-lg);
  --pdf-radius: var(--radius-md);
  --pdf-radius-sm: var(--radius-sm);
}

/* Main container */
.pdf-viewer-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  background: var(--pdf-main-bg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  overflow: hidden;
}

/* Toolbar */
.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--pdf-toolbar-bg);
  border-bottom: 1px solid var(--pdf-border);
  flex-wrap: wrap;
  min-height: 48px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.pdf-toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.pdf-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--pdf-border);
  margin: 0 var(--spacing-sm);
}

.pdf-title-group {
  flex: 1;
  min-width: 150px;
  justify-content: center;
}

.pdf-filename {
  color: var(--pdf-text-primary);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Buttons - App style */
.pdf-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--pdf-radius-sm);
  color: var(--pdf-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.pdf-btn:hover {
  background: var(--pdf-btn-hover);
  color: var(--color-primary);
}

.pdf-btn:active {
  background: var(--pdf-btn-active);
}

.pdf-btn.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.pdf-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.pdf-btn svg {
  width: 18px;
  height: 18px;
}

/* Page navigation */
.pdf-page-nav {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.pdf-page-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--pdf-text-primary);
  font-size: var(--font-size-base);
}

.page-input {
  width: 50px;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--bg-white);
  border: 1px solid var(--pdf-border);
  border-radius: var(--pdf-radius-sm);
  color: var(--pdf-text-primary);
  font-size: var(--font-size-base);
  text-align: center;
  transition: border-color var(--transition-fast);
}

.page-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

/* Zoom controls */
.pdf-zoom-group {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.zoom-select {
  padding: 6px 28px 6px 10px;
  background: var(--bg-white);
  border: 1px solid var(--pdf-border);
  border-radius: var(--pdf-radius-sm);
  color: var(--pdf-text-primary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--transition-fast);
}

.zoom-select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.zoom-level {
  font-size: var(--font-size-sm);
  color: var(--pdf-text-secondary);
  min-width: 45px;
  text-align: center;
}

/* Tool buttons */
.pdf-tools-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tool-btn.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.draw-color {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--pdf-border);
  border-radius: var(--pdf-radius-sm);
  cursor: pointer;
  background: var(--bg-white);
}

/* Main content area */
.pdf-main-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.pdf-sidebar {
  width: 250px;
  background: var(--pdf-sidebar-bg);
  border-right: 1px solid var(--pdf-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-sidebar.collapsed {
  width: 0;
  border-right: none;
}

.pdf-sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--pdf-border);
  background: var(--bg-white);
}

.pdf-sidebar-tab {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--pdf-text-muted);
  transition: all var(--transition-fast);
}

.pdf-sidebar-tab:hover {
  background: var(--pdf-btn-hover);
  color: var(--color-primary);
}

.pdf-sidebar-tab.active {
  background: var(--bg-white);
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
  border-bottom: 2px solid var(--color-primary);
}

.pdf-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
}

/* Thumbnails */
.pdf-thumbnails {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  align-items: center;
}

.pdf-thumbnail {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--pdf-radius-sm);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background: var(--bg-white);
  box-shadow: var(--shadow-sm);
}

.pdf-thumbnail:hover {
  border-color: var(--pdf-text-muted);
  box-shadow: var(--shadow-md);
}

.pdf-thumbnail.selected {
  border-color: var(--pdf-thumbnail-selected);
  box-shadow: 0 0 0 2px var(--color-primary-bg);
}

.pdf-thumbnail canvas {
  display: block;
}

.pdf-thumbnail-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: var(--font-size-xs);
  text-align: center;
  padding: 2px 4px;
}

/* Outline/Bookmarks */
.pdf-outline {
  font-size: var(--font-size-base);
}

.pdf-outline-item {
  padding: var(--spacing-sm);
  cursor: pointer;
  border-radius: var(--pdf-radius-sm);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--pdf-text-secondary);
  transition: background var(--transition-fast);
}

.pdf-outline-item:hover {
  background: var(--pdf-btn-hover);
  color: var(--color-primary);
}

.pdf-outline-item.selected {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.pdf-outline-children {
  margin-left: var(--spacing-lg);
}

.pdf-outline-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--pdf-text-muted);
}

/* Main content */
.pdf-main {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--pdf-main-bg);
  padding: var(--spacing-xl);
  position: relative;
}

.pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-xl);
}

.pdf-page-container {
  position: relative;
  box-shadow: var(--pdf-shadow-lg);
  background: var(--pdf-page-bg);
  border-radius: var(--pdf-radius-sm);
}

.pdf-page-container canvas {
  display: block;
}

/* Text layer for selection */
.textLayer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  opacity: 0.5;
  line-height: 1.0;
  z-index: 1;
}

.textLayer > span {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
  pointer-events: auto;
}

.textLayer ::selection {
  background: var(--color-primary);
}

/* Ensure page container properly stacks layers */
.pdf-page-container {
  position: relative;
}

.pdf-page-container canvas {
  position: relative;
  z-index: 0;
}

/* Annotation layer - below text layer */
.annotationLayer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
}

.annotationLayer > section {
  position: absolute;
  pointer-events: auto;
}

/* Highlight annotations */
.annotation-highlight {
  background: var(--pdf-annotation-yellow);
  cursor: pointer;
  border-radius: 2px;
}

.annotation-highlight.green {
  background: var(--pdf-annotation-green);
}

.annotation-highlight.blue {
  background: var(--pdf-annotation-blue);
}

.annotation-highlight.pink {
  background: var(--pdf-annotation-pink);
}

/* Search bar */
.pdf-search {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  background: var(--bg-white);
  border: 1px solid var(--pdf-border);
  border-radius: var(--pdf-radius-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
}

.pdf-search svg {
  color: var(--pdf-text-muted);
  flex-shrink: 0;
}

.pdf-search input {
  background: transparent;
  border: none;
  color: var(--pdf-text-primary);
  font-size: var(--font-size-sm);
  width: 120px;
  outline: none;
}

.pdf-search input::placeholder {
  color: var(--pdf-text-muted);
}

.pdf-search-count {
  color: var(--pdf-text-muted);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.search-btn {
  width: 24px;
  height: 24px;
  padding: 0;
}

/* Loading and error states */
.pdf-error, .pdf-viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--pdf-text-primary);
  font-size: var(--font-size-base);
  text-align: center;
  padding: var(--spacing-3xl);
}

.pdf-error {
  color: var(--color-danger);
}

.pdf-error .error-detail {
  color: var(--pdf-text-muted);
  margin: var(--spacing-md) 0;
  font-size: var(--font-size-sm);
}

.pdf-viewer-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--pdf-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--spacing-md);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Version Compare Modal */
.pdf-version-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.pdf-version-modal.show {
  display: flex;
}

.pdf-version-modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 1400px;
  height: 90%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.pdf-version-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-xl);
  background: var(--bg-lighter);
  border-bottom: 1px solid var(--pdf-border);
}

.pdf-version-header h3 {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--pdf-text-primary);
  font-weight: var(--font-weight-medium);
}

.pdf-version-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
}

.pdf-version-select {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.pdf-version-select label {
  font-size: var(--font-size-sm);
  color: var(--pdf-text-secondary);
  white-space: nowrap;
}

.pdf-version-select select {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--pdf-border);
  border-radius: var(--pdf-radius-sm);
  font-size: var(--font-size-sm);
  min-width: 150px;
  background: var(--bg-white);
  color: var(--pdf-text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.pdf-version-select select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.pdf-version-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.pdf-version-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--pdf-border);
}

.pdf-version-pane:last-child {
  border-right: none;
}

.pdf-version-pane-header {
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-lighter);
  border-bottom: 1px solid var(--pdf-border);
  font-size: var(--font-size-sm);
  color: var(--pdf-text-secondary);
  font-weight: var(--font-weight-medium);
}

.pdf-version-pane-content {
  flex: 1;
  overflow: auto;
  background: var(--pdf-main-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-xl);
}

.pdf-version-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--pdf-text-muted);
  padding: var(--spacing-xs);
  line-height: 1;
  transition: color var(--transition-fast);
}

.pdf-version-close:hover {
  color: var(--pdf-text-primary);
}

/* Diff highlighting in version compare */
.pdf-page-container.diff-old {
  border: 3px solid var(--color-danger);
}

.pdf-page-container.diff-new {
  border: 3px solid var(--color-success);
}

/* Scrollbar styling */
.pdf-sidebar-content::-webkit-scrollbar,
.pdf-main::-webkit-scrollbar,
.pdf-version-pane-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.pdf-sidebar-content::-webkit-scrollbar-track,
.pdf-main::-webkit-scrollbar-track,
.pdf-version-pane-content::-webkit-scrollbar-track {
  background: var(--bg-lighter);
}

.pdf-sidebar-content::-webkit-scrollbar-thumb,
.pdf-main::-webkit-scrollbar-thumb,
.pdf-version-pane-content::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-sm);
}

.pdf-sidebar-content::-webkit-scrollbar-thumb:hover,
.pdf-main::-webkit-scrollbar-thumb:hover,
.pdf-version-pane-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Pane placeholder */
.pane-placeholder {
  color: var(--pdf-text-muted);
  font-size: var(--font-size-base);
  text-align: center;
  padding: var(--spacing-xl);
}

/* Search highlight */
.search-highlight {
  background: var(--color-warning-bg);
  border-radius: 2px;
  padding: 0 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .pdf-sidebar {
    position: absolute;
    left: 0;
    top: 48px;
    bottom: 0;
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }

  .pdf-version-body {
    flex-direction: column;
  }

  .pdf-version-pane {
    border-right: none;
    border-bottom: 1px solid #ddd;
  }
}

/* Simplified PDF Toolbar for EmbedPDF */
.pdf-toolbar-simple {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--cde-border);
  min-height: 48px;
}

.pdf-toolbar-simple .pdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  min-width: 100px;
  min-height: 32px;
  background: transparent;
  border: 1px solid var(--cde-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--font-size-sm);
}

.pdf-toolbar-simple .pdf-btn:hover {
  background: var(--bg-hover);
  border-color: var(--cde-blue);
}

.pdf-toolbar-simple .pdf-filename {
  font-weight: 500;
  color: var(--text-primary);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-toolbar-spacer {
  flex: 1;
}

.version-compare-section {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.version-select {
  padding: 6px 12px;
  border: 1px solid var(--cde-border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 160px;
  max-width: 220px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-select:hover {
  border-color: var(--cde-blue);
}

.version-compare-section .pdf-btn,
#btn-compare,
#btn-exit-compare {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--cde-blue) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.version-compare-section .pdf-btn:hover,
#btn-compare:hover,
#btn-exit-compare:hover {
  background: #1565c0 !important;
}

.pdf-btn-save,
#btn-save-annotations {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  padding: 6px 14px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  white-space: nowrap;
  background: var(--color-primary, #2563eb);
  color: #fff !important;
  border: none !important;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.pdf-btn-save:hover,
#btn-save-annotations:hover {
  background: #1b5e20 !important;
}

/* PDF Main Area */
.pdf-main-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--pdf-main-bg, #525252);
}

.pdf-main-area .pdf-viewer {
  flex: 1;
  display: block;
  overflow: auto;
  background: var(--pdf-main-bg, #525252);
}

.pdf-main-area .pdf-viewer-compare {
  flex: 1;
  display: none;
  overflow: auto;
  border-left: 1px solid var(--cde-border);
  background: var(--pdf-main-bg, #525252);
}

.pdf-main-area.compare-mode .pdf-viewer {
  width: 50%;
}

.pdf-main-area.compare-mode .pdf-viewer-compare {
  display: block;
  width: 50%;
}

/* EmbedPDF container styling */
.pdf-viewer > div,
.pdf-viewer-compare > div {
  height: 100% !important;
}

/* Button states */
.btn-exit-compare {
  background: var(--bg-danger-light, #fee2e2);
  border-color: var(--bg-danger, #dc2626);
  color: var(--bg-danger, #dc2626);
}

.btn-exit-compare:hover {
  background: var(--bg-danger);
  color: #fff;
}

