/* PD RAG - Document Management Interface */
/* Styled with pibiCo Brand Guidelines */

/* Root Container */
.pd-drive-container {
  width: 100%;
  max-width: 100%;
  padding: 0;
  background: var(--bg-color);
  font-family: 'Figtree', Arial, sans-serif;
  color: #4682b4;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;

  /* Flexbox Layout for resizable sections */
  display: flex;
  height: calc(80vh - 30px);
}

/* Collapsed sidebar state */
.pd-drive-container.sidebar-collapsed .pd-sidebar {
  display: none;
}

.pd-drive-container.sidebar-collapsed .pd-resize-handle {
  display: none;
}

/* ===== LEFT SIDEBAR (320px) ===== */
.pd-sidebar {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius) 0 0 0;
  border-right: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  width: 320px;
  min-width: 200px;
  max-width: 600px;
  flex-shrink: 0;
}

/* Resize Handle - Seamless vertical divider */
.pd-resize-handle {
  width: 1px;
  background: var(--border-color);
  cursor: col-resize;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
  user-select: none;
  margin: 0;
  padding: 0;
}

.pd-resize-handle:hover,
.pd-resize-handle.resizing {
  background: #4682b4;
  width: 2px;
}

.pd-resize-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
  /* Expanded hit area for easier grabbing */
}

/* Sidebar Header */
.pd-sidebar-header {
  padding: 6px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Raleway', Arial, sans-serif;
  color: var(--text-color);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title .fa {
  color: #4682b4;
  font-size: 14px;
}

/* Sidebar Body */
.pd-sidebar-body {
  padding: 6px;
  padding-top: 21px;
  flex: 1;
  overflow-y: auto;
}

/* Workspace Selector - Top Section (like path bar) */
.pd-workspace-selector {
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.04) 0%, rgba(46, 77, 111, 0.02) 100%);
  border-bottom: 1px solid var(--border-color);
  min-height: 52px;
  display: flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

/* Path Bar in Documents Area - Top aligned */
.pd-path-bar {
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.04) 0%, rgba(46, 77, 111, 0.02) 100%);
  border-bottom: 1px solid var(--border-color);
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pd-path-bar .pd-sidebar-toggle {
  flex-shrink: 0;
}

.pd-path-input-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid rgba(70, 130, 180, 0.3);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: all 0.2s ease;
  height: 36px;
}

.pd-path-input-container:focus-within {
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

.pd-path-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #333;
  font-size: 13px;
  font-family: 'Figtree', Arial, sans-serif;
  padding: 0;
  min-width: 0;
  cursor: text;
}

.pd-path-input::placeholder {
  color: #999;
}

.pd-path-go-btn,
.pd-tree-view-main-btn {
  width: 28px !important;
  height: 28px !important;
  flex-shrink: 0;
}

.pd-path-go-btn .fa,
.pd-tree-view-main-btn .fa {
  font-size: 12px;
}

.pd-path-go-btn {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  border: 1px solid #4CAF50;
}

.pd-path-go-btn:hover {
  background: linear-gradient(135deg, #45a049 0%, #4CAF50 100%);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.pd-path-separator {
  color: #999;
  font-size: 12px;
  flex-shrink: 0;
  margin: 0 4px;
}

/* Folder List Header (like toolbar) */
.pd-folder-list-header {
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.06) 0%, rgba(46, 77, 111, 0.03) 100%);
  border-bottom: 1px solid rgba(70, 130, 180, 0.15);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
}

.pd-folder-list-header .pd-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #4682b4;
  margin: 0;
  padding: 0;
  border: none;
  flex: 1;
}

.pd-tree-view-btn {
  width: 36px !important;
  height: 36px !important;
  flex-shrink: 0;
}

/* Folder Content Area (like main content area) */
.pd-folder-content-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.pd-folder-items {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

/* Folder Item (flat list item) */
.pd-folder-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  margin-bottom: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  color: var(--text-color);
  border: 1px solid transparent;
}

.pd-folder-item:hover {
  background: rgba(70, 130, 180, 0.08);
  border-color: rgba(70, 130, 180, 0.2);
}

.pd-folder-item.active {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.12) 0%, rgba(46, 77, 111, 0.12) 100%);
  border-color: #4682b4;
  font-weight: 600;
}

.pd-folder-item.parent-folder {
  width: 36px;
  height: 36px;
  padding: 0;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.pd-folder-item .fa {
  font-size: 16px;
  color: #4682b4;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}


.pd-folder-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pd-folder-item-count {
  font-size: 11px;
  font-weight: 700;
  color: white;
  /* Background color set dynamically via JavaScript gradient */
  background: #4682b4; /* Fallback color */
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* New split count badges - normalized design */
.pd-folder-count-badge {
  font-size: 9px;
  font-weight: 700;
  color: white;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.pd-folder-count-badge i {
  font-size: 8px;
  color: white;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.3),
    1px -1px 0 rgba(255, 255, 255, 0.3),
    -1px 1px 0 rgba(255, 255, 255, 0.3),
    1px 1px 0 rgba(255, 255, 255, 0.3);
}

/* File badge (gray) */
.pd-file-badge {
  background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
  border: 1px solid rgba(108, 117, 125, 0.3);
}

.pd-file-badge:hover {
  background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Data badge (blue) */
.pd-data-badge {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.pd-data-badge:hover {
  background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

/* Sidebar Sections (Quick Access & Categories) */
.pd-sidebar-section {
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.pd-sidebar-section .pd-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

/* Collapsible Section Header */
.pd-collapsible-header {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  padding: 4px 0;
  border-radius: var(--radius-sm);
}

.pd-collapsible-header:hover {
  background: rgba(70, 130, 180, 0.05);
}

/* Chevron Toggle Icon */
.pd-section-toggle {
  font-size: 10px;
  color: #4682b4;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.pd-sidebar-section.collapsed .pd-section-toggle {
  transform: rotate(-90deg);
}

/* Collapsible Content */
.pd-collapsible-content {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
  opacity: 1;
  margin-top: 3px;
}

.pd-sidebar-section.collapsed .pd-collapsible-content {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.pd-sidebar-section .pd-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #4682b4;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: 'Raleway', Arial, sans-serif;
  border-bottom: none;
  margin: 0;
  padding-bottom: 0;
}

/* Quick Filters in Sidebar - Two Column Grid */
.pd-sidebar-section .pd-quick-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
  overflow: hidden;
}

.pd-sidebar-section .pd-quick-filters .pd-filter-badge {
  position: relative;
  width: 100%;
  justify-content: flex-start;
  padding: 3px 22px 3px 6px; /* Add right padding for badge counter */
  border-radius: var(--radius-sm);
  font-size: 9px;
  gap: 3px;
  overflow: hidden;
  min-width: 0;
  min-height: 24px; /* Ensure enough height for the badge */
}

.pd-sidebar-section .pd-quick-filters .pd-filter-badge span:not(.pd-badge-count) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
  font-size: 9px; /* Ensure consistent text size */
}

.pd-sidebar-section .pd-quick-filters .pd-filter-badge .fa {
  font-size: 10px; /* Consistent icon size */
}

/* Position badge counter in top-right corner for quick access filters */
.pd-sidebar-section .pd-quick-filters .pd-filter-badge .pd-badge-count {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 1px 3px;
  font-size: 8px;
  line-height: 14px;
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm);
  background: rgba(70, 130, 180, 0.85); /* Steel blue */
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.pd-sidebar-section .pd-quick-filters .pd-filter-badge.active .pd-badge-count {
  background: rgba(70, 130, 180, 1); /* Solid steel blue */
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Category Filters in Sidebar - Two Column Grid */
.pd-sidebar-section .pd-category-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
  overflow: hidden;
}

.pd-sidebar-section .pd-category-filters .pd-filter-badge {
  position: relative;
  width: 100%;
  justify-content: flex-start;
  padding: 3px 22px 3px 6px; /* Add right padding for badge counter */
  border-radius: var(--radius-sm);
  font-size: 9px;
  gap: 3px;
  overflow: hidden; /* Keep contained */
  min-width: 0;
  min-height: 24px; /* Ensure enough height for the badge */
}

.pd-sidebar-section .pd-category-filters .pd-filter-badge .category-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
  font-size: 9px; /* Ensure consistent text size */
}

.pd-sidebar-section .pd-category-filters .pd-filter-badge .fa {
  font-size: 10px; /* Consistent icon size */
}

/* Position badge counter in top-right corner for category filters - flush with corner */
.pd-sidebar-section .pd-category-filters .pd-filter-badge .pd-badge-count {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 1px 3px;
  font-size: 8px;
  line-height: 14px;
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm); /* Match parent top-right radius, rounded bottom-left */
  background: rgba(70, 130, 180, 0.85); /* Steel blue */
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Active state for category badge counter */
.pd-sidebar-section .pd-category-filters .pd-filter-badge.active .pd-badge-count {
  background: rgba(70, 130, 180, 1); /* Solid steel blue when active */
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ── File-type filter: collapsible groups → exact-type rows (multi-select) ── */
.pd-filetype-filters { padding: 2px; }
.pd-ft-group { border-radius: var(--radius-sm); }
.pd-ft-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  cursor: pointer;
  line-height: 1;
  font-size: 10px;
  font-weight: 600;
  color: #2c5171;
  border-radius: var(--radius-sm);
}
.pd-ft-group > summary::-webkit-details-marker { display: none; }
.pd-ft-group > summary:hover { background: rgba(70, 130, 180, 0.08); }
.pd-ft-caret { font-size: 11px; color: #94a3b8; transition: transform 0.15s; }
.pd-ft-group[open] > summary .pd-ft-caret { transform: rotate(90deg); }
.pd-ft-group-icon { font-size: 12px; color: #4682b4; }
.pd-ft-group-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-ft-group-count {
  min-width: 14px; height: 14px; padding: 0 3px; font-size: 8px; line-height: 14px;
  text-align: center; border-radius: var(--radius-sm); background: rgba(70, 130, 180, 0.15);
  color: #2c5171; font-weight: 700;
}
.pd-ft-active-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4682b4; flex-shrink: 0;
}
.pd-ft-types {
  padding-left: 16px;
  border-left: 1px solid rgba(70, 130, 180, 0.12);
  margin: 0 0 2px 8px;
}
.pd-ft-type {
  display: flex; align-items: center; gap: 5px; width: 100%;
  padding: 2px 6px; border: none; background: none; cursor: pointer;
  line-height: 1; font-size: 9px; color: #4a5568; border-radius: var(--radius-sm);
  font-family: inherit; text-align: left;
}
.pd-ft-type:hover { background: rgba(70, 130, 180, 0.06); }
.pd-ft-check {
  font-size: 9px;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(70, 130, 180, 0.55);
  border-radius: var(--radius-sm);
  background: #fff;
  color: transparent; /* check glyph hidden until active; the border stays visible */
}
.pd-ft-type:hover .pd-ft-check { border-color: rgba(70, 130, 180, 0.85); }
.pd-ft-type.active { color: #2c5171; font-weight: 600; }
.pd-ft-type.active .pd-ft-check {
  background: #4682b4;
  border-color: #4682b4;
  color: #fff;
}
.pd-ft-type-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-ft-type-count {
  min-width: 14px; height: 14px; padding: 0 3px; font-size: 8px; line-height: 14px;
  text-align: center; border-radius: var(--radius-sm); background: rgba(70, 130, 180, 0.12);
  color: #2c5171; font-weight: 700;
}
.pd-ft-type.active .pd-ft-type-count { background: rgba(70, 130, 180, 0.85); color: #fff; }

/* Tag Filters in Sidebar - Two Column Grid */
.pd-sidebar-section .pd-tag-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 100%;
  overflow: hidden;
}

.pd-sidebar-section .pd-tag-filters .pd-filter-badge {
  width: 100%;
  justify-content: flex-start;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  gap: 3px;
  overflow: hidden;
  min-width: 0;
}

.pd-sidebar-section .pd-tag-filters .pd-filter-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

/* Filters Section Styles */
.pd-filters-section .pd-filters-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pd-filter-search-group {
  position: relative;
  display: flex;
  align-items: center;
}

.pd-filter-search-group .ph-magnifying-glass {
  position: absolute;
  left: 10px;
  color: #999;
  font-size: 12px;
  pointer-events: none;
}

.pd-filter-search-input {
  width: 100%;
  padding: 8px 8px 8px 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: 'Figtree', Arial, sans-serif;
  color: var(--text-color);
  background: var(--bg-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pd-filter-search-input:focus {
  outline: none;
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

.pd-filter-search-input::placeholder {
  color: #999;
  font-size: 11px;
}

/* Sidebar Filter Search Options */
.pd-filter-search-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.pd-filter-search-content-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-color);
  margin: 0;
  user-select: none;
}

.pd-filter-search-content-checkbox {
  cursor: pointer;
  margin: 0;
}

.pd-filter-search-mode-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  color: var(--text-color);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.pd-filter-search-mode-select:focus {
  outline: none;
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

.pd-filter-search-help-btn {
  background: none;
  border: none;
  color: #4682b4;
  cursor: pointer;
  padding: 3px 6px;
  font-size: 12px;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pd-filter-search-help-btn:hover {
  color: #2e4d6f;
}

.pd-filter-extensions-group {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Two column grid like other filters */
  gap: 4px;
  width: 100%;
}

.pd-filter-extensions-group .pd-extensions-badge {
  position: relative;
  width: 100%;
  justify-content: flex-start;
  padding: 3px 22px 3px 6px; /* Add right padding for badge counter */
  border-radius: var(--radius-sm); /* Match other filter badges */
  font-size: 9px;
  gap: 3px;
  overflow: hidden;
  min-width: 0;
  min-height: 24px;
}

.pd-filter-extensions-group .pd-extensions-badge span:not(.pd-badge-count):not(.pd-extensions-count) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
  font-size: 9px; /* Ensure consistent text size */
}

.pd-filter-extensions-group .pd-extensions-badge .fa {
  font-size: 10px; /* Consistent icon size */
}

/* Position badge counter in top-right corner for file types badge */
.pd-filter-extensions-group .pd-extensions-badge .pd-badge-count,
.pd-filter-extensions-group .pd-extensions-badge .pd-extensions-count {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 1px 3px;
  font-size: 8px;
  line-height: 14px;
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm);
  background: rgba(70, 130, 180, 0.85); /* Steel blue */
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.pd-filter-extensions-group .pd-extensions-badge.active .pd-badge-count,
.pd-filter-extensions-group .pd-extensions-badge.active .pd-extensions-count {
  background: rgba(70, 130, 180, 1); /* Solid steel blue */
  color: white;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.pd-workspace-selector .floating-label {
  position: absolute;
  top: -16px;
  right: 8px;
  color: #4682b4;
  font-size: 12px;
  font-weight: 500;
  background: white;
  padding: 0 6px;
  z-index: 1;
  margin: 0;
  border-radius: var(--radius-sm);
}

.pd-workspace-selector .floating-label .fa {
  margin-right: 4px;
  color: #4682b4;
  font-size: 11px;
}

.pd-workspace-dropdown {
  width: 100%;
  padding: 6px 12px;
  border: 1px solid rgba(70, 130, 180, 0.3);
  border-radius: var(--radius-sm);
  background: white;
  color: #333;
  font-size: 13px;
  height: 36px;
  line-height: 1.2;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Figtree', Arial, sans-serif;
}

.pd-workspace-dropdown:focus {
  outline: none;
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

/* Workspace Menu Dropdown */
.pd-workspace-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  max-height: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Search Container */
.pd-workspace-search-container {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.04) 0%, rgba(46, 77, 111, 0.02) 100%);
  flex-shrink: 0;
}

.pd-workspace-search-box {
  position: relative;
  width: 100%;
}

.pd-workspace-search-box .fa {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #4682b4;
  font-size: 11px;
}

.pd-workspace-search-input {
  width: 100%;
  padding: 4px 8px 4px 28px;
  border: 1px solid rgba(70, 130, 180, 0.3);
  border-radius: var(--radius-sm);
  background: white;
  color: #333;
  font-size: 12px;
  height: 28px;
  line-height: 1.2;
  transition: all 0.2s ease;
  font-family: 'Figtree', Arial, sans-serif;
}

.pd-workspace-search-input:focus {
  outline: none;
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

.pd-workspace-search-input::placeholder {
  color: #999;
}

/* Scrollable Items Container */
.pd-workspace-items-container {
  overflow-y: auto;
  max-height: 280px;
  flex: 1;
}

.pd-workspace-item {
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  color: var(--text-color);
  font-family: 'Figtree', Arial, sans-serif;
}

.pd-workspace-item:hover {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
}

.pd-workspace-item .workspace-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.pd-workspace-item .workspace-icon .icon {
  width: 16px;
  height: 16px;
}

/* Create Library Item */
.pd-create-library-item {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.05) 0%, rgba(46, 77, 111, 0.02) 100%);
  border-top: 1px solid var(--border-color);
  font-weight: 600;
}

.pd-create-library-item:hover {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.12) 0%, rgba(46, 77, 111, 0.08) 100%);
}

.pd-create-library-item .workspace-icon {
  color: #4682b4;
}

.pd-create-library-item .ph-plus {
  font-size: 14px;
}

/* Divider */
.pd-workspace-menu-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--border-color) 50%, transparent 100%);
  margin: 0;
  flex-shrink: 0;
}

/* Section Titles */
.pd-section-title {
  font-size: 12px;
  font-weight: 600;
  font-family: 'Raleway', Arial, sans-serif;
  color: var(--text-color);
  margin: 16px 0 8px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pd-section-title .fa {
  color: #4682b4;
  font-size: 11px;
}

/* Quick Access Navigation */
.pd-nav-item {
  padding: 3px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin-bottom: 2px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--text-color);
}

.pd-nav-item:hover {
  background: rgba(70, 130, 180, 0.08);
}

.pd-nav-item.active {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.1) 0%, rgba(46, 77, 111, 0.1) 100%);
  color: #2e4d6f;
  font-weight: 600;
}

