/* Files Panel */
.files-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background: var(--surface);
  box-shadow: calc(var(--padding-xs) * -1) 0 24px var(--overlay-soft);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.files-panel:not(.hidden) {
  transform: translateX(0);
}

.files-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.files-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.files-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  transition: background .15s ease;
  cursor: pointer;
}

.file-item:hover {
  background: transparent;
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.file-status.processing { color: #f59e0b; }
.file-status.ready { color: #10b981; }
.file-status.error { color: var(--danger); }

/* DOCS mode button styling to match Files tab */
.docs-mode-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(var(--padding-xs));
  -webkit-backdrop-filter: blur(var(--padding-xs));
  display: grid;
  place-items: center;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.docs-mode-container:not(.hidden) {
  visibility: visible;
  opacity: 1;
}

.docs-mode-panel {
  width: min(800px, 94vw);
  height: min(700px, 92vh);
  background: var(--glass-surface-98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.25);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.docs-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--overlay-soft);
  background: var(--glass-surface-90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.docs-mode-header h3 {
  font-weight: 600;
  font-size: 18px;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.3px;
}

.docs-mode-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  overflow: hidden;
}

.docs-mode-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.docs-mode-search {
  flex: 1;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--overlay);
  border-radius: 12px;
  background: var(--glass-surface-80);
  font: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}

.docs-mode-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: white;
}

.docs-mode-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg);
  border-radius: 18px;
  border: 1px solid var(--overlay-soft);
}

.docs-mode-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  position: relative;
  min-height: 120px;
  justify-content: center;
  background: var(--glass-surface-80);
}

.docs-mode-item:hover {
  background: var(--glass-surface-95);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.docs-mode-item.selected {
  background: var(--state-info-soft);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 var(--padding-xs) rgba(59, 130, 246, 0.2);
}

.docs-mode-item-icon {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(var(--padding-xs));
  -webkit-backdrop-filter: blur(var(--padding-xs));
}

.docs-mode-item-name {
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  color: var(--text);
  line-height: 1.35;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.docs-mode-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--overlay-strong);
  border-radius: var(--padding-xs);
  background: var(--glass-surface-90);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.docs-mode-item.selected .docs-mode-checkbox {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.docs-mode-checkbox svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.docs-mode-item.selected .docs-mode-checkbox svg {
  opacity: 1;
}

.docs-mode-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--overlay-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.docs-mode-count {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

.docs-mode-actions {
  display: flex;
  gap: 12px;
}

.docs-mode-footer .docs-mode-btn {
  height: 40px;
  padding: 0 20px;
  padding-right: 2px;
  border: 1px solid var(--overlay);
  border-radius: 10px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.docs-mode-footer .docs-mode-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.25);
}

.docs-mode-footer .docs-mode-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.docs-mode-footer .docs-mode-btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 85%, black);
  border-color: color-mix(in srgb, var(--accent) 85%, black);
}


/* Files view */
.files-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  box-sizing: border-box;
  background: var(--surface);
  flex: 1;
  z-index: 1;
  border-radius: var(--radius-xl);
  padding: var(--padding-xs);
}

/* Files toolbar - fixed at top with same transition model as universal container */
#files-toolbar-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: transparent;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(.2,.7,.2,1);
}

/* Visible state */
#files-toolbar-container:not(.hidden) {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

/* Keep toolbar in flow for transitions even with global `.hidden { display:none !important; }` */
#files-toolbar-container.hidden {
  display: block !important;
}

/* Compensate main-content top shift in files mode so toolbar stays visually higher */
.main-content.files-mode > #files-toolbar-container {
  top: -46px;
}

.files-toolbar-left .files-open-menu {
  display: none;
  color: #0f172a;
}

@media (max-width: 768px) {
  .files-toolbar-left .files-open-menu {
    display: inline-flex;
  }
}

@media (min-width: 769px) {
  .files-toolbar-left .files-open-menu {
    display: none !important;
  }
}



.files-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  margin: 5px 0;
  min-height: var(--control-height);
}

@media (max-width: 768px) {
  .files-toolbar {
    margin: 5px 0;
  }
}