.pd-nav-item .fa {
  width: 16px;
  text-align: center;
  font-size: 11px;
  color: #4682b4;
}

.pd-nav-item span:first-of-type {
  flex: 1;
}

.pd-count {
  font-size: 10px;
  font-weight: 700;
  color: #4682b4;
  background: rgba(70, 130, 180, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

/* Folder Tree */
.pd-folder-tree {
  margin-top: 8px;
}

/* Tree Root (Home) Node */
.pd-tree-root {
  padding: 3px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin-bottom: 2px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--text-color);
  font-weight: 600;
  background: rgba(70, 130, 180, 0.05);
}

.pd-tree-root:hover {
  background: rgba(70, 130, 180, 0.1);
}

.pd-tree-root.active {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.15) 0%, rgba(46, 77, 111, 0.15) 100%);
  color: #2e4d6f;
}

.pd-tree-root .ph-house {
  color: #4682b4;
  font-size: 12px;
}

/* Tree Items (Folders) */
.pd-tree-item {
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  margin-bottom: 1px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-color);
  position: relative;
  user-select: none;
}

.pd-tree-item:hover {
  background: rgba(70, 130, 180, 0.08);
}

.pd-tree-item.active {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.12) 0%, rgba(46, 77, 111, 0.12) 100%);
  color: #2e4d6f;
  font-weight: 600;
  border-left: 3px solid #4682b4;
  padding-left: 5px;
}

.pd-tree-item .ph-caret-right,
.pd-tree-item .ph-caret-down {
  font-size: 9px;
  transition: transform 0.2s ease;
  color: #999;
  width: 12px;
  flex-shrink: 0;
}

.pd-tree-item.expanded .ph-caret-right {
  transform: rotate(90deg);
}

.pd-tree-item .ph-folder,
.pd-tree-item .ph-folder-open {
  font-size: 12px;
  color: #4682b4;
  flex-shrink: 0;
}

.pd-tree-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pd-tree-item-count {
  font-size: 10px;
  color: white;
  /* Background color set dynamically via JavaScript gradient */
  background: #4682b4; /* Fallback color */
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Nested folder children */
.pd-tree-children {
  margin-left: 0;
  padding-left: 16px;
  border-left: 1px solid rgba(70, 130, 180, 0.15);
  margin-top: 2px;
  margin-bottom: 2px;
}

/* Root level children (no border) */
.pd-tree-root-children {
  margin-left: 0;
  padding-left: 0;
  margin-top: 4px;
}

/* Category List - 2 Column Grid */
.pd-category-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 4px;
  padding: 0;
  margin: 0;
  width: 100%;
  overflow: hidden;
}

/* Category Filters - Badge Style */
.pd-category-item {
  padding: 0;
  margin-bottom: 0;
  cursor: pointer;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.pd-category-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid;
  transition: all 0.2s ease;
  font-size: 10px;
  font-weight: 600;
  color: white !important;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.pd-category-badge i {
  font-size: 10px;
  opacity: 1;
  color: white !important;
  flex-shrink: 0;
}

.pd-category-name {
  flex: 1;
  font-size: 9px;
  font-weight: 700;
  color: white !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Red notification badge for count */
.pd-category-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ff4757 0%, #dc3545 100%);
  color: white;
  font-size: 8px;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  min-width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(220, 53, 69, 0.3), 0 0 0 1.5px white;
  border: 1px solid white;
  line-height: 1;
}

.pd-category-item:hover .pd-category-badge {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.pd-category-item.active .pd-category-badge {
  box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.3), 0 4px 8px rgba(0, 0, 0, 0.15);
  transform: scale(1.02);
}

/* Old styles - keeping for compatibility */
.category-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category-label {
  flex: 1;
  font-size: 12px;
}

.category-count {
  font-size: 10px;
  color: #888;
}

/* Sidebar Footer */
.pd-sidebar-footer {
  padding: 6px;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.05) 0%, rgba(46, 77, 111, 0.02) 100%);
}

.pd-storage-status {
  font-size: 11px;
  color: var(--text-muted);
}

.storage-bar {
  height: 6px;
  background: var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 6px 0;
}

.storage-used {
  height: 100%;
  background: linear-gradient(90deg, #4682b4, #2e4d6f);
  transition: width 0.3s ease;
}

.storage-text {
  font-size: 10px;
  color: #888;
  line-height: 1.2;
}

/* ===== MAIN PANEL (flex-grow) ===== */
.pd-main-panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  min-width: 400px;
  margin-left: -1px; /* Overlap the resize handle slightly */
}

/* When sidebar is collapsed, restore left border */
.pd-drive-container.sidebar-collapsed .pd-main-panel {
  border-left: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-left: 0;
}

/* Main Panel Header */
.pd-main-header {
  padding: 6px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.main-title {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Raleway', Arial, sans-serif;
  color: var(--text-color);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.main-title .fa {
  color: #4682b4;
  font-size: 14px;
}

/* Toolbar */
.pd-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.02) 0%, rgba(46, 77, 111, 0.01) 100%);
}

.pd-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pd-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  max-width: 400px;
}

.pd-btn {
  padding: 3px 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-color);
  line-height: 1.2;
  min-height: 32px;
  height: 32px;
}

.pd-btn:hover:not(:disabled) {
  background: #2e4d6f;
  color: white;
  border-color: #2e4d6f;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(46, 77, 111, 0.3);
}

.pd-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pd-btn .fa {
  font-size: 11px;
}

.pd-btn-primary {
  background: linear-gradient(135deg, #4682b4 0%, #2e4d6f 100%);
  color: white;
  border: none;
}

.pd-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2e4d6f 0%, rgb(0, 130, 120) 100%);
  box-shadow: 0 4px 12px rgba(70, 130, 180, 0.3);
}