.files-toolbar-left,
.inline-doc-nav-buttons {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.files-toolbar-left .btn-icon,
.folder-back-btn,
.folder-forward-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-xl);
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.files-toolbar-left .btn-icon:hover:not(:disabled),
.folder-back-btn:hover:not(:disabled),
.folder-forward-btn:hover:not(:disabled) {
  background: var(--state-hover-soft);
  border-radius: var(--radius-xl);
}

.files-toolbar-left .btn-icon:disabled,
.folder-back-btn:disabled,
.folder-forward-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.files-toolbar-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.files-toolbar-right .btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.files-toolbar-right .btn-secondary:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
}

.files-toolbar-right .btn-secondary:active {
  background: var(--active_transparent_btns);
}

.files-toolbar-right #upload-btn svg {
  width: 18px;
  height: 18px;
}

.files-toolbar-right #new-folder-btn svg {
  width: 18px;
  height: 18px;
}

.files-toolbar-right #new-folder-btn span,
.files-toolbar-right #upload-btn span {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}




.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 120px);
  gap: 1px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding-bottom: 120px;
  align-content: flex-start;
  justify-content: start;
  background: transparent;
  box-sizing: border-box;
  position: relative;
}

.files-grid.loading {
  min-height: 240px;
}

.files-grid.loading::before {
  content: 'Loading...';
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* When grid has empty state, switch to flex and center it */
.files-grid:has(.empty-state) {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0;
  height: 100%;
  min-height: 100%;
}

/* If :has() is not supported, use this fallback */
.files-grid.empty {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0;
  height: 100%;
  min-height: 100%;
}


.file-item, .folder-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  align-self: start;
  gap: 2px;
  padding: 10px 0 var(--padding-xs);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
  position: relative;
  width: 120px;
  min-height: 120px;
  height: auto;
  background: transparent;
  box-sizing: border-box;
  outline: none;
  overflow: hidden;
}

.file-item.corner-top-left,
.folder-item.corner-top-left {
  border-top-left-radius: 18px;
}

.file-item.corner-top-right,
.folder-item.corner-top-right {
  border-top-right-radius: 18px;
}

.file-item:hover:not(.selected), .folder-item:hover:not(.selected) {
  background: var(--file-item-hover);
}


.file-item:focus, .file-item:focus-visible, .folder-item:focus, .folder-item:focus-visible {
  outline: none;
}

.file-item.dragging, .folder-item.dragging {
  opacity: 0.5;
}

.folder-item.drop-target,
.add-item.drop-target {
  background: rgba(59, 130, 246, 0.15);
}

.file-item.selected, .folder-item.selected {
  background: var(--hover_transparent_btns);
  border: 1px solid var(--accent-300);
}

/* Keep selected state on hover - no border change */
.file-item.selected:hover, .folder-item.selected:hover {
  background: var(--file-item-active);
  border: 1px solid var(--accent-300);
}

.add-item {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
}

.add-item:hover,
.add-item:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59,130,246,0.12);
}

.add-item .item-name {
  margin-top: 6px;
  font-weight: 500;
}

.add-item svg {
  color: currentColor;
}

.item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  margin-bottom: 0;
  position: relative;
  flex-shrink: 0;
}

.item-icon span {
  font-size: 100px;
  line-height: 1;
  user-select: none;
  display: block;
}

.item-icon svg:not(.shared-badge) {
  width: 100px;
  height: 100px;
}

.file-cover {
  width: 100%;
  height: 100px;
  position: relative;
  overflow: hidden;
  background: transparent;
  border-radius: 5px;
  box-shadow: 0 0 6px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
}

.file-cover::before,
.file-cover::after {
  content: none !important;
}

.file-cover-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
  transition: opacity 0.25s ease;
}

.file-cover-placeholder svg {
  width: 100px;
  height: 100px;
  max-width: 100%;
  max-height: 100%;
  opacity: 0.45;
}

.file-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.file-cover.loaded .file-cover-img {
  opacity: 1;
}

.file-cover.loaded .file-cover-placeholder {
  opacity: 0;
}


.file-cover.cover-error {
  background: var(--surface);
}

.item-icon.loading .file-cover:not(.loaded) {
  filter: grayscale(0.35) brightness(0.9);
}

.item-icon.loading span {
  filter: brightness(0.4);
  transition: filter 0.3s ease;
}

/* Circular progress overlay (synced with test-status-animation.html) */
.circular-progress {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 110px;
  pointer-events: none;
  z-index: 5;
}

.circular-progress svg {
  width: 100%;
  height: 100%;
}

/* Hide item-level circular loader overlays */
.file-item .circular-progress,
.folder-item .circular-progress {
  display: none !important;
}

/* Depth indicator badge */
.folder-item[data-depth]::before {
  content: attr(data-depth);
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--state-info-soft);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

/* Hide depth indicator for root level */
.folder-item[data-depth="0"]::before,
.folder-item:not([data-depth])::before {
  display: none;
}

/* Max depth warning styling */
.folder-item.max-depth {
  opacity: 0.6;
  cursor: not-allowed;
}

.folder-item.max-depth .folder-icon {
  color: var(--text-muted);
}

.folder-item.max-depth::after {
  content: '⚠';
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  background: var(--state-danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 50%;
  font-size: 12px;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* File icons now use emoji, no color styling needed */

/* React FileItem component styles */
.file-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  margin-bottom: var(--padding-xs);
  position: relative;
  flex-shrink: 0;
}

.file-item-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--padding-xs);
  align-items: center;
}

.file-item-name {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  color: var(--text);
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
  display: block;
  width: 100%;
  padding: 0 8px;
  z-index: 10;
  position: relative;
}

.file-item-meta {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  display: flex;
  align-items: center;
  gap: var(--padding-xs);
  flex-wrap: wrap;
  justify-content: center;
}

.file-item-meta .separator {
  opacity: 0.5;
}

.status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--padding-xs);
  font-weight: 500;
  text-transform: capitalize;
}

.status-badge.status-uploading {
  background: var(--state-info-soft);
  color: #2563eb;
}

.status-badge.status-ocr_queued,
.status-badge.status-vectorization_queued {
  background: rgba(156, 163, 175, 0.1);
  color: var(--text-muted);
}

.status-badge.status-ocr_processing {
  background: var(--state-warning-soft);
  color: #d97706;
}

.status-badge.status-vectorization_processing {
  background: rgba(139, 92, 246, 0.1);
  color: #7c3aed;
}

.status-badge.status-error,
.status-badge.status-cancelled {
  background: var(--state-danger-soft);
  color: var(--danger);
}

.file-item-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
}

.file-item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  display: flex;
  gap: var(--padding-xs);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.file-item:hover .file-item-actions,
.folder-item:hover .file-item-actions {
  opacity: 1;
}

.action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: var(--glass-surface-90);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  padding: 0;
}

.action-btn:hover {
  background: var(--state-hover-soft);
}

.action-btn.danger:hover {
  background: var(--state-danger-bg);
  color: var(--danger);
}

/* Item styles (unified for files and folders) */
.item-name {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  color: #333;
  width: 100%;
  padding: 0;
  margin-bottom: 0;
  margin-top: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  position: relative;
  z-index: 10;
  opacity: 1;
  visibility: visible;
  line-height: 1.3;
}

.item-status {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
  max-height: 40px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: normal;
  line-height: 1.1;
  direction: ltr;
}

.item-status.ready {
  color: #059669;
}

.item-status.processing {
  color: #d97706;
}

.item-status.error {
  color: var(--danger);
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: var(--padding-xs);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 0;  /* Remove gap after name */
  width: 100%;
  flex-shrink: 0;
}

.file-size {
  font-weight: 500;
}

.file-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 9999px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  font-family: var(--font-default);
}

.file-status.uploaded {
  background: var(--state-info-soft);
  color: #2563eb;
}

.file-status.processing {
  background: var(--state-warning-soft);
  color: #d97706;
}