.pd-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: white;
  color: #4682b4;
  border: 1px solid rgba(70, 130, 180, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pd-btn-icon:hover {
  background: #4682b4;
  color: white;
  border-color: #4682b4;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(70, 130, 180, 0.25);
}

.pd-btn-icon.active {
  background: #4682b4;
  color: white;
  border-color: #4682b4;
}

.pd-btn-icon .fa {
  font-size: 14px;
}

/* Primary icon button variant */
.pd-btn-icon.pd-btn-primary {
  background: linear-gradient(135deg, #4682b4 0%, #2e4d6f 100%);
  color: white;
  border: 1px solid #4682b4;
}

.pd-btn-icon.pd-btn-primary:hover {
  background: linear-gradient(135deg, #2e4d6f 0%, #4682b4 100%);
  box-shadow: 0 2px 12px rgba(70, 130, 180, 0.4);
}

/* Sidebar toggle button - special styling */
.pd-sidebar-toggle {
  margin-right: 4px;
}

.pd-sidebar-toggle .fa {
  transition: transform 0.3s ease;
}

.sidebar-collapsed .pd-sidebar-toggle .fa {
  transform: rotate(180deg);
}

/* Smaller add folder button in sidebar */
.pd-add-folder-btn {
  width: auto;
  height: auto;
  min-width: 18px;
  min-height: 18px;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid #4682b4;
}

.pd-add-folder-btn .fa {
  font-size: 11px;
}

.pd-add-folder-btn:hover {
  transform: none;
  box-shadow: 0 1px 3px rgba(70, 130, 180, 0.2);
}

/* Search Container - Two Row Layout */
.pd-search-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 350px;
}

/* Search Box - First Row */
.pd-search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.pd-search-box .fa {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #4682b4;
  font-size: 11px;
  z-index: 1;
  pointer-events: none;
}

.pd-search-input {
  flex: 1;
  width: 100%;
  padding: 6px 12px 6px 32px;
  border: 1px solid rgba(70, 130, 180, 0.3);
  border-radius: var(--radius-sm);
  background: white;
  color: #333;
  font-size: 13px;
  height: 36px;
  line-height: 1.2;
  transition: all 0.2s ease;
  font-family: 'Figtree', Arial, sans-serif;
}

.pd-search-input:focus {
  outline: none;
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

/* Search Options - Second Row */
.pd-search-options {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 2px;
  height: 28px; /* Fixed height for alignment */
}

/* Extended Search Checkbox Toggle */
.pd-search-content-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
  height: 28px; /* Match parent height */
  line-height: 1;
}

.pd-search-content-toggle:hover {
  background-color: rgba(70, 130, 180, 0.05);
}

/* Toolbar scope/mode controls (.pd-search-content-checkbox, .pd-checkbox-label,
   .pd-search-mode-select) were removed in 2026-05 — toolbar search is now
   hard-wired to name+library+folder. Their CSS lived here; deleted. The
   .pd-filter-search-* family used by the legacy advanced search panel is
   unrelated and stays untouched. */

/* Búsqueda finger tab — chips + counts narrowed to folder subtree.
   Inlined in the left card (#t2d-tab-cats); driven by search_facets.js. */
.t2d-srch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px 4px;
  font-family: var(--font-body, Inter, sans-serif);
}
.t2d-srch-scope {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-light, #666);
  line-height: 1.2;
  flex: 1;
  min-width: 0;
}
.t2d-srch-scope-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Match the expand/collapse button in the files-card header (`.t2d-cf-hdr-btn`)
 * — both inherit `.pd-btn-icon`'s 36×36 default. Previously the search reset
 * was a shrunk 22×22 chip, which read as a less-important affordance even
 * though it's a primary "clear all" action. */
.t2d-srch-reset i,
.t2d-srch-apply i { font-size: 14px; }

/* El tinte verde de «Aplicar» se retira: era el que distinguía un icono de
 * confirmación de otro icono neutro cuando los dos vivían en la cabecera.
 * Ahora es el botón primario del pie de la tarjeta, con nombre y con el azul
 * de la casa; el verde sobre ese fondo dejaba el rótulo casi ilegible. */

.t2d-srch-facets-section .t2d-srch-group,
.t2d-srch-tags-section { padding: 2px 10px 6px; }
.t2d-srch-group { margin-bottom: 6px; }
.t2d-srch-key {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-light, #666);
  margin: 4px 0 3px;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
/* AND/OR switch for a facet group — only rendered once two values of the key
   are selected (multi-value facets: "todos" = EN-1090 AND PED). */
.t2d-srch-mode {
  border: 1px solid rgba(70, 130, 180, 0.28);
  background: rgba(70, 130, 180, 0.08);
  color: var(--accent-color, #2c5171);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  line-height: 1.3;
  cursor: pointer;
}
.t2d-srch-mode:hover { background: rgba(70, 130, 180, 0.18); }
.t2d-srch-chips,
.t2d-srch-tags {
  display: flex;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 4px;
  align-items: center;
}
.t2d-srch-chip.t2d-srch-more {
  background: rgba(70, 130, 180, 0.18);
  border-color: rgba(70, 130, 180, 0.30);
  font-weight: 600;
  flex-shrink: 0;
  margin-left: auto;
}
.t2d-srch-chip.t2d-srch-more:hover {
  background: rgba(70, 130, 180, 0.30);
}
.t2d-srch-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(70, 130, 180, 0.08);
  border: 1px solid rgba(70, 130, 180, 0.18);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-color, #333);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
/* Dead-end values under the current cascade (count 0): the group stays
   visible (vocabulary never vanishes) but the chip is muted + inert. */
.t2d-srch-chip-zero,
.t2d-srch-ftext.t2d-srch-chip-zero {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}
/* Task #13: quick date-range chips above the from/to inputs. */
.t2d-srch-date-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 2px 10px 4px;
}
.t2d-srch-date-chip {
  display: inline-flex;
  align-items: center;
  background: rgba(70, 130, 180, 0.08);
  border: 1px solid rgba(70, 130, 180, 0.18);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--text-color, #333);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.t2d-srch-date-chip:hover {
  background: rgba(70, 130, 180, 0.18);
  border-color: rgba(70, 130, 180, 0.35);
}
.t2d-srch-date-chip.active {
  background: var(--primary-color, #4682b4);
  color: #fff;
  border-color: var(--primary-color, #4682b4);
  font-weight: 600;
}
.t2d-srch-chip:hover {
  background: rgba(70, 130, 180, 0.18);
  border-color: rgba(70, 130, 180, 0.35);
}
.t2d-srch-chip.active {
  background: var(--primary-color, #4682b4);
  color: #fff;
  border-color: var(--primary-color, #4682b4);
  font-weight: 600;
}
.t2d-srch-chip-val {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t2d-srch-chip-n {
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  border-radius: var(--radius-sm);
  padding: 0 5px;
  font-size: 9px;
  font-weight: 600;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  line-height: 1.4;
}
.t2d-srch-chip.active .t2d-srch-chip-n {
  background: rgba(255, 255, 255, 0.22);
}
.t2d-srch-empty {
  font-size: 10px;
  color: var(--text-light, #666);
  font-style: italic;
  padding: 4px 0;
}

/* Búsqueda finger tab — tighten vertical rhythm. The default
   .pd-sidebar-section padding (8px 12px) was designed for the Quick
   Access blocks; the search panel stacks 3 short sections (Tipo /
   Filtros / Etiquetas) plus a scope+reset header, so the spacing
   between them was eating ~50px of vertical room. */
#t2d-tab-cats .pd-sidebar-section { padding: 3px 10px; }
#t2d-tab-cats .pd-sidebar-section .pd-section-header { margin-bottom: 1px; }
#t2d-tab-cats .pd-sidebar-section .pd-section-title { font-size: 10px; }
#t2d-tab-cats .t2d-srch-head { padding: 4px 10px 2px; }
#t2d-tab-cats .t2d-srch-group { margin-bottom: 3px; }

/* Slide panel — render each clave:valor facet group as a SINGLE row:
 * `[KEY-LABEL]  [chip] [chip] [chip] … [+N]`
 * In the narrow panel a two-line layout (label above, chips below) wasted
 * vertical space and the +N marker could end up looking like a second row.
 * The flex layout keeps everything on one line and the chips area becomes
 * the only thing that can shrink (`min-width:0`), so `overflow:hidden` +
 * `flex-wrap:nowrap` consistently kicks in and the JS overflow detector
 * places +N at the right edge. */
#t2dSearchPanel .t2d-srch-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  min-width: 0;
}
#t2dSearchPanel .t2d-srch-group > .t2d-srch-key {
  margin: 0;
  flex-shrink: 0;
  width: 64px;
  text-align: right;
  font-size: 9px;
}
#t2dSearchPanel .t2d-srch-group > .t2d-srch-chips {
  flex: 1 1 0;
  min-width: 0;
}
/* Free-tag bucket inside the panel is rendered directly into #t2dSearchTags
 * (no per-key wrapper). Same single-row treatment. */
#t2dSearchPanel #t2dSearchTags { display: flex; align-items: center; gap: 8px; min-width: 0; }
#t2dSearchPanel #t2dSearchTags > .t2d-srch-key { margin: 0; flex-shrink: 0; width: 64px; text-align: right; font-size: 9px; }
#t2dSearchPanel #t2dSearchTags > .t2d-srch-chips { flex: 1 1 0; min-width: 0; }

/* Filetype tree — bucket groups (Imágenes / PDF / Documentos / …) with
   concrete extensions nested below. <details>/<summary> natively handles
   the open/close; we override the caret + suppress the default marker. */
.t2d-srch-fttree { display: flex; flex-direction: column; gap: 1px; }
.t2d-srch-ftgroup { line-height: 1.2; }
.t2d-srch-ftgroup > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-color, #333);
  transition: background 0.15s;
}
.t2d-srch-ftgroup > summary::-webkit-details-marker { display: none; }
.t2d-srch-ftgroup > summary:hover { background: rgba(70, 130, 180, 0.07); }
.t2d-srch-ftgroup > summary.active {
  background: rgba(70, 130, 180, 0.18);
  color: var(--accent-color, #2c5171);
  font-weight: 600;
}
.t2d-srch-ftcaret {
  width: 14px; flex-shrink: 0; color: var(--text-light, #888);
  transition: transform 0.15s;
  padding: 1px;
  border-radius: var(--radius-sm);
}
.t2d-srch-ftcaret:hover { background: rgba(70, 130, 180, 0.15); }
.t2d-srch-ftgroup[open] > summary > .t2d-srch-ftcaret {
  transform: rotate(90deg);
}
.t2d-srch-fticon { color: var(--primary-color, #4682b4); font-size: 13px; flex-shrink: 0; }
.t2d-srch-ftname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2d-srch-ftcnt {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  color: var(--text-light, #666);
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  padding: 0 6px;
  flex-shrink: 0;
}
.t2d-srch-ftgroup > summary.active .t2d-srch-ftcnt {
  background: rgba(255, 255, 255, 0.5);
  color: var(--accent-color, #2c5171);
}
.t2d-srch-ftexts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 1px 6px 3px 26px;
}
.t2d-srch-ftext {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 10px;
  color: var(--text-color, #333);
}
.t2d-srch-ftext:hover { background: rgba(70, 130, 180, 0.07); }
.t2d-srch-ftext.active {
  background: rgba(70, 130, 180, 0.18);
  color: var(--accent-color, #2c5171);
  font-weight: 600;
}
.t2d-srch-ftext input[type="checkbox"] {
  width: 12px; height: 12px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary-color, #4682b4);
  flex-shrink: 0;
}
.t2d-srch-ftextname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.12em; }
.t2d-srch-ftextcnt {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  color: var(--text-light, #666);
  flex-shrink: 0;
}

/* Search Help Button */
.pd-search-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(70, 130, 180, 0.3);
  border-radius: 50%;
  background: white;
  color: #4682b4;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.pd-search-help-btn:hover {
  background: rgba(70, 130, 180, 0.1);
  border-color: #4682b4;
  color: #2c5282;
}

.pd-search-help-btn:active {
  transform: scale(0.95);
}

.pd-search-help-btn i {
  margin: 0;
  line-height: 1;
}

/* Filter Bar - New row for filters and categories */
/* Filter bar removed - filters now in sidebar */

.pd-quick-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pd-category-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.pd-filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: white;
  border: 1.5px solid rgba(70, 130, 180, 0.25);
  border-radius: var(--radius);
  font-size: 10px;
  font-weight: 600;
  color: #4682b4;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: 'Figtree', Arial, sans-serif;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pd-filter-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.pd-filter-badge:hover {
  background: rgba(70, 130, 180, 0.08);
  border-color: #4682b4;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(70, 130, 180, 0.15);
}

.pd-filter-badge.active {
  background: linear-gradient(135deg, #4682b4 0%, #2e4d6f 100%);
  color: white;
  border-color: #4682b4;
  box-shadow: 0 2px 8px rgba(70, 130, 180, 0.3);
}

.pd-filter-badge .fa {
  font-size: 11px;
}

.pd-badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: rgba(70, 130, 180, 0.15);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.pd-filter-badge.active .pd-badge-count {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* Category filter badge color variants */
.pd-filter-badge.category-waste {
  border-color: #FF9800;
  color: #E65100;
}

.pd-filter-badge.category-waste.active {
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
  border-color: #FF9800;
  color: white;
}

.pd-filter-badge.category-safety {
  border-color: #4CAF50;
  color: #2E7D32;
}

.pd-filter-badge.category-safety.active {
  background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
  border-color: #4CAF50;
  color: white;
}

.pd-filter-badge.category-engineering {
  border-color: #2196F3;
  color: #1565C0;
}

.pd-filter-badge.category-engineering.active {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  border-color: #2196F3;
  color: white;
}

.pd-filter-badge.category-quality {
  border-color: #9C27B0;
  color: #6A1B9A;
}

.pd-filter-badge.category-quality.active {
  background: linear-gradient(135deg, #9C27B0 0%, #7B1FA2 100%);
  border-color: #9C27B0;
  color: white;
}

/* View Controls Bar - Replaces breadcrumb bar */
.pd-view-controls-bar {
  padding: 8px 12px;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 52px;
}

.pd-view-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pd-view-controls .pd-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
  margin: 0 3px;
}

/* Breadcrumb in Sidebar */
.pd-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-color);
  flex-wrap: wrap;
}

.pd-breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  line-height: 1.4;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

/* Only apply hover to clickable items (not active) */
.pd-breadcrumb-item:not(.active) {
  cursor: pointer;
}

.pd-breadcrumb-item:not(.active):hover {
  background: rgba(70, 130, 180, 0.08);
  color: #4682b4;
}

.pd-breadcrumb-item.active {
  color: #2e4d6f;
  font-weight: 600;
  cursor: default;
  background: rgba(70, 130, 180, 0.1);
}

.pd-breadcrumb-item .fa {
  font-size: 11px;
}

.pd-breadcrumb-item:not(:last-child)::after {
  content: '/';
  margin: 0 4px;
  color: #4682b4;
  font-weight: 400;
}

/* View Toggle */
.pd-view-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Main Content Area */
.pd-main-body {
  padding: 6px;
  padding-top: 21px;
  flex: 1;
  overflow-y: auto;
}

/* Content Area - Direct child of main panel */
.pd-content-area {
  flex: 1;
  overflow-y: auto;
  padding: 9px;
}

/* Loading State */
.pd-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.pd-loading .fa {
  font-size: 2em;
  margin-bottom: 12px;
  color: #4682b4;
}

.pd-loading p {
  font-size: 13px;
  margin: 0;
}

/* Empty State */
/* Folder empty-state — a clear-blue banner card on top of the content area,
   matching the search-status bar (.t2d-search-status) look. */
.pd-empty-state {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 0 8px;
  border-radius: var(--radius-sm);
  background: rgba(70, 130, 180, 0.10);
  color: #2c5171;
  text-align: left;
}

.pd-empty-state .fa,
.pd-empty-state i,
.pd-empty-state .ph {
  font-size: 16px;
  line-height: 1;
  color: #2c5171;
  margin: 0;
  flex-shrink: 0;
}

.pd-empty-state h3 {
  font-size: 13px;
  font-weight: 600;
  color: #2c5171;
  margin: 0;
  line-height: 1.2;
}

.pd-empty-state p {
  font-size: 12px;
  color: #2c5171;
  opacity: 0.85;
  margin: 0;
  line-height: 1.2;
}

/* Document Grid - Enhanced Appealing Distribution */
.pd-document-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  padding: 2px; /* Prevent cut-off shadows */
}

/* Optional: Featured/First item larger */
.pd-doc-card:first-child {
  grid-column: span 1;
  grid-row: span 1;
}

.pd-doc-card {
  background: white;
  border: 1px solid rgba(70, 130, 180, 0.12);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding: 6px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.03);
}

.pd-doc-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow:
    0 12px 24px rgba(70, 130, 180, 0.12),
    0 8px 16px rgba(46, 77, 111, 0.08),
    0 4px 8px rgba(0, 0, 0, 0.06);
  border-color: rgba(70, 130, 180, 0.4);
  z-index: 10;
}

.pd-doc-card:active {
  transform: translateY(-6px) scale(1.01);
  transition: all 0.15s ease;
}

.pd-doc-card.selected {
  border-color: #4682b4;
  box-shadow:
    0 0 0 3px rgba(70, 130, 180, 0.15),
    0 8px 16px rgba(70, 130, 180, 0.2);
  transform: translateY(-2px);
}

/* ===== PD DATA CARDS (Blue Theme for Structured Content) ===== */
.pd-data-card {
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.03) 0%, rgba(70, 130, 180, 0.05) 100%);
  border: 2px solid rgba(33, 150, 243, 0.2);
  border-radius: var(--radius);
  overflow: visible; /* Changed from hidden to show ellipsis button */
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  padding: 6px;
  box-shadow:
    0 1px 3px rgba(33, 150, 243, 0.08),
    0 1px 2px rgba(33, 150, 243, 0.06);
}

/* Ellipsis button for PD Data cards - match PD Document styling */
.pd-data-card .pd-doc-more-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.95);
  color: #4682b4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

.pd-data-card:hover .pd-doc-more-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.pd-data-card .pd-doc-more-btn:hover {
  background: rgba(70, 130, 180, 0.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pd-data-card .pd-doc-more-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pd-data-card .pd-doc-more-btn .fa {
  font-size: 14px;
  color: #4682b4;
}

/* Always visible on mobile */
@media (max-width: 768px) {
  .pd-data-card .pd-doc-more-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    width: 36px;
    height: 36px;
  }
}

.pd-data-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow:
    0 12px 24px rgba(33, 150, 243, 0.18),
    0 8px 16px rgba(33, 150, 243, 0.12),
    0 4px 8px rgba(33, 150, 243, 0.08);
  border-color: rgba(33, 150, 243, 0.5);
  z-index: 10;
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.06) 0%, rgba(70, 130, 180, 0.08) 100%);
}

.pd-data-card:active {
  transform: translateY(-6px) scale(1.01);
  transition: all 0.15s ease;
}

.pd-data-card.selected {
  border-color: #2196F3;
  box-shadow:
    0 0 0 3px rgba(33, 150, 243, 0.2),
    0 8px 16px rgba(33, 150, 243, 0.25);
  transform: translateY(-2px);
}

/* Data card preview area - blue theme with database icon */
.pd-data-preview {
  height: 140px;
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.12) 0%, rgba(70, 130, 180, 0.08) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #2196F3;
  font-size: 3em;
  position: relative;
  border-bottom: 2px solid rgba(33, 150, 243, 0.15);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all 0.3s ease;
}

.pd-data-card:hover .pd-data-preview {
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.18) 0%, rgba(70, 130, 180, 0.12) 100%);
  color: #1976D2;
}

/* DocType badge on data preview */
.pd-data-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(33, 150, 243, 0.9);
  color: white;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  font-family: 'Raleway', Arial, sans-serif;
}

/* DATA badge in card footer */
.pd-data-badge {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  color: white;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
  font-family: 'Raleway', Arial, sans-serif;
}

/* Source DocType label in metadata */
.pd-doc-source {
  color: #2196F3;
  font-weight: 600;
  font-size: 12px;
}

.pd-doc-preview {
  height: 140px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4682b4;
  font-size: 3em;
  position: relative;
  border-bottom: 1px solid rgba(70, 130, 180, 0.08);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: all 0.3s ease;
}

/* Lazy image thumbnail — covers the preview box, over the fallback icon.
   On load error the <img> removes itself (onerror) and the icon shows. */
.pd-doc-preview .pd-doc-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: #fff;
}
/* Vector art (SVG): contain so logos/diagrams aren't cropped. */
.pd-doc-preview .pd-doc-thumb--contain { object-fit: contain; padding: 8px; }

/* Markdown snippet thumbnail — first lines of the .md as plain text. */
.pd-doc-preview .pd-doc-thumb--md {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 8px 9px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  line-height: 1.35;
  color: #4a5568;
  background: #fff;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  text-align: left;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}

/* Tweet-length gist popover (#133): a single body-level floating tooltip (never
   clipped by card/grid overflow), shown on card hover and flipped left/right to
   stay on screen. Rounded, black bg / white text. Positioned in drive_init.js. */
#pd-tweet-pop {
  position: fixed;
  z-index: 11000;
  max-height: 60vh;
  overflow: hidden;
  box-sizing: border-box;
  padding: 9px 12px;
  background: rgba(17, 17, 17, 0.94);
  color: #fff;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
#pd-tweet-pop.show { opacity: 1; transform: scale(1); }

/* Favorite indicator - small star in top right corner */
.pd-favorite-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(255, 193, 7, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.pd-favorite-indicator i {
  font-size: 12px;
  color: white;
}

/* Favorite star in list view */
.pd-favorite-star {
  margin-left: 8px;
  color: #FFC107;
  font-size: 14px;
}

/* Reference indicator - small link icon in top left corner */
.pd-reference-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(33, 150, 243, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.pd-reference-indicator i {
  font-size: 11px;
  color: white;
}

/* Reference icon in list view */
.pd-reference-icon {
  margin-left: 8px;
  color: #2196F3;
  font-size: 13px;
}

/* Cloud indicator - small cloud icon in bottom left corner (for raw cloud files) */
.pd-cloud-indicator {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(33, 150, 243, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.pd-cloud-indicator i {
  font-size: 11px;
  color: white;
}

/* Document indicator - small document icon in bottom left corner (for PD Cloud Documents) */
.pd-document-indicator {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(76, 175, 80, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.pd-document-indicator i {
  font-size: 11px;
  color: white;
}

/* Indexing indicator — file has a row but pgvector tier not reached yet
   (pending/converting/queued). Orange to read as "in flight, not done". */
.pd-indexing-indicator {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  background: rgba(251, 191, 36, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.pd-indexing-indicator i {
  font-size: 11px;
  color: white;
}

/* Attachments indicator — small paperclip + count pill in the bottom-right
   of an .eml card. Stamped from documents.extra_metadata.attachments.count
   (set by app/services/eml_ingest.py during compound-eml ingest). The
   bottom-left corner is reserved for index-state (cloud / document /
   indexing), so the paperclip lives bottom-right to avoid collision. */
.pd-attachments-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  height: 22px;
  min-width: 22px;
  padding: 0 8px 0 6px;
  background: rgba(70, 130, 180, 0.92);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.pd-attachments-indicator i.ph {
  font-size: 12px;
  color: #fff;
}

.pd-attachments-indicator .pd-att-count {
  color: #fff;
}

/* Duplicate-group "+N" pill (Task #5) — surfaces on the survivor card
   when the search response folded N sibling copies into this hit. Sits in
   the bottom-right corner; if the same card already shows the .eml
   paperclip pill, this one slides further left so they don't overlap. */
.pd-dup-indicator {
  position: absolute;
  bottom: 8px;
  right: 8px;
  height: 22px;
  min-width: 22px;
  padding: 0 8px 0 6px;
  background: rgba(230, 126, 34, 0.92);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 2;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
}
.pd-dup-indicator i.ph { font-size: 12px; color: #fff; }
.pd-dup-indicator .pd-dup-count { color: #fff; }
/* If both pills land on the same card, push the dup pill left of the paperclip. */
.pd-attachments-indicator + .pd-dup-indicator { right: 56px; }

/* Cloud icon in list view */
.pd-cloud-icon {
  margin-left: 8px;
  color: #2196F3;
  font-size: 13px;
}

/* Cloud badge (for raw cloud files) */
.pd-cloud-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  background: rgba(33, 150, 243, 0.1);
  color: #2196F3;
  border-radius: var(--radius-sm);
  font-weight: 500;
  margin-left: 4px;
}

.pd-cloud-badge i {
  font-size: 10px;
  margin-right: 3px;
}

/* Document badge (for PD Cloud Documents) */
.pd-document-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  background: rgba(76, 175, 80, 0.1);
  color: #4CAF50;
  border-radius: var(--radius-sm);
  font-weight: 500;
  margin-left: 4px;
}

.pd-document-badge i {
  font-size: 10px;
  margin-right: 3px;
}

/* Reference badge */
.pd-reference-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(33, 150, 243, 0.15);
  color: #2196F3;
  border-radius: var(--radius-sm);
  margin-left: 4px;
}

.pd-doc-card:hover .pd-doc-preview {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.12) 0%, rgba(46, 77, 111, 0.08) 100%);
}

.pd-doc-preview.folder {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.1) 0%, rgba(220, 50, 40, 0.1) 100%);
  color: rgb(244, 67, 54);
}

/* Category Border Colors - Enhanced */
.pd-doc-preview[data-category="waste"] {
  border-top: 4px solid #FF9800;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.08) 0%, rgba(255, 152, 0, 0.04) 100%);
}

.pd-doc-preview[data-category="safety"] {
  border-top: 4px solid #4CAF50;
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.08) 0%, rgba(76, 175, 80, 0.04) 100%);
}

.pd-doc-preview[data-category="engineering"] {
  border-top: 4px solid #2196F3;
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.08) 0%, rgba(33, 150, 243, 0.04) 100%);
}

.pd-doc-preview[data-category="quality"] {
  border-top: 4px solid #9C27B0;
  background: linear-gradient(135deg, rgba(156, 39, 176, 0.08) 0%, rgba(156, 39, 176, 0.04) 100%);
}

/* Category glow effect on hover */
.pd-doc-card:hover .pd-doc-preview[data-category="waste"] {
  box-shadow: inset 0 0 20px rgba(255, 152, 0, 0.1);
}

.pd-doc-card:hover .pd-doc-preview[data-category="safety"] {
  box-shadow: inset 0 0 20px rgba(76, 175, 80, 0.1);
}

.pd-doc-card:hover .pd-doc-preview[data-category="engineering"] {
  box-shadow: inset 0 0 20px rgba(33, 150, 243, 0.1);
}

.pd-doc-card:hover .pd-doc-preview[data-category="quality"] {
  box-shadow: inset 0 0 20px rgba(156, 39, 176, 0.1);
}

.pd-doc-info {
  padding: 0;
  padding-top: 6px;
  background: var(--bg-primary);
}

.pd-doc-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.pd-doc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1;
}

.pd-doc-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Facet/tag chips on the grid card (#facets-on-cards). The chip class
   `.t2d-cf-chip` is the same one used in the slide-panel detail strip
   (drive.html ~L995); we keep the visual identity but bump density and stack
   ONE chip per line so values aren't ellipsis-clipped on a narrow card. The
   "+N" overflow chip is rendered INSIDE the last row, pushed right with
   `margin-left:auto` so the surplus is visible without taking a 4th row. */
.pd-doc-facets {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 3px;
  max-width: 100%;
}
.pd-doc-facet-row {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  line-height: 1;
}
/* Chip itself — denser than the slide-panel default so the row fits inside
   the card's ~140px width while still showing the full value (no ellipsis
   for typical short facet/tag values). */
.pd-doc-facets .pd-doc-facet-chip {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  cursor: pointer;
  border: none;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
}
.pd-doc-facets .pd-doc-facet-chip b {
  font-weight: 600;
  color: #1a3a54;
  text-transform: lowercase;
  margin-right: 2px;
}
.pd-doc-facets .pd-doc-facet-chip i {
  font-size: 10px;
  opacity: 0.7;
}
.pd-doc-facets .pd-doc-facet-chip:hover:not(.t2d-cf-overflow) {
  background: rgba(70,130,180,0.22);
}
/* The "+N" overflow chip — slate, no hover, no pointer, pushed to the right
   inside the last `.pd-doc-facet-row` so it never claims a row of its own. */
.pd-doc-facets .t2d-cf-overflow {
  background: rgba(94,108,127,0.14);
  color: #5a6478;
  cursor: default;
  font-weight: 600;
  margin-left: auto;
  flex-shrink: 0;
}

/* Active-search chip inserted into .pd-path-bar by the advanced panel AND the
   Búsqueda finger tab (after Apply). Same visual language: blue tint, funnel
   on the left, results-count label, x to clear. The chip auto-replaces an
   older one if both sources fire — only one filter is active at a time. */
.pd-path-bar button.t2d-search-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px 0 10px;
  margin-left: auto;
  background: rgba(70,130,180,0.16);
  color: #1a3a54;
  border: 1px solid rgba(70,130,180,0.35);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.pd-path-bar button.t2d-search-active-chip:hover {
  background: rgba(70,130,180,0.26);
}
.pd-path-bar button.t2d-search-active-chip i.ph {
  font-size: 13px;
  line-height: 1;
}
.pd-path-bar button.t2d-search-active-chip i.ph-x {
  font-size: 12px;
  opacity: 0.7;
}
.pd-path-bar button.t2d-search-active-chip:hover i.ph-x {
  opacity: 1;
}
.pd-path-bar button.t2d-search-active-chip span {
  white-space: nowrap;
}

.pd-doc-category-badge {
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1;
}

/* File-type badge (shown under the size) — monospace, neutral chip, with a
   stable data-filetype attribute for filtering. */
.pd-doc-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  color: #2c5171;
  background: rgba(70, 130, 180, 0.12);
  text-transform: uppercase;
  white-space: nowrap;
}
/* In the table view it sits on its own line right under the size. */
td > .pd-doc-type-badge { margin-top: 3px; }

/* Index-state badge (cloud files): indexed / indexing / error / cloud-only. */
.pd-idx-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.pd-idx-badge i { font-size: 9px; }
.pd-idx-indexed  { background: rgba(16,185,129,0.14); color: #0f7a5a; }
.pd-idx-indexing { background: rgba(70,130,180,0.16); color: #2c5171; }
.pd-idx-error    { background: rgba(239,68,68,0.14);  color: #b3261e; }
.pd-idx-cloud    { background: rgba(148,163,184,0.22); color: #5a6478; }
td > .pd-idx-badge { margin-top: 3px; }

/* Duplicate-of badge (#156): clickable chip linking to the original doc that
   was first content-hash indexed. Same height as the index-state badge so the
   badge row aligns; lavender tone to read as a relational hint, not a status. */
.pd-dup-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  background: rgba(168,142,240,0.16);
  color: #4a3580;
  cursor: pointer;
  transition: background 0.15s;
}
.pd-dup-badge:hover { background: rgba(168,142,240,0.28); }
.pd-dup-badge i { font-size: 9px; }
td > .pd-dup-badge { margin-top: 3px; }

.pd-doc-category-badge.waste {
  background: #fff3e0;
  color: #e65100;
}

.pd-doc-category-badge.safety {
  background: #e8f5e9;
  color: #2e7d32;
}

.pd-doc-category-badge.engineering {
  background: #e3f2fd;
  color: #1565c0;
}

.pd-doc-category-badge.quality {
  background: #f3e5f5;
  color: #6a1b9a;
}

.pd-workflow-badge {
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.pd-workflow-badge.draft {
  background: #f3f4f6;
  color: #6b7280;
}

.pd-workflow-badge.under-review {
  background: #fef3c7;
  color: #92400e;
}

.pd-workflow-badge.approved {
  background: #d1fae5;
  color: #065f46;
}

.pd-workflow-badge.archived {
  background: #e5e7eb;
  color: #4b5563;
}

/* Document Actions */
.pd-doc-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 3px;
}

.pd-doc-card:hover .pd-doc-actions {
  display: flex;
}

.pd-doc-action-btn {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #4682b4;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pd-doc-action-btn:hover {
  background: #4682b4;
  color: white;
  transform: scale(1.1);
}

.pd-doc-action-btn .fa {
  font-size: 11px;
}

/* Document List/Table View */
.pd-document-table {
  width: 100%;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  table-layout: auto;
}

/* Responsive rows: the Name column takes all the slack; every other column
   shrinks to its content so there is no dangling empty space. The last column
   is the row actions (⋮ more-options menu). */
.pd-document-table th:first-child,
.pd-document-table td:first-child { width: 100%; }
.pd-document-table th:not(:first-child),
.pd-document-table td:not(:first-child) { white-space: nowrap; }
.pd-document-table .pd-th-actions,
.pd-document-table .pd-row-actions { width: 40px; }

/* When the files card is narrow, drop the lower-value columns (Category,
   Status) so Name + Size + Modified + actions stay readable. */
@media (max-width: 1180px) {
  .pd-document-table th:nth-child(2), .pd-document-table td:nth-child(2),
  .pd-document-table th:nth-child(3), .pd-document-table td:nth-child(3) { display: none; }
}

.pd-document-table thead {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
}

.pd-document-table th {
  padding: 6px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-color);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border-color);
  line-height: 1.2;
}

.pd-document-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
}

.pd-document-table tbody tr:hover {
  background: rgba(70, 130, 180, 0.05);
}

.pd-document-table tbody tr.selected {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.1) 0%, rgba(46, 77, 111, 0.1) 100%);
}

.pd-document-table td {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-color);
  line-height: 1.2;
}