.file-status.ready {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.file-status.error {
  background: var(--state-danger-soft);
  color: var(--danger);
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: var(--padding-xs);
  z-index: 1000;
  min-width: 120px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(calc(var(--padding-xs) * -1));
  transition: opacity 0.12s ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.context-menu.context-menu--visible {
  background: var(--glass-surface-70);
  opacity: 1;
  transform: translateY(0);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: chat-menu-fade 0.12s ease-out;
}

.context-menu-item {
  padding: 8px 12px;
  height: var(--control-height);
  font-size: 14px;
  line-height: 1.2;
  font-family: var(--font-default);
  color: var(--text);
  cursor: pointer;
  display: grid;
  grid-template-columns: 22px 1fr;
  column-gap: 7px;
  align-items: center;
  border-radius: 18px;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.1s ease, backdrop-filter 0.15s ease;
}

.context-menu-item:hover {
  background: var(--hover_transparent_btns);
  color: var(--text);
}

.context-menu-item:active {
  background: var(--active_transparent_btns);
  opacity: 0.6;
}

.context-menu-item svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
}

/* Larger icons for New Folder and Upload actions */
.context-menu-item[data-action="new-folder"] svg,
.context-menu-item[data-action="upload"] svg {
  width: 21px !important;
  height: 21px !important;
}


.context-menu-item.danger {
  color: var(--danger);
  white-space: nowrap;
}

.context-menu-item.danger:hover {
  background: var(--state-danger-bg);
}

/* Context Menu Color Picker */
.context-menu-color-picker {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 7px;
  padding: 9px;
  justify-content: start;
}

.context-menu-color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-sizing: border-box;
}

.context-menu-color-swatch:hover {
  filter: brightness(0.88);
}

.context-menu-color-swatch.active {
  box-shadow: none;
}

/* Folder colors — set via CSS custom properties on the SVG */
.folder-item[data-folder-color="darkblue"] .item-icon {
  --fc-back: #2C73D0; --fc-front: #3477DE;
}
.folder-item[data-folder-color="red"] .item-icon {
  --fc-back: #C33F3E; --fc-front: #DA3D36;
}
.folder-item[data-folder-color="yellow"] .item-icon {
  --fc-back: #EDAB06; --fc-front: #F9B812;
}
.folder-item[data-folder-color="green"] .item-icon {
  --fc-back: #5DB45E; --fc-front: #5DB45E;
}
.folder-item[data-folder-color="purple"] .item-icon {
  --fc-back: #9C33AF; --fc-front: #B33BCF;
}
.folder-item[data-folder-color="brown"] .item-icon {
  --fc-back: #BF712D; --fc-front: #D8843C;
}
.folder-item[data-folder-color="gray"] .item-icon {
  --fc-back: #69686C; --fc-front: #86858A;
}

/* Shared folder badge */
.folder-item .item-icon {
  position: relative;
}
.shared-badge {
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 32px;
  pointer-events: none;
  filter: brightness(0.82);
}

/* Empty state */
.empty-state {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  color: var(--text-muted);
  text-align: center;
  gap: 20px;
  cursor: pointer;
  border-radius: 18px;
  transition: all 0.2s ease;
  background: white;
  border: 2px dashed var(--border);
  margin: 0;
  box-sizing: border-box;
  pointer-events: auto;
}

.empty-state:hover,
.files-grid.empty:hover .empty-state {
  background: rgba(0,0,0,.04);
  border-color: var(--state-hover-strong);
}

.files-grid.dragover .empty-state {
  background: rgba(0,0,0,.04);
  border-color: var(--state-hover-strong);
}

.empty-state * {
  pointer-events: auto;
}

.empty-state .empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  border-radius: 30px;
  background: transparent;
  color: #9ca3af;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.empty-state .empty-icon svg {
  width: 120px;
  height: 120px;
  fill: currentColor;
}


.empty-state h3 {
  font-size: 28px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.5px;
  color: #374151;
  font-family: var(--font-heading);
}

.empty-state p {
  font-size: 15px;
  margin: 0;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}



/* Document Statistics Tooltip */
.doc-stats-tooltip {
  position: absolute;
  background: var(--glass-surface-70);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  border-radius: var(--radius-xl);
  padding: 10px 12px;
  z-index: 10000;
  opacity: 0;
  transform: translateY(var(--padding-xs));
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
  min-width: 200px;
  max-width: 220px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  white-space: normal;
  word-wrap: break-word;
}

.doc-stats-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.doc-stats-tooltip h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--padding-xs);
  font-family: var(--font-default);
  letter-spacing: -0.01em;
}

.doc-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--padding-xs) 0;
  gap: 12px;
  min-height: 18px;
}

.doc-stats-label {
  color: var(--muted);
  font-size: inherit;
  flex-shrink: 0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.doc-stats-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 120px;
  white-space: normal;
  font-size: inherit;
}