.pd-table-doc-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pd-table-doc-icon {
  width: 32px;
  height: 32px;
  background: rgba(70, 130, 180, 0.1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4682b4;
  flex-shrink: 0;
}

.pd-table-doc-icon .fa {
  font-size: 14px;
}

/* ===== RIGHT DETAILS PANEL - SLIDING CURTAIN ===== */
.pd-details-panel {
  position: fixed;
  top: calc(var(--navbar-height, 48px) + 6px); /* Below navbar with gap - CONSISTENT WITH CHAT PANEL */
  right: 0;
  bottom: 6px; /* Gap from bottom - CONSISTENT WITH CHAT PANEL */
  width: 400px;
  background: white;
  border-left: 1px solid rgba(70, 130, 180, 0.2);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
  z-index: 1045; /* Below chat panel, above navbar */
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-top-left-radius: 12px; /* Match chat panel */
  border-bottom-left-radius: 12px; /* Match chat panel */
  overflow: hidden;
}

.pd-details-panel.active {
  transform: translateX(0);
}

.pd-details-panel.collapsed {
  transform: translateX(100%);
}

/* Optional: Backdrop overlay when details panel is open */
.pd-details-backdrop {
  position: fixed;
  top: 0; /* Cover entire screen including navbar - CONSISTENT WITH CHAT PANEL */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1044; /* Just below details panel */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.pd-details-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Details Header */
.pd-details-header {
  padding: 9px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.details-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.details-title .fa {
  color: #4682b4;
  font-size: 14px;
}

.btn-close-details {
  width: 32px;
  height: 32px;
  padding: 0;
  background: white;
  color: #4682b4;
  border: 1px solid #4682b4;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-details:hover {
  background: #4682b4;
  color: white;
}

.btn-close-details .fa {
  font-size: 14px;
}

/* Details Body */
.pd-details-body {
  padding: 9px;
  flex: 1;
  overflow-y: auto;
}

/* Details Content */
.pd-details-content {
  padding: 9px;
  flex: 1;
  overflow-y: auto;
}

/* No Selection State */
.pd-no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.pd-no-selection .fa {
  font-size: 2.5em;
  margin-bottom: 12px;
  color: #d1d5db;
}

.pd-no-selection p {
  font-size: 12px;
  margin: 0;
}

/* File Preview */
.pd-preview {
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.pd-preview-placeholder {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.1) 0%, rgba(46, 77, 111, 0.1) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4682b4;
  font-size: 3em;
}

.pd-preview img {
  width: 100%;
  height: auto;
  display: block;
}

/* Metadata */
.pd-doc-title {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Raleway', Arial, sans-serif;
  color: var(--text-color);
  margin-bottom: 12px;
  word-wrap: break-word;
  line-height: 1.2;
}

.pd-metadata-group {
  margin-bottom: 12px;
}

.pd-metadata-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.pd-metadata-value {
  font-size: 12px;
  color: var(--text-color);
  line-height: 1.2;
}

.pd-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(70, 130, 180, 0.1);
  font-size: 11px;
  font-weight: 600;
  color: #2e4d6f;
}

.category-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.pd-sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgb(76, 175, 80);
}

.pd-sync-status .fa {
  font-size: 11px;
}

/* Details Actions */
.pd-details-actions {
  padding: 9px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pd-btn-block {
  width: 100%;
  justify-content: center;
}

/* Activity Feed */
.pd-activity-feed {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.pd-activity-feed h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pd-activity-feed h4 .fa {
  color: #4682b4;
  font-size: 11px;
}

.pd-activity-item {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.pd-activity-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.pd-activity-item .fa {
  width: 28px;
  height: 28px;
  background: rgba(70, 130, 180, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4682b4;
  font-size: 11px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-text {
  font-size: 11px;
  color: var(--text-color);
  margin-bottom: 3px;
  line-height: 1.2;
}

.activity-time {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1;
}

/* ===== MODALS ===== */
.pd-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pd-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.pd-modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pd-modal-header {
  padding: 6px;
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.08) 0%, rgba(46, 77, 111, 0.04) 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pd-modal-header h3 {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Raleway', Arial, sans-serif;
  color: var(--text-color);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pd-modal-header h3 .fa {
  color: #4682b4;
  font-size: 14px;
}

.pd-modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.pd-modal-footer {
  padding: 6px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Upload Zone */
.pd-upload-zone {
  border: 2px dashed rgba(70, 130, 180, 0.3);
  border-radius: var(--radius-sm);
  padding: 32px 16px;
  text-align: center;
  transition: all 0.2s;
  margin-bottom: 16px;
  background: rgba(70, 130, 180, 0.02);
}

.pd-upload-zone:hover,
.pd-upload-zone.drag-over {
  border-color: #4682b4;
  background: rgba(70, 130, 180, 0.08);
}

.pd-upload-zone .fa {
  font-size: 3em;
  color: #4682b4;
  margin-bottom: 12px;
}

.pd-upload-zone h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 6px;
}

.pd-upload-zone p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0;
}

.upload-hint {
  font-size: 10px;
  color: #888;
}

/* Form Controls */
.pd-upload-options .form-group {
  margin-bottom: 12px;
}

.pd-upload-options label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 4px;
}

.pd-upload-options .form-control {
  width: 100%;
  padding: 3px 8px;
  border: 1px solid rgba(76, 212, 192, 0.3);
  border-radius: var(--radius-sm);
  background: white;
  color: #333;
  font-size: 14px;
  height: 28px;
  line-height: 1.2;
  transition: all 0.2s ease;
}

.pd-upload-options .form-control:focus {
  outline: none;
  border-color: #4682b4;
  box-shadow: 0 0 0 2px rgba(70, 130, 180, 0.1);
}

.pd-upload-options select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='14' height='8' viewBox='0 0 14 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M1 1L7 7L13 1' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 30px;
}

/* ===== ELLIPSIS BUTTON ===== */
.pd-doc-more-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.95);
  color: #4682b4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

/* Show on card hover (desktop) */
.pd-doc-card:hover .pd-doc-more-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Always visible on mobile */
@media (max-width: 768px) {
  .pd-doc-more-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    width: 36px;
    height: 36px;
  }
}

.pd-doc-more-btn:hover {
  background: rgba(70, 130, 180, 0.1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pd-doc-more-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pd-doc-more-btn .fa {
  font-size: 14px;
}

/* List view button styling */
.pd-row-actions {
  width: 40px;
  text-align: center;
  vertical-align: middle;
}

.pd-row-actions .pd-doc-more-btn {
  position: relative;
  top: 0;
  left: 0;
  margin: 0 auto;
}

/* ===== CONTEXT MENU ===== */
.pd-context-menu {
  position: fixed;
  display: block;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px;
  min-width: 180px;
  z-index: 1000000002;
  animation: contextMenuFadeIn 0.15s ease-out;
}

/* Mobile touch optimizations */
@media (max-width: 768px) {
  .pd-context-item {
    padding: 6px 14px;
    font-size: 14px;
    min-height: 36px;
  }

  .pd-context-menu {
    padding: 3px;
  }

  .pd-context-divider {
    margin: 1px 0;
  }
}

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

.pd-context-item {
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  font-size: 13px;
  color: var(--text-color);
  line-height: 1.3;
}

.pd-context-item:hover {
  background: rgba(70, 130, 180, 0.08);
}

.pd-context-item.danger {
  color: rgb(244, 67, 54);
}

.pd-context-item.danger:hover {
  background: rgba(244, 67, 54, 0.1);
}

.pd-context-item .fa {
  width: 16px;
  text-align: center;
  font-size: 12px;
  color: #4682b4;
}

.pd-context-item.danger .fa {
  color: rgb(244, 67, 54);
}

.pd-context-divider {
  height: 1px;
  background: var(--border-color);
  margin: 2px 0;
}

/* Arrow pointer for context menu opening to the right */
.pd-context-menu.open-right::after {
  content: '';
  position: absolute;
  top: 16px;
  left: -8px;
  width: 0;
  height: 0;
  border-right: 8px solid white;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  z-index: 1001;
}

.pd-context-menu.open-right::before {
  content: '';
  position: absolute;
  top: 15px;
  left: -10px;
  width: 0;
  height: 0;
  border-right: 9px solid var(--border-color);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  z-index: 1000;
}

/* Highlight active card when context menu is open */
.pd-doc-card.context-menu-active,
.pd-doc-row.context-menu-active {
  outline: 2px solid #4682b4;
  outline-offset: 2px;
  background: rgba(70, 130, 180, 0.05);
  position: relative;
  z-index: 900;
}

.pd-doc-card.context-menu-active {
  box-shadow:
    0 0 0 2px rgba(70, 130, 180, 0.2),
    0 8px 24px rgba(70, 130, 180, 0.15);
  transform: translateY(-2px);
}

/* ===== FOLDER CONTEXT MENU ===== */
.pd-folder-context-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 6px;
  min-width: 180px;
  font-size: 12px;
  z-index: 99999;
  overflow: hidden;
}

.context-menu-item {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
  background: #ffffff;
  color: var(--text-color);
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.4;
  border-radius: var(--radius-sm);
}

.context-menu-item:hover {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.12) 0%, rgba(46, 77, 111, 0.12) 100%);
}

.context-menu-item i {
  width: 14px;
  text-align: center;
  color: #2e4d6f;
  font-size: 12px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.context-menu-item:hover i {
  transform: scale(1.1);
}

.context-menu-item span {
  font-size: 12px;
  font-weight: 500;
}

.context-menu-item[data-action="delete"]:hover {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.15) 0%, rgba(220, 53, 69, 0.1) 100%);
  color: #dc3545;
}

.context-menu-item[data-action="delete"]:hover i {
  color: #dc3545;
  transform: scale(1.15);
}

.context-menu-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(70, 130, 180, 0.3) 50%, transparent 100%);
  margin: 6px 8px;
}

/* ===== SCROLLBAR STYLING ===== */
.pd-sidebar-body::-webkit-scrollbar,
.pd-main-body::-webkit-scrollbar,
.pd-details-body::-webkit-scrollbar {
  width: 6px;
}

.pd-sidebar-body::-webkit-scrollbar-track,
.pd-main-body::-webkit-scrollbar-track,
.pd-details-body::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: var(--radius-sm);
}

.pd-sidebar-body::-webkit-scrollbar-thumb,
.pd-main-body::-webkit-scrollbar-thumb,
.pd-details-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

.pd-sidebar-body::-webkit-scrollbar-thumb:hover,
.pd-main-body::-webkit-scrollbar-thumb:hover,
.pd-details-body::-webkit-scrollbar-thumb:hover {
  background: #2e4d6f;
}

/* ===== RESPONSIVE DESIGN ===== */
/* Extra large screens - wider sidebar and 5 columns */
/* ===== RESPONSIVE DESIGN ===== */

/* Extra Large Screens - 5+ columns */
@media (min-width: 1600px) {
  .pd-document-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
  }
}

/* Large Screens - 4 columns */
@media (max-width: 1599px) and (min-width: 1200px) {
  .pd-document-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }
}

/* Medium Screens - narrower sidebar, 3 columns */
@media (max-width: 1199px) and (min-width: 992px) {
  .pd-sidebar {
    width: 280px;
    min-width: 280px;
  }

  .pd-document-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
  }

  .pd-details-panel {
    width: 350px;
  }
}

/* Tablet Landscape - narrower sidebar, 2-3 columns */
@media (max-width: 991px) and (min-width: 769px) {
  .pd-sidebar {
    width: 260px;
    min-width: 260px;
  }

  .pd-document-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
  }

  .pd-details-panel {
    width: 320px;
  }

  .pd-toolbar {
    flex-wrap: nowrap; /* Keep in one row */
    gap: 8px;
  }

  .pd-toolbar-right {
    flex: 1;
    max-width: none; /* Allow to expand */
    min-width: 0; /* Allow to shrink */
  }

  .pd-search-box {
    width: 100%;
    min-width: 120px; /* Minimum width for functionality */
  }
}