.doc-stats-value.highlight {
  color: var(--accent);
}

.doc-stats-value.success {
  color: #10b981;
}

.doc-stats-value.info {
  color: var(--info);
}

.doc-stats-value.warning {
  color: #f59e0b;
}

.doc-stats-languages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--padding-xs);
  justify-content: flex-end;
}

.doc-stats-lang-tag {
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--padding-xs);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.doc-stats-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.doc-stats-no-data {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 8px 0;
  font-size: 11px;
}

.doc-stats-icon {
  display: inline-block;
  margin-right: var(--padding-xs);
  opacity: 0.8;
}





/* Progress bar styles for real-time file statuses */
.file-progress {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.progress-bar-container {
  flex: 1;
  height: var(--padding-xs);
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.3s ease;
  border-radius: 2px;
  position: relative;
}

.progress-text {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  min-width: 32px;
  text-align: right;
}

/* Animation for active processes */
.file-item.processing .progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg,
    transparent,
    var(--glass-border),
    transparent
  );
  animation: progress-shimmer 1.5s ease-in-out infinite;
}

@keyframes progress-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Status colors */
.item-status.processing {
  color: var(--accent);
}

.item-status.ocr_processing {
  color: #f59e0b;
}

.item-status.vectorizing {
  color: #8b5cf6;
}

.item-status.ready {
  color: var(--success);
}

.item-status.error,
.item-status.ocr_failed,
.item-status.vectorization_failed,
.item-status.failed {
  color: var(--danger) !important;
  background: none !important;
  -webkit-text-fill-color: var(--danger) !important;
  animation: none !important;
}

/* Left-to-right shimmer animation for in-progress statuses (text only) */
/* Synced with: src/ailegalesearch/services/status_manager.py:163-171 (PROCESSING_STATUSES) */
.item-status.uploaded,
.item-status.pending,
.item-status.processing,
.item-status.ocr_queued,
.item-status.ocr_processing,
.item-status.vectorization_queued,
.item-status.vectorizing,
.item-status.reprocessing {
  position: relative;
  display: inline-block;
  background: linear-gradient(90deg,
    var(--muted) 0%,
    var(--muted) 25%,
    var(--surface) 50%,
    var(--muted) 75%,
    var(--muted) 100%
  );
  background-size: 300% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-text 2.5s linear infinite;
}

/* Intermediate completed states (no shimmer, static text) */
.item-status.ocr_completed,
.item-status.vectorization_completed {
  color: var(--muted);
}

@keyframes shimmer-text {
  0% {
    background-position: 300% 0;
  }
  100% {
    background-position: 0% 0;
  }
}

/* No external spinner - using iOS-style progress indicator inside icon */



/* Selection rectangle for drag-to-select */
.selection-rectangle {
  position: fixed;
  border: 1px solid var(--accent-300);
  background: var(--file-item-active);
  pointer-events: none;
  z-index: 1000;
  border-radius: var(--padding-xs);
  transition: opacity 0.1s ease;
}

/* User-select none during drag operations */
.files-grid.selecting {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Dragging state for selected items */
.file-item.dragging, .folder-item.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  transition: opacity 0.2s ease, transform 0.2s ease;
  position: relative;
}

/* Flying icons animation */
.flying-icon {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  will-change: transform, opacity, left, top;
  animation: iconGlow 0.4s ease-in-out;
}

.flying-icon span {
  display: inline-block;
  font-size: inherit;
  line-height: 1;
}

@keyframes iconGlow {
  0%, 100% {
    filter: drop-shadow(0 var(--padding-xs) 12px var(--overlay-strong));
  }
  50% {
    filter: drop-shadow(0 6px 20px rgba(59, 130, 246, 0.6));
  }
}

/* Drag stack styling (macOS-style) */
.drag-stack {
  cursor: grabbing !important;
  filter: drop-shadow(0 8px 24px var(--overlay-strong));
}