/* Tablet Portrait & Mobile - Collapsible Sidebar */
@media (max-width: 768px) {
  .pd-drive-container {
    padding: 0;
    height: calc(100vh - 60px);
    max-width: 100vw; /* Prevent horizontal overflow */
    overflow-x: hidden; /* Hide any overflow */
  }

  /* Ensure all children respect container width */
  .pd-drive-container * {
    box-sizing: border-box;
  }

  /* Hide sidebar by default on mobile */
  .pd-sidebar {
    position: fixed;
    left: -69%; /* Hide offscreen */
    top: 54px; /* Below navbar (48px) + gap (6px) - SAME AS RIGHT PANEL */
    bottom: 6px; /* Gap from bottom (6px) - SAME AS RIGHT PANEL */
    width: 69%; /* 69% width to allow clicking outside */
    min-width: 260px; /* Minimum usable width */
    max-width: 69%;
    height: auto; /* Auto height based on top/bottom */
    z-index: 1000000001 !important; /* Extremely high to show over all Frappe elements */
    transition: left 0.3s ease;
    border-radius: 0 var(--radius) var(--radius) 0; /* Rounded right corners - SAME AS RIGHT PANEL */
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    background: white !important;
    background-color: #ffffff !important;
    border-top: 2px solid var(--border-color); /* Top border - SAME AS RIGHT PANEL */
    border-bottom: 2px solid var(--border-color); /* Bottom border - SAME AS RIGHT PANEL */
    border-right: 2px solid var(--border-color); /* Right border - SAME AS RIGHT PANEL */
    border-left: none;
    overflow-y: auto; /* Allow scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    -webkit-transform: translateZ(0); /* Hardware acceleration for iOS */
    transform: translateZ(0);
    display: flex; /* Flex container */
    flex-direction: column; /* Vertical layout */
  }

  /* iOS Safari specific fixes for sidebar */
  @supports (-webkit-touch-callout: none) {
    .pd-sidebar {
      /* Ensure fixed positioning on iOS - SAME AS RIGHT PANEL */
      top: 54px !important; /* Below navbar with gap */
      bottom: 6px !important; /* Gap from bottom */
      height: auto !important; /* Auto height based on top/bottom */
      position: fixed !important;
    }
  }

  /* Show sidebar when active */
  .pd-drive-container.sidebar-active .pd-sidebar {
    left: 0;
  }

  /* Mobile sidebar overlay - SAME AS RIGHT PANEL */
  .pd-drive-container.sidebar-active::before {
    content: '';
    position: fixed;
    top: 48px; /* Start at navbar height (48px) - SAME AS RIGHT PANEL */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000000000 !important; /* Just below sidebar, above everything else */
  }

  /* Hide resize handle on mobile */
  .pd-resize-handle {
    display: none;
  }

  /* Main panel takes full width */
  .pd-main-panel {
    width: 100%;
    flex: 1;
    min-width: 0; /* Remove desktop min-width constraint */
    max-width: 100%; /* Ensure it doesn't overflow */
    border-left: 1px solid var(--border-color); /* Restore left border since no sidebar */
    border-radius: var(--radius); /* Full rounded corners on mobile */
    margin-left: 0; /* Remove negative margin */
    padding: 0;
  }

  /* Show sidebar toggle button */
  .pd-sidebar-toggle {
    display: flex !important;
  }

  /* Toolbar adjustments - keep in one row */
  .pd-toolbar {
    flex-wrap: nowrap; /* Force single row */
    padding: 6px;
    gap: 4px;
    min-height: 44px;
  }

  .pd-toolbar-left {
    gap: 4px;
    flex-shrink: 0; /* Don't shrink buttons */
  }

  .pd-toolbar-right {
    flex: 1;
    min-width: 0; /* Allow to shrink */
    max-width: none;
  }

  .pd-search-box {
    width: 100%;
    max-width: 100%;
    min-width: 100px; /* Minimum functional width */
  }

  /* Make buttons more compact on mobile */
  .pd-toolbar .pd-btn-icon {
    width: 32px;
    height: 32px;
    padding: 6px;
  }

  .pd-toolbar .pd-btn-icon i {
    font-size: 14px;
  }

  /* Path bar adjustments */
  .pd-path-bar {
    padding: 6px 8px;
    gap: 6px;
  }

  .pd-path-input-container {
    padding: 4px 8px;
  }

  /* Document grid - 2 columns */
  .pd-document-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 4px;
    max-width: 100%; /* Prevent overflow */
    box-sizing: border-box;
  }

  /* Content area - prevent overflow */
  .pd-content-area {
    max-width: 100%;
    overflow-x: hidden;
    padding: 0;
  }

  .pd-doc-card {
    border-radius: var(--radius-sm);
    padding: 4px;
  }

  .pd-doc-preview {
    height: 120px;
    font-size: 2.5em;
  }

  /* Details panel - 90% width */
  .pd-details-panel {
    width: 90%;
    max-width: 350px;
  }

  /* View controls */
  .pd-view-controls-bar {
    padding: 6px 8px;
  }

  /* Sidebar sections more compact */
  .pd-sidebar-section {
    padding: 8px;
  }

  /* Remove padding from full-width widgets on mobile */
  .widget.custom-block-widget-box.full-width {
    padding: 0 !important;
    margin: 0 !important;
  }

  .widget.custom-block-widget-box.full-width .widget-body {
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Remove padding from CE blocks on mobile */
  [data-page-route="Workspaces"] .codex-editor .codex-editor__redactor .ce-block .ce-block__content {
    padding: 0 !important;
  }

  [data-page-route="Workspaces"] .codex-editor .codex-editor__redactor .ce-block {
    padding: 0 !important;
  }
}

  .pd-section-header {
    padding: 6px 0;
  }

  .pd-filter-badge,
  .pd-category-badge {
    font-size: 9px;
    padding: 3px 5px;
    gap: 3px;
  }

  .pd-category-badge i {
    font-size: 9px;
  }

  .pd-category-name {
    font-size: 8px;
  }

  /* Workspace selector compact - ensure visible on mobile */
  .pd-workspace-selector {
    padding: 10px;
    min-height: 52px;
    margin-top: 0;
    position: sticky; /* Stick to top when scrolling */
    top: 0; /* Stick at top of sidebar */
    background: linear-gradient(135deg, rgba(70, 130, 180, 0.04) 0%, rgba(46, 77, 111, 0.02) 100%);
    z-index: 10; /* Above other sidebar content */
    flex-shrink: 0; /* Don't shrink */
    border-bottom: 1px solid var(--border-color); /* Visual separation */
  }

  .pd-workspace-dropdown {
    font-size: 13px;
    padding: 8px 10px;
    min-height: 36px;
  }

  /* Ensure floating label is visible on mobile */
  .pd-workspace-selector .floating-label {
    top: -14px;
    font-size: 11px;
  }

  /* Folder list header */
  .pd-folder-list-header {
    padding: 6px 10px;
  }
}

/* Mobile Small - 1 column, full-width details */
@media (max-width: 480px) {
  .pd-drive-container {
    height: calc(100vh - 50px);
    max-width: 100vw; /* Prevent horizontal overflow */
    overflow-x: hidden; /* Hide any overflow */
  }

  /* Main panel - ensure no overflow */
  .pd-main-panel {
    min-width: 0;
    max-width: 100%;
  }

  /* Sidebar 69% width on small mobile too */
  .pd-sidebar {
    width: 69%;
    min-width: 240px; /* Smaller minimum for very small screens */
    max-width: 69%;
    /* Keep same top/bottom positioning as tablet */
    top: 54px;
    bottom: 6px;
  }

  /* Path bar more compact */
  .pd-path-bar {
    padding: 4px 6px;
    min-height: 44px;
  }

  .pd-path-input {
    font-size: 12px;
  }

  /* Toolbar very compact */
  .pd-toolbar {
    padding: 6px;
    gap: 4px;
  }

  .pd-toolbar-left {
    gap: 4px;
  }

  .pd-btn-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .pd-btn-icon .fa {
    font-size: 14px;
  }

  /* Single column grid */
  .pd-document-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
  }

  .pd-doc-preview {
    height: 180px;
    font-size: 3.5em;
  }

  .pd-doc-info {
    padding: 10px;
  }

  .pd-doc-title {
    font-size: 13px;
  }

  .pd-doc-meta {
    font-size: 10px;
  }

  /* Full width details panel */
  .pd-details-panel {
    width: 100%;
    max-width: 100%;
  }

  /* View controls compact */
  .pd-view-controls-bar {
    padding: 4px 6px;
  }

  /* Sidebar sections very compact */
  .pd-sidebar-section {
    padding: 6px;
  }

  .pd-filter-badge,
  .pd-category-badge {
    font-size: 8px;
    padding: 2px 4px;
    gap: 2px;
  }

  .pd-category-badge i {
    font-size: 8px;
  }

  .pd-category-name {
    font-size: 8px;
  }

  .pd-badge-count {
    min-width: 16px;
    height: 16px;
    font-size: 9px;
    line-height: 16px;
  }

  /* Workspace selector very compact */
  .pd-workspace-selector {
    padding: 4px 8px;
    min-height: 40px;
  }

  .pd-workspace-dropdown {
    font-size: 12px;
    padding: 4px 8px;
  }

  /* Search input smaller */
  .pd-search-box input,
  .pd-filter-search-input {
    font-size: 12px;
  }

  /* Folder items compact */
  .pd-folder-item {
    padding: 6px 8px;
    font-size: 12px;
  }

  /* Modal adjustments */
  .pd-modal-content {
    width: 95%;
    margin: 10px;
  }

  .pd-modal-header h3 {
    font-size: 16px;
  }

  .pd-modal-body {
    padding: 12px;
  }
}

/* Mobile Extra Small - Optimize for very small screens */
@media (max-width: 360px) {
  .pd-sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
  }

  .pd-path-bar {
    padding: 4px;
  }

  .pd-toolbar {
    padding: 4px;
  }

  .pd-btn-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
  }

  .pd-btn-icon .fa {
    font-size: 12px;
  }

  .pd-document-grid {
    padding: 8px;
    gap: 10px;
  }

  .pd-doc-preview {
    height: 150px;
  }

  .pd-section-title {
    font-size: 11px;
  }

  .pd-workspace-dropdown {
    font-size: 11px;
  }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* ===== METADATA AND VERSION CONTAINERS ===== */
/* These are modal overlays that should be hidden by default */
.pd-metadata-container,
.pd-version-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.5);
}

.pd-metadata-container.active,
.pd-version-container.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== FOLDER TREE DIALOG ===== */
.pd-tree-modal-content {
  max-width: 700px;
  width: 90%;
}

.pd-tree-dialog-content {
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px;
}

/* Tree root node in dialog */
.pd-tree-dialog-content .pd-tree-root {
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  background: rgba(70, 130, 180, 0.08);
  border: 2px solid transparent;
}

.pd-tree-dialog-content .pd-tree-root:hover {
  background: rgba(70, 130, 180, 0.15);
  border-color: rgba(70, 130, 180, 0.3);
}

.pd-tree-dialog-content .pd-tree-root .ph-house {
  color: #4682b4;
  font-size: 14px;
}

/* Tree items in dialog */
.pd-tree-dialog-content .pd-tree-item {
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin: 0;
  font-size: 13px;
  line-height: 1;
  border: 2px solid transparent;
  position: relative;
}

.pd-tree-dialog-content .pd-tree-item:hover {
  background: rgba(70, 130, 180, 0.1);
  border-color: rgba(70, 130, 180, 0.2);
}

.pd-tree-dialog-content .pd-tree-item.selected {
  background: linear-gradient(135deg, rgba(70, 130, 180, 0.2) 0%, rgba(46, 77, 111, 0.2) 100%);
  border-color: #4682b4;
  font-weight: 600;
}

.pd-tree-dialog-content .pd-tree-item .ph-folder,
.pd-tree-dialog-content .pd-tree-item .ph-folder-open {
  font-size: 14px;
  color: #4682b4;
  flex-shrink: 0;
}

.pd-tree-dialog-content .pd-tree-item .ph-caret-right,
.pd-tree-dialog-content .pd-tree-item .ph-caret-down {
  font-size: 10px;
  transition: transform 0.2s ease;
  color: #999;
  width: 14px;
  flex-shrink: 0;
}

.pd-tree-dialog-content .pd-tree-item.expanded .ph-caret-right {
  transform: rotate(90deg);
}

.pd-tree-dialog-content .pd-tree-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pd-tree-dialog-content .pd-tree-item-count {
  font-size: 11px;
  font-weight: 700;
  color: white;
  /* Background color set dynamically via JavaScript gradient */
  background: #4682b4; /* Fallback color */
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Nested folder children in dialog */
.pd-tree-dialog-content .pd-tree-children {
  margin: 0;
  padding-left: 16px;
  border-left: 2px solid rgba(70, 130, 180, 0.2);
}

/* ===== FRAPPE TREE COMPONENT OVERRIDES ===== */
/* Override Frappe's default tree component styles for compact display */

/* Tree node container */
.modal-body .tree-node,
.modal-dialog .tree-node {
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
}

/* Tree link (clickable area) */
.modal-body .tree-link,
.modal-dialog .tree-link {
  padding: 3px 6px !important;
  margin: 0 !important;
  line-height: 1 !important;
  min-height: auto !important;
}

/* Tree label text */
.modal-body .tree-label,
.modal-dialog .tree-label {
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Tree children (nested items) - reduce indent */
.modal-body .tree-children,
.modal-dialog .tree-children {
  padding-left: 12px !important;
  margin: 0 !important;
}

/* Tree node list items */
.modal-body .tree-node > li,
.modal-dialog .tree-node > li {
  margin: 0 !important;
  padding: 0 !important;
}

/* Frappe tree component root */
.modal-body .frappe-tree,
.modal-dialog .frappe-tree {
  line-height: 1 !important;
}

.modal-body .frappe-tree .tree-node,
.modal-dialog .frappe-tree .tree-node {
  margin-bottom: 0 !important;
}

.modal-body .frappe-tree .tree-link,
.modal-dialog .frappe-tree .tree-link {
  padding: 3px 4px !important;
  line-height: 1 !important;
  min-height: 20px !important;
}

.modal-body .frappe-tree .tree-children,
.modal-dialog .frappe-tree .tree-children {
  padding-left: 12px !important;
}

/* Remove extra spacing from tree items */
.modal-body ul.tree,
.modal-dialog ul.tree {
  padding-left: 0 !important;
  margin: 0 !important;
}

.modal-body ul.tree > li,
.modal-dialog ul.tree > li {
  margin: 0 !important;
  padding: 0 !important;
}

/* Compact tree icons */
.modal-body .tree-link .fa,
.modal-dialog .tree-link .fa {
  font-size: 12px !important;
}

/* ===== CUSTOM TREE OVERRIDES (for dynamically generated trees) ===== */
/* Ultra-specific selectors to override inline styles */
.modal-body .frappe-tree-node,
.modal-dialog .frappe-tree-node,
div[data-fieldname="tree_area"] .frappe-tree-node,
.frappe-control .frappe-tree-node {
  padding: 2px 4px !important;
  margin-bottom: 0 !important;
  line-height: 1 !important;
  min-height: auto !important;
}

.modal-body .tree-node-container,
.modal-dialog .tree-node-container,
div[data-fieldname="tree_area"] .tree-node-container,
.frappe-control .tree-node-container {
  margin-bottom: 0 !important;
}

.modal-body .tree-children,
.modal-dialog .tree-children,
div[data-fieldname="tree_area"] .tree-children,
.frappe-control .tree-children {
  margin-left: 12px !important;
  padding-left: 0 !important;
}

.modal-body .frappe-tree-list,
.modal-dialog .frappe-tree-list,
div[data-fieldname="tree_area"] .frappe-tree-list,
.frappe-control .frappe-tree-list {
  margin-left: 12px !important;
}

/* Root node - ultra specific */
.modal-body .root-node,
.modal-dialog .root-node,
div[data-fieldname="tree_area"] .root-node,
.frappe-control .root-node {
  padding: 3px 4px !important;
  margin-bottom: 2px !important;
  line-height: 1 !important;
}

/* ========================================
   SEARCH HIGHLIGHTING
   ======================================== */

/* Highlighted search terms in context snippets */
mark {
  background-color: #fff59d; /* Light yellow */
  color: #000;
  padding: 1px 2px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Alternative style for content search results */
.pd-content-area mark {
  background-color: #ffeb3b; /* Brighter yellow */
  box-shadow: 0 0 3px rgba(255, 235, 59, 0.5);
}

/* ===== SEMANTIC SEARCH SIMILARITY BADGES ===== */

/* Similarity indicator overlay on document card */
.pd-similarity-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
}

/* Score badge for ALL search modes (Semantic, Hybrid, Natural, Boolean, Phrase) */
.pd-similarity-badge,
.pd-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: 'Figtree', Arial, sans-serif;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.pd-similarity-badge i,
.pd-score-badge i {
  font-size: 13px;
}

/* High score - Green (Semantic/Hybrid: 70%+, Fulltext: 3.0+) */
.pd-similarity-badge.high,
.pd-score-badge.high {
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: white;
}

.pd-similarity-badge.high:hover,
.pd-score-badge.high:hover {
  box-shadow: 0 3px 8px rgba(76, 175, 80, 0.4);
  transform: translateY(-1px);
}

/* Medium score - Orange (Semantic/Hybrid: 40-69%, Fulltext: 1.0-2.9) */
.pd-similarity-badge.medium,
.pd-score-badge.medium {
  background: linear-gradient(135deg, #ff9800, #ffa726);
  color: white;
}

.pd-similarity-badge.medium:hover,
.pd-score-badge.medium:hover {
  box-shadow: 0 3px 8px rgba(255, 152, 0, 0.4);
  transform: translateY(-1px);
}

/* Low score - Blue-gray (Semantic/Hybrid: <40%, Fulltext: <1.0) */
.pd-similarity-badge.low,
.pd-score-badge.low {
  background: linear-gradient(135deg, #607d8b, #78909c);
  color: white;
}

.pd-similarity-badge.low:hover,
.pd-score-badge.low:hover {
  box-shadow: 0 3px 8px rgba(96, 125, 139, 0.4);
  transform: translateY(-1px);
}

/* ===== AI CHAT SLIDE PANEL ===== */

/* Floating AI Button */
.pd-ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4682b4, #2e4d6f);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 188, 212, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 999;
}

.pd-ai-chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 188, 212, 0.6);
}

.pd-ai-chat-fab i {
  font-size: 24px;
}

/* AI Chat Backdrop */
.pd-ai-chat-backdrop {
  position: fixed;
  top: 0; /* Cover entire screen including navbar */
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1050; /* Above navbar (1030) but below modals (1055) */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.pd-ai-chat-backdrop.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* AI Chat Panel — full parity with the details/account slide panels (shared CSS
   in drive.html): FULL height OVER the navbar (top:0/bottom:0), 620px width,
   transform-based slide, z-index 1600 (above its 1599 backdrop). Mirrors the
   shared rule exactly so there's no stylesheet fight. */
.pd-ai-chat-panel {
  position: fixed !important;
  top: 0 !important;
  right: 0;
  bottom: 0 !important;
  width: var(--t2d-panel-w, min(620px, 96vw));
  background: #ffffff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
  z-index: 1600 !important;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 50px));
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0;
  overflow: hidden;
}

.pd-ai-chat-panel.active {
  transform: translateX(0);
  right: 0;
}

/* Wide mode (toggled via the header's expand button) — bigger ceiling on the
   panel width so the user can read MD tables / wide source-card expansions
   without horizontal scroll. Default ceiling stays 620px; wide pushes to
   min(960px, 96vw) which is comfortable on a typical 13-15" laptop. */
.pd-ai-chat-panel.wide {
  width: min(960px, 96vw) !important;
}

/* AI Chat Header (blue gradient like Frappe dialogs) */
.pd-ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;                          /* plain white — parity w/ details panel */
  border-bottom: 1px solid rgba(70, 130, 180, 0.18);
  color: var(--accent-color, #2c5171);
  flex-shrink: 0;
}
.pd-ai-chat-actions { display: flex; align-items: center; gap: 6px; }

/* Curtain Header (same style as AI Chat Header) */
.pd-curtain-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px;
  background: linear-gradient(135deg, #4682b4 0%, #2e4d6f 100%);
  border-bottom: 2px solid #2e4d6f;
  flex-shrink: 0;
}

.pd-ai-chat-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-color, #2c5171);
  flex: 1;
  font-family: 'Montserrat', 'Raleway', Arial, sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pd-ai-chat-title i,
.pd-ai-chat-title .fa {
  color: var(--primary-color, #4682b4);
  font-size: 18px;
}

/* AI Chat Header Buttons - MUST be in CSS for Shadow DOM */
.pd-ai-chat-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white !important;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pd-ai-chat-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.pd-ai-chat-btn i,
.pd-ai-chat-btn .fa {
  color: white !important;
  font-size: 16px;
}

.pd-close-ai-chat:hover {
  background: rgba(244, 67, 54, 0.3);
  color: #f44336 !important;
  transform: rotate(90deg);
}

/* AI Chat Content */
.pd-ai-chat-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pd-ai-chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
}

.pd-ai-chat-loading i {
  font-size: 32px;
  color: #4682b4;
}

.pd-ai-chat-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.pd-ai-chat-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* AI Chat Footer */
/* Footer — compact pibiCo chrome (matches the app footer aesthetic): light,
   small, Inter, tight line-height. */
.pd-ai-chat-footer {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.6);
  border-top: 1px solid rgba(70, 130, 180, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 12px;
  color: var(--text-secondary, #5b6b7c);
  line-height: 1;
}

.pd-ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary, #5b6b7c);
}

.pd-ai-status i {
  animation: pulse 2s ease-in-out infinite;
}

.pd-ai-model-info {
  font-size: 11px;
  color: var(--text-secondary, #5b6b7c);
  font-weight: 500;
}

.pd-ai-status-dot { color: #10b981; font-size: 9px; }   /* green "ready" dot */
.pd-ai-model-name { font-family: var(--font-mono, 'JetBrains Mono', monospace); }

/* Conversation actions moved into the search/context bar (header keeps only X). */
.pd-ai-context-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.pd-ai-context-actions .pd-btn-icon { width: 28px; height: 28px; }
.pd-ai-library-select,
.pd-ai-mode-select {
  flex: 1; min-width: 0; max-width: 240px;
  height: 34px;                 /* match the 34px action buttons */
  box-sizing: border-box;
  padding: 0 8px;
  line-height: 1;
  font-size: 12px;
  font-family: var(--font-body, 'Inter', sans-serif);
  border: 1px solid rgba(70, 130, 180, 0.25);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-color, #2c3e50);
  cursor: pointer;
}
.pd-ai-mode-select { flex: 0 0 auto; width: auto; max-width: 210px; }

/* Chat input row — give the textarea real styling (was UA default: a resize
   grip + grey border + scrollbar). resize:none removes the grip; height
   matches the 34px send button. */
.pd-ai-input-area {
  padding: 6px;
}
.pd-ai-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.pd-ai-input {
  flex: 1;
  resize: none;
  overflow-y: auto;
  box-sizing: border-box;
  min-height: 34px;
  max-height: 120px;
  padding: 7px 10px;
  line-height: 1.3;
  font-size: 14px;
  font-family: var(--font-body, 'Inter', sans-serif);
  border: 1px solid var(--pibico-mid-gray, #cbd5e1);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-color, #2c3e50);
}
.pd-ai-input:focus {
  outline: none;
  border-color: var(--primary, #4682b4);
  box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.12);
}
.pd-ai-send-btn { width: 34px; height: 34px; flex-shrink: 0; }

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

/* Context Bar */
.pd-ai-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  background: var(--pibico-light-gray);
  border-bottom: 1px solid var(--pibico-mid-gray);
  flex-shrink: 0;
}

.pd-ai-context-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-color);
}

.pd-ai-context-info i {
  color: #4682b4;
}

/* Scope badge: shown only when the companion was launched from a doc
   preview's "Ask Talky about this doc" button. Chip-style, dismissible. */
.pd-ai-scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 8px;
  background: rgba(70, 130, 180, 0.12);
  border: 1px solid rgba(70, 130, 180, 0.35);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-color);
  max-width: 240px;
}
.pd-ai-scope-badge i.ph-paperclip {
  font-size: 13px;
  color: #4682b4;
  flex-shrink: 0;
}
.pd-ai-scope-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.pd-ai-scope-clear {
  background: transparent;
  border: 0;
  padding: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  border-radius: 50%;
  color: var(--text-color);
  opacity: 0.65;
}
.pd-ai-scope-clear:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}
.pd-ai-scope-clear i { font-size: 11px; }

.pd-clear-chat {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.pd-clear-chat:hover {
  opacity: 1;
  background: var(--control-bg-hover);
}

/* Messages Container */
.pd-ai-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  background: #fafafa;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pd-ai-messages-container::-webkit-scrollbar {
  width: 6px;
}

.pd-ai-messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.pd-ai-messages-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

.pd-ai-messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Message Bubbles */
.pd-ai-message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.3s ease-out;
}

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

.pd-ai-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.pd-ai-assistant .pd-ai-message-avatar {
  background: linear-gradient(135deg, #4682b4, #2e4d6f);
  color: white;
  padding: 6px;
}

.pd-ai-assistant .pd-ai-message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0) invert(1); /* Make SVG white */
}

.pd-ai-user .pd-ai-message-avatar {
  background: var(--primary);
  color: white;
}

.pd-ai-message-content {
  flex: 1;
  min-width: 0;
}

.pd-ai-message-text {
  background: white !important;
  padding: 6px 12px !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  border: 1px solid var(--pibico-light-gray) !important;
  font-family: var(--font-body, 'Inter', sans-serif) !important;
  line-height: 1.35 !important;
  font-size: 14px !important;
  color: #2c3e50 !important;
}

.pd-ai-user .pd-ai-message-text {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
}

/* The generic inner-element rule below forces #2c3e50 on every p/div/span,
   which on the blue user bubble renders dark-on-blue (invisible). Re-assert
   white for inner elements inside user bubbles. */
.pd-ai-user .pd-ai-message-text p,
.pd-ai-user .pd-ai-message-text li,
.pd-ai-user .pd-ai-message-text div,
.pd-ai-user .pd-ai-message-text span,
.pd-ai-user .pd-ai-message-text blockquote {
  color: #fff !important;
}

/* ALL elements inside message - consistent padding and line-height */
.pd-ai-message-text p,
.pd-ai-message-text h1,
.pd-ai-message-text h2,
.pd-ai-message-text h3,
.pd-ai-message-text h4,
.pd-ai-message-text h5,
.pd-ai-message-text h6,
.pd-ai-message-text li,
.pd-ai-message-text div,
.pd-ai-message-text span,
.pd-ai-message-text blockquote {
  margin: 0 !important;
  padding: 3px 0 !important;
  line-height: 1 !important;
  font-family: 'Figtree', Arial, sans-serif !important;
  color: #2c3e50 !important;
}

/* Paragraphs */
.pd-ai-message-text p {
  font-size: 14px !important;
}

/* Headers */
.pd-ai-message-text h1 {
  font-size: 16px !important;
  font-weight: 600 !important;
}

.pd-ai-message-text h2 {
  font-size: 14px !important;
  font-weight: 600 !important;
}

.pd-ai-message-text h3 {
  font-size: 14px !important;
  font-weight: 600 !important;
}

.pd-ai-message-text h4,
.pd-ai-message-text h5,
.pd-ai-message-text h6 {
  font-size: 14px !important;
  font-weight: 600 !important;
}

/* Lists */
.pd-ai-message-text ul,
.pd-ai-message-text ol {
  margin: 0 !important;
  padding: 3px 0 3px 20px !important;
  line-height: 1 !important;
}

.pd-ai-message-text li {
  font-size: 14px !important;
}

.pd-ai-message-text li p {
  display: inline !important;
  padding: 0 !important;
}

/* Nested lists */
.pd-ai-message-text li ul,
.pd-ai-message-text li ol {
  padding: 3px 0 3px 16px !important;
}

/* Bold text */
.pd-ai-message-text strong,
.pd-ai-message-text b {
  font-weight: 600 !important;
  color: #2c3e50 !important;
}

.pd-ai-user .pd-ai-message-text strong,
.pd-ai-user .pd-ai-message-text b {
  color: white !important;
}

/* Italic text */
.pd-ai-message-text em,
.pd-ai-message-text i {
  font-style: italic !important;
}

/* Inline code */
.pd-ai-message-text code {
  background: rgba(70, 130, 180, 0.1) !important;
  padding: 1px 4px !important;
  border-radius: var(--radius-sm) !important;
  font-family: 'Courier New', Courier, monospace !important;
  font-size: 12px !important;
  line-height: 1 !important;
  color: #4682b4 !important;
}

.pd-ai-user .pd-ai-message-text code {
  background: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
}

/* User message - all text white */
.pd-ai-user .pd-ai-message-text p,
.pd-ai-user .pd-ai-message-text h1,
.pd-ai-user .pd-ai-message-text h2,
.pd-ai-user .pd-ai-message-text h3,
.pd-ai-user .pd-ai-message-text h4,
.pd-ai-user .pd-ai-message-text h5,
.pd-ai-user .pd-ai-message-text h6,
.pd-ai-user .pd-ai-message-text li,
.pd-ai-user .pd-ai-message-text div,
.pd-ai-user .pd-ai-message-text span,
.pd-ai-user .pd-ai-message-text blockquote {
  color: white !important;
}

/* Code blocks */
.pd-ai-message-text pre {
  background: #f6f8fa !important;
  border: 1px solid #e1e4e8 !important;
  border-radius: var(--radius-sm) !important;
  padding: 6px 8px !important;
  margin: 3px 0 !important;
  overflow-x: auto !important;
  line-height: 1 !important;
}

.pd-ai-message-text pre code {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  color: #4682b4 !important;
  font-size: 12px !important;
  line-height: 1 !important;
}