/* Card float animation */
@keyframes dragCardFloat {
  0% {
    transform: rotate(0deg) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

/* Badge pop animation */
@keyframes badgePop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Visual feedback when dragging over drop targets */
.folder-item.drop-target {
  background: rgba(59, 130, 246, 0.15) !important;
  border-color: var(--info) !important;
}

.add-item.drop-target {
  background: rgba(59, 130, 246, 0.15) !important;
  border-color: var(--info) !important;
}
}

/* ========================================
   Shared with me section
   ======================================== */

.shared-with-me-header {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary, #8b8fa8);
  padding: 16px 4px 4px;
  margin-top: 8px;
  border-top: 1px solid var(--border, rgba(0,0,0,0.08));
}

.shared-by-group {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  padding: 8px 4px 2px;
}

.shared-readonly-folder {
  opacity: 0.9;
}

/* ========================================
   Share folder modal
   ======================================== */

.modal-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  background: var(--glass-surface-70);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  animation: chat-menu-fade 0.12s ease-out;
  width: 320px;
  max-width: 92vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog * {
  font-size: 14px !important;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

#share-folder-modal .modal-header {
  align-items: flex-start;
  border-bottom: none;
  background: none;
  padding: var(--padding-xs) var(--padding-xs) 12px 20px;
}

#share-folder-modal .modal-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#share-folder-modal .share-modal-subtitle {
  margin: 0;
  font-size: 12px !important;
  color: var(--muted);
  line-height: 1.3;
}

#share-folder-modal .modal-footer {
  border-top: none;
  background: none;
  padding-top: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.modal-close:hover {
  background: var(--state-hover-soft);
  color: var(--text-strong);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--padding-xs);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 5px;
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  align-self: center;
  height: 35px;
  padding: 0 16px;
  border-radius: var(--radius-xl);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.1s ease;
}

.modal-footer .btn-primary {
  background: var(--file-item-active);
  color: var(--file-item-active-text);
  border: 1px solid transparent;
  box-shadow: none;
}

.modal-footer .btn-primary:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: var(--file-item-active-text);
  box-shadow: none;
}

.modal-footer .btn-primary:active {
  background: var(--active_transparent_btns);
  border-color: transparent;
  color: var(--file-item-active-text);
  opacity: 0.85;
  transform: none;
  box-shadow: none;
  filter: none;
}

.modal-footer .btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.modal-footer .btn-secondary:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: var(--text);
}

.modal-footer .btn-secondary:active {
  background: var(--active_transparent_btns);
  border-color: transparent;
  color: var(--text);
  opacity: 0.85;
}

.share-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  height: var(--control-height);
  font-size: 14px;
  line-height: 1.2;
  font-family: var(--font-default);
  color: var(--text);
  cursor: pointer;
  border-radius: 18px;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.1s ease;
}

.share-member-row:hover {
  background: var(--hover_transparent_btns);
  color: var(--text);
}

.share-member-row:active {
  background: var(--active_transparent_btns);
  opacity: 0.6;
}

.share-member-cb {
  flex-shrink: 0;
  position: relative;
  width: 22px;
  height: 22px;
  cursor: pointer;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--overlay);
  background: transparent;
}

.share-member-cb:checked {
  background: var(--accent-300);
  border: none;
}

.share-member-cb:checked::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 9px;
  background-color: var(--surface);
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'><path d='M1 5L5 9L13 1' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none'><path d='M1 5L5 9L13 1' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transform: translate(-50%, -50%);
}

.share-member-label {
  flex: 1;
  font-size: 16px;
  color: var(--text-primary, #111);
}

.share-member-role {
  font-size: 11px;
  color: var(--text-tertiary, #8b8fa8);
  text-transform: capitalize;
}

.share-modal-empty,
.share-modal-loading {
  font-size: 14px;
  color: var(--text-secondary, #6b7280);
  padding: 12px 0;
}

.share-modal-error {
  font-size: 14px;
  color: var(--danger, #ef4444);
  padding: 6px 0;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border, rgba(0,0,0,0.15));
  border-radius: var(--radius-sm, 6px);
  padding: 7px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-primary, #111);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.1s ease, filter 0.1s ease;
}

.btn-secondary:hover {
  background: var(--hover_transparent_btns);
  border-color: transparent;
  color: var(--text);
}

.btn-secondary:active {
  background: var(--active_transparent_btns);
  border-color: var(--border-strong);
  color: var(--text);
  opacity: 0.85;
}

/* ========================================
   OCR Mode Selection Modal (moved to ocr-modal.html)
   ======================================== */