.pd-ai-user .pd-ai-message-text pre {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

.pd-ai-user .pd-ai-message-text pre code {
  color: white !important;
}

/* Links */
.pd-ai-message-text a {
  color: #4682b4 !important;
  text-decoration: none !important;
  border-bottom: 1px solid transparent !important;
  transition: border-color 0.2s !important;
}

.pd-ai-message-text a:hover {
  border-bottom-color: #4682b4 !important;
}

.pd-ai-user .pd-ai-message-text a {
  color: white !important;
  border-bottom-color: rgba(255, 255, 255, 0.5) !important;
}

/* Blockquotes */
.pd-ai-message-text blockquote {
  margin: 3px 0 !important;
  padding: 3px 8px !important;
  border-left: 3px solid #4682b4 !important;
  background: rgba(70, 130, 180, 0.05) !important;
  font-style: italic !important;
  line-height: 1 !important;
}

.pd-ai-user .pd-ai-message-text blockquote {
  border-left-color: white !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

/* Horizontal rules */
.pd-ai-message-text hr {
  margin: 3px 0 !important;
  border: none !important;
  border-top: 1px solid #ddd !important;
}

/* Line breaks */
.pd-ai-message-text br {
  line-height: 1 !important;
}

/* =================================== */
/* Markdown Tables - DataTable Style   */
/* =================================== */

.pd-table-wrapper {
  width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  margin: 3px 0 !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid #ddd !important;
  position: relative !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Scrollbar for table wrapper */
.pd-table-wrapper::-webkit-scrollbar {
  height: 8px !important;
}

.pd-table-wrapper::-webkit-scrollbar-track {
  background: #f0f0f0 !important;
  border-radius: var(--radius-sm) !important;
}

.pd-table-wrapper::-webkit-scrollbar-thumb {
  background: #ccc !important;
  border-radius: var(--radius-sm) !important;
}

.pd-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #999 !important;
}

.pd-md-table {
  width: 100% !important;
  min-width: max-content !important;
  border-collapse: collapse !important;
  font-size: 13px !important;
  line-height: 1 !important;
}

.pd-md-table thead {
  background: linear-gradient(135deg, #4682b4 0%, #5a9fd4 100%) !important;
  color: white !important;
}

.pd-md-table th {
  padding: 3px 8px !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 11px !important;
  letter-spacing: 0.12em !important;
  white-space: nowrap !important;
  border-bottom: 2px solid #3d7199 !important;
  text-align: left !important;
  color: white !important;
  background: linear-gradient(135deg, #4682b4 0%, #5a9fd4 100%) !important;
}

.pd-md-table tbody tr {
  border-bottom: 1px solid #eee !important;
  transition: background-color 0.15s ease !important;
}

.pd-md-table tbody tr:nth-child(even) {
  background: #f8f9fa !important;
}

.pd-md-table tbody tr:hover {
  background: rgba(70, 130, 180, 0.08) !important;
}

.pd-md-table td {
  padding: 3px 8px !important;
  white-space: nowrap !important;
  color: #2c3e50 !important;
  line-height: 1 !important;
}

/* First column sticky for wide tables */
.pd-md-table th:first-child,
.pd-md-table td:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 1 !important;
}

.pd-md-table th:first-child {
  background: linear-gradient(135deg, #4682b4 0%, #5a9fd4 100%) !important;
}

.pd-md-table tbody tr:nth-child(odd) td:first-child {
  background: white !important;
}

.pd-md-table tbody tr:nth-child(even) td:first-child {
  background: #f8f9fa !important;
}

.pd-md-table tbody tr:hover td:first-child {
  background: rgba(70, 130, 180, 0.08) !important;
}

/* Document Badge Styles */
.pd-doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  margin-right: 6px;
  margin-bottom: 4px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.pd-doc-badge i {
  font-size: 10px;
}

/* Library badge - blue theme */
.pd-doc-badge-library {
  background: rgba(70, 130, 180, 0.1);
  color: #4682b4;
  border: 1px solid rgba(70, 130, 180, 0.2);
}

/* Folder badge - amber theme */
.pd-doc-badge-folder {
  background: rgba(255, 152, 0, 0.1);
  color: #ff9800;
  border: 1px solid rgba(255, 152, 0, 0.2);
}

/* Document badge - gray theme - clickable */
.pd-doc-badge-document {
  background: rgba(96, 125, 139, 0.1);
  color: #607d8b;
  border: 1px solid rgba(96, 125, 139, 0.2);
  cursor: pointer;
}

/* Score badge - green theme */
.pd-doc-badge-score {
  background: rgba(76, 175, 80, 0.1);
  color: #4caf50;
  border: 1px solid rgba(76, 175, 80, 0.2);
}

/* Hover effects for badges */
.pd-doc-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Meta container for badges */
.pd-ai-doc-result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* NOTE: Document card styles removed from CSS - now applied as inline styles in JavaScript
   (slide_panel_frappe.js) for reliable application to dynamically generated content */

/* ============================================================================
   FRAPPE MODAL/SLIDE PANEL H2 STYLING - FIX FOR DOCUMENT PREVIEW
   ============================================================================
   These rules target H2 elements in Frappe modals/slide panels used for
   document preview. Applied globally to ensure consistent compact sizing.
   ============================================================================ */

/* Target H2 in Frappe modal bodies (slide panels, dialogs) */
.modal-body h2,
.frappe-control h2,
.form-layout h2,
body h2 {
  font-size: 14px !important;
  margin: 8px 0 4px 0 !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
}

/* First H2 in container - remove top margin */
.modal-body h2:first-child,
.frappe-control h2:first-child,
.form-layout h2:first-child {
  margin-top: 0 !important;
}

/* H1 and H3 for consistency */
.modal-body h1,
.frappe-control h1,
.form-layout h1,
body h1 {
  font-size: 16px !important;
  margin: 8px 0 4px 0 !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
}

.modal-body h3,
.frappe-control h3,
.form-layout h3,
body h3 {
  font-size: 13px !important;
  margin: 8px 0 4px 0 !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
}

/* Override Frappe's desk.bundle media query that increases h2 size on larger screens */
@media (min-width: 768px) {
  .modal-body h2,
  .frappe-control h2,
  .form-layout h2,
  body h2,
  .page-content h2,
  .container h2 {
    font-size: 14px !important;
  }

  .modal-body h1,
  .frappe-control h1,
  .form-layout h1,
  body h1,
  .page-content h1,
  .container h1 {
    font-size: 16px !important;
  }

  .modal-body h3,
  .frappe-control h3,
  .form-layout h3,
  body h3,
  .page-content h3,
  .container h3 {
    font-size: 13px !important;
  }
}


/* ── List (table) view: responsive + ellipsized long names ───────────────────
   table-layout:fixed bounds the columns so a long file name ellipsizes inside
   the Name cell instead of blowing out the row; narrow widths drop the lower-
   priority columns. */
.pd-document-table { width: 100%; table-layout: fixed; }
.pd-document-table th, .pd-document-table td {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pd-document-table th:nth-child(2), .pd-document-table td:nth-child(2) { width: 128px; }  /* Category */
.pd-document-table th:nth-child(3), .pd-document-table td:nth-child(3) { width: 92px; }   /* Status */
.pd-document-table th:nth-child(4), .pd-document-table td:nth-child(4) { width: 116px; }  /* Size */
.pd-document-table th:nth-child(5), .pd-document-table td:nth-child(5) { width: 120px; }  /* Modified */
.pd-document-table th:nth-child(6), .pd-document-table td:nth-child(6) { width: 44px; }   /* Actions */
/* Name cell: icon + ellipsized name + (badges stay full size). */
.pd-doc-name-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pd-doc-name-cell > i, .pd-doc-name-cell > .pd-score-badge,
.pd-doc-name-cell > .pd-favorite-star, .pd-doc-name-cell > .pd-reference-icon { flex-shrink: 0; }
.pd-doc-name-cell > span:not([class]) {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
/* Responsive: shed lower-priority columns as the workspace narrows. */
@media (max-width: 1180px) {
  .pd-document-table th:nth-child(2), .pd-document-table td:nth-child(2) { display: none; }  /* Category */
}
@media (max-width: 920px) {
  .pd-document-table th:nth-child(5), .pd-document-table td:nth-child(5) { display: none; }  /* Modified */
}
@media (max-width: 720px) {
  .pd-document-table th:nth-child(3), .pd-document-table td:nth-child(3) { display: none; }  /* Status */
}

/* ============================================================
   Companion thread-history panel (pibiCo compact density)
   Replaces the un-styled browser-default rendering that left
   each card with huge whitespace below.
   ============================================================ */
.pd-thread-history-panel {
  position: absolute;
  inset: 44px 0 0 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 5;
}
.pd-thread-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(70,130,180,0.10);
  font-size: 12px;
  font-weight: 600;
  color: #2c5171;
  line-height: 1;
  flex-shrink: 0;
}
.pd-thread-history-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 2px 0;
}
.pd-thread-empty {
  text-align: center;
  padding: 20px 12px;
  color: #999;
  font-size: 11px;
  line-height: 1.2;
}
.pd-thread-empty i { font-size: 28px; opacity: 0.4; display: block; margin-bottom: 6px; }
.pd-thread-empty p { margin: 2px 0; }

.pd-thread-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-bottom: 1px solid rgba(70,130,180,0.06);
  cursor: pointer;
  transition: background 0.12s;
  line-height: 1;
}
.pd-thread-item:hover { background: rgba(70,130,180,0.05); }
.pd-thread-item.active { background: rgba(70,130,180,0.10); }
.pd-thread-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  color: #6a9bc3;
  font-size: 14px;
}
.pd-thread-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pd-thread-title {
  font-size: 12px;
  font-weight: 600;
  color: #2c5171;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-thread-meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: #888;
  line-height: 1;
  flex-wrap: nowrap;
  overflow: hidden;
}
.pd-thread-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.pd-thread-meta-item i { font-size: 10px; opacity: 0.7; }
.pd-thread-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.pd-thread-item:hover .pd-thread-actions { opacity: 1; }
.pd-thread-action-btn {
  background: transparent;
  border: none;
  color: #6a9bc3;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.pd-thread-action-btn:hover { background: rgba(70,130,180,0.12); color: #2c5171; }
.pd-thread-action-btn.delete:hover { background: rgba(239,68,68,0.10); color: #ef4444; }

/* Pager footer — page-size selector + ← / N / → */
.pd-thread-history-footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(70,130,180,0.10);
  background: rgba(255,255,255,0.95);
}
.pd-thread-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  font-size: 10px;
  color: #555;
  line-height: 1;
}
.pd-thread-pager-hint {
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: #999;
  padding-bottom: 3px;
  line-height: 1.1;
}
.pd-thread-pager-size {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pd-thread-pager-select {
  font-size: 10px;
  padding: 1px 4px;
  border: 1px solid rgba(70,130,180,0.25);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #2c5171;
  cursor: pointer;
  line-height: 1.2;
}
.pd-thread-pager-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pd-thread-pager-prev, .pd-thread-pager-next {
  background: rgba(70,130,180,0.10);
  color: #2c5171;
  border: none;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.pd-thread-pager-prev:hover:not(:disabled),
.pd-thread-pager-next:hover:not(:disabled) {
  background: rgba(70,130,180,0.22);
}
.pd-thread-pager-prev:disabled,
.pd-thread-pager-next:disabled { opacity: 0.35; cursor: default; }
.pd-thread-pager-page { font-weight: 600; min-width: 56px; text-align: center; }

/* ============================================================
   Advanced search slide panel — results + pager
   `.t2d-sf-*` classes were referenced from JS without CSS, so
   the results list rendered with browser defaults (no flex, no
   tight spacing). Add compact rules + pager.
   ============================================================ */
.t2d-sf-results { padding: 4px 10px 0; }
.t2d-sf-rhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #2c5171;
  padding: 4px 0 4px;
  line-height: 1;
}
/* Pager lives inside the pinned head now — drop the footer chrome. */
.t2d-sf-rhead .t2d-sf-pager {
  padding: 0;
  margin-top: 0;
  border-top: none;
  font-weight: 400;
}
/* The list scrolls on its own so head + pager stay reachable with any
   result count; panel-body scroll remains as the outer fallback. */
.t2d-sf-rlist {
  max-height: 52vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.t2d-sf-empty {
  text-align: center;
  padding: 16px 8px;
  color: #999;
  font-size: 11px;
  line-height: 1.2;
}
.t2d-sf-rrow-wrap { margin: 0; }
.t2d-sf-rtop { display: flex; }
.t2d-sf-rrow {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(70,130,180,0.06);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 11px;
  color: #333;
  line-height: 1.1;
  transition: background 0.12s;
}
.t2d-sf-rrow:hover { background: rgba(70,130,180,0.06); }
.t2d-sf-rrow i.ph {
  font-size: 14px;
  color: #6a9bc3;
  flex-shrink: 0;
}
.t2d-sf-rtext {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.t2d-sf-rtext b {
  font-size: 11px;
  font-weight: 600;
  color: #2c5171;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t2d-sf-rtext small {
  font-size: 10px;
  color: #888;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t2d-sf-score {
  flex-shrink: 0;
  background: rgba(70,130,180,0.12);
  color: #2c5171;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  white-space: nowrap;
}
/* "+N copias" pill on the survivor of a folded duplicate-group (Task #5). */
.t2d-sf-dup {
  flex-shrink: 0;
  background: rgba(230,126,34,0.14);
  color: #b85b00;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  line-height: 1.2;
  white-space: nowrap;
  margin-right: 4px;
  cursor: help;
}
/* Plain checkbox row inside the advanced-search panel. Sits alongside
   the existing range-slider .t2d-sf rows. */
.t2d-sf.t2d-sf-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.t2d-sf.t2d-sf-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}
.t2d-sf.t2d-sf-check span {
  font-size: 12px;
  color: #2c5171;
  cursor: pointer;
}
/* Folder picker row — input + tree-icon button side-by-side. */
.t2d-sf-folder-row {
  display: flex;
  /* Centrado, no estirado: el botón lleva alto propio —el panel vive dentro
     de `.pd-sidebar` y allí los controles miden 26 px con `!important`— así
     que `stretch` no lo estiraba y lo dejaba pegado arriba, 4 px más corto
     que el campo. Centrar no depende de quién gane esa pelea de alturas. */
  align-items: center;
  gap: 6px;
}
.t2d-sf-folder-row > input { flex: 1 1 auto; min-width: 0; }
.t2d-sf-folder-row > .pd-btn-icon {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(70,130,180,0.30);
  /* Un solo radio para todos los controles: el mismo del campo que tiene al
     lado. Llevaba 6 px y el input 8, y a 32 px de alto la diferencia se ve. */
  border-radius: var(--radius-sm);
  background: rgba(70,130,180,0.06);
  color: #2c5171;
  cursor: pointer;
}
.t2d-sf-folder-row > .pd-btn-icon:hover { background: rgba(70,130,180,0.14); }

/* Adv-search pager — same visual language as the history pager so the
   two surfaces feel consistent. */
.t2d-sf-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  margin-top: 4px;
  border-top: 1px solid rgba(70,130,180,0.10);
  font-size: 10px;
  color: #555;
  line-height: 1;
}
.t2d-sf-pager-size { display: inline-flex; align-items: center; gap: 4px; }
.t2d-sf-pager-select {
  font-size: 10px;
  padding: 1px 4px;
  border: 1px solid rgba(70,130,180,0.25);
  border-radius: var(--radius-sm);
  background: #fff;
  color: #2c5171;
  cursor: pointer;
  line-height: 1.2;
}
.t2d-sf-pager-nav { display: inline-flex; align-items: center; gap: 4px; }
.t2d-sf-pager-prev, .t2d-sf-pager-next {
  background: rgba(70,130,180,0.10);
  color: #2c5171;
  border: none;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  transition: background 0.12s, opacity 0.12s;
}
.t2d-sf-pager-prev:hover:not(:disabled),
.t2d-sf-pager-next:hover:not(:disabled) {
  background: rgba(70,130,180,0.22);
}
.t2d-sf-pager-prev:disabled,
.t2d-sf-pager-next:disabled { opacity: 0.35; cursor: default; }
.t2d-sf-pager-page { font-weight: 600; min-width: 70px; text-align: center; }

/* CSV export button on companion tables — canonical pd-btn-icon, positioned
   top-right of the table wrapper. Replaces the old inline styles + JS hover
   (HIGH/MEDIUM audit 14/06). */
.pd-table-wrapper { position: relative; }
.pd-table-export-csv {
  position: absolute; right: 8px; top: 8px; z-index: 10;
  width: 24px; height: 24px; opacity: 0.85;
}
.pd-table-export-csv:hover { opacity: 1; }
