/* ── Folder Tree ── */

.folder-tree-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #000;
  overflow: hidden;
}

/* Breadcrumb bar */
.folder-tree-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #30363d);
  flex-shrink: 0;
  min-height: 44px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.folder-tree-breadcrumb::-webkit-scrollbar {
  display: none;
}

.folder-tree-breadcrumb-chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent, #58a6ff);
  font-size: 13px;
  font-family: 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  border: none;
  outline: none;
}

.folder-tree-breadcrumb-chip:active {
  background: rgba(88, 166, 255, 0.12);
}

.folder-tree-breadcrumb-chip.current {
  color: var(--text, #e6edf3);
  cursor: default;
  background: transparent;
}

.folder-tree-breadcrumb-sep {
  flex-shrink: 0;
  color: var(--text-dim, #484f58);
  font-size: 12px;
  padding: 0 2px;
  user-select: none;
}

/* Toolbar with search and toggle */
.folder-tree-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border, #30363d);
  flex-shrink: 0;
  min-height: 40px;
}

/* Search input */
.ft-search-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 0 8px;
  gap: 6px;
  color: var(--text-dim, #8b949e);
}

.ft-search-wrap:focus-within {
  border-color: var(--accent, #58a6ff);
}

.ft-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text, #e6edf3);
  font-size: 13px;
  font-family: 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
  padding: 6px 0;
  height: 32px;
}

.ft-search-input::placeholder {
  color: var(--text-dim, #484f58);
}

.ft-search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-dim, #8b949e);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.ft-search-clear:active {
  background: rgba(255, 255, 255, 0.08);
}

/* Search match highlight */
mark.ft-search-match {
  background: rgba(227, 179, 65, 0.3);
  color: #e3b341;
  border-radius: 2px;
  padding: 0 1px;
}

.folder-tree-toggle-hidden {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #30363d);
  background: transparent;
  color: var(--text-dim, #8b949e);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.folder-tree-toggle-hidden:active {
  background: rgba(255, 255, 255, 0.06);
}

.folder-tree-toggle-hidden.active {
  border-color: var(--accent, #58a6ff);
  color: var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.08);
}

/* Entry list */
.folder-tree-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
}

/* Single entry row */
.folder-tree-entry {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
  transition: background 0.1s;
}

.folder-tree-entry:active {
  background: rgba(255, 255, 255, 0.04);
}

.folder-tree-entry:focus-visible {
  outline: 2px solid var(--accent, #58a6ff);
  outline-offset: -2px;
}

/* Indent spacer */
.folder-tree-indent {
  flex-shrink: 0;
}

/* Type indicator */
.folder-tree-icon {
  flex-shrink: 0;
  width: 20px;
  font-size: 12px;
  color: var(--text-dim, #8b949e);
  text-align: center;
  margin-right: 8px;
  user-select: none;
}

.folder-tree-icon.dir {
  color: var(--accent, #58a6ff);
}

/* File/dir name */
.folder-tree-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-family: 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
  color: var(--text, #e6edf3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-tree-entry.is-dir .folder-tree-name {
  font-weight: 500;
}

/* Extension suffix */
.folder-tree-ext {
  flex-shrink: 0;
  font-size: 11px;
  font-family: 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
  color: var(--text-dim, #484f58);
  margin-left: 6px;
}

/* Size info (files only) */
.folder-tree-size {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim, #484f58);
  margin-left: 8px;
  white-space: nowrap;
}

/* Loading spinner for a directory */
.folder-tree-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--text-dim, #8b949e);
  font-size: 13px;
}

.folder-tree-loading .ft-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent, #58a6ff);
  border-radius: 50%;
  animation: ft-spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* Error state */
.folder-tree-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 24px;
  text-align: center;
  gap: 12px;
}

.folder-tree-error-icon {
  color: #f85149;
}

.folder-tree-error-msg {
  color: var(--text-dim, #8b949e);
  font-size: 14px;
  max-width: 320px;
  word-break: break-word;
}

.folder-tree-btn-retry {
  min-height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: transparent;
  color: var(--accent, #58a6ff);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.folder-tree-btn-retry:active {
  background: rgba(88, 166, 255, 0.1);
}

/* Empty dir state */
.folder-tree-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 8px;
}

.folder-tree-empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim, #8b949e);
}

.folder-tree-empty-sub {
  font-size: 12px;
  color: var(--text-dim, #484f58);
}

/* Load more button */
.folder-tree-load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--accent, #58a6ff);
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: none;
  background: transparent;
  width: 100%;
}

.folder-tree-load-more:active {
  background: rgba(88, 166, 255, 0.08);
}

/* Entry count */
.folder-tree-count {
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-dim, #484f58);
  text-align: right;
}

/* ── Action Bar (New File / New Folder) ── */

.ft-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border, #30363d);
  flex-shrink: 0;
}

.ft-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #30363d);
  background: transparent;
  color: var(--text-dim, #8b949e);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.ft-action-btn:active {
  background: rgba(255, 255, 255, 0.06);
}

.ft-action-btn span {
  color: var(--text-dim, #8b949e);
}

/* ── Inline Input (New File/Folder name) ── */

.ft-inline-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border, #30363d);
  background: rgba(88, 166, 255, 0.04);
}

.ft-inline-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--accent, #58a6ff);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #e6edf3);
  font-size: 13px;
  font-family: 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
  outline: none;
}

.ft-inline-input.error {
  border-color: #f85149;
}

.ft-inline-input::placeholder {
  color: var(--text-dim, #484f58);
}

.ft-inline-cancel {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim, #8b949e);
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.ft-inline-cancel:active {
  background: rgba(255, 255, 255, 0.06);
}

/* ── Overflow Menu (three-dot) ── */

.ft-overflow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border: none;
  background: transparent;
  color: var(--text-dim, #484f58);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.ft-overflow-btn:active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text, #e6edf3);
}

.ft-overflow-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  min-width: 120px;
  background: var(--surface, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  padding: 4px 0;
  overflow: hidden;
}

.ft-overflow-item {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: var(--text, #e6edf3);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ft-overflow-item:active {
  background: rgba(255, 255, 255, 0.06);
}

.ft-overflow-item.ft-overflow-delete {
  color: #f85149;
}

/* ── Rename Input ── */

.ft-rename-input {
  width: 100%;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--accent, #58a6ff);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #e6edf3);
  font-size: 13px;
  font-family: 'Menlo', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
  outline: none;
}

/* ── Delete Confirm Dialog ── */

.ft-confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.ft-confirm-card {
  background: var(--surface, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 12px;
  padding: 20px;
  max-width: 320px;
  width: 100%;
}

.ft-confirm-title {
  font-size: 15px;
  font-weight: 600;
  color: #f85149;
  margin-bottom: 8px;
}

.ft-confirm-msg {
  font-size: 13px;
  color: var(--text-dim, #8b949e);
  margin-bottom: 16px;
  line-height: 1.5;
  word-break: break-word;
}

.ft-confirm-actions {
  display: flex;
  gap: 8px;
}

.ft-confirm-btn {
  flex: 1;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ft-confirm-cancel {
  color: var(--text-dim, #8b949e);
}

.ft-confirm-cancel:active {
  background: rgba(255, 255, 255, 0.06);
}

.ft-confirm-delete {
  color: #f85149;
  border-color: #f85149 !important;
}

.ft-confirm-delete:active {
  background: rgba(248, 81, 73, 0.1);
}

/* ── Desktop Sidebar Mode ──────────────────────────────────── */
/* #ft-sidebar replaces #view-dashboard when browsing files on desktop */

.ft-sidebar {
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}

@media (min-width: 768px) {
  #app-layout > .ft-sidebar {
    flex: 0 0 var(--sidebar-width);
    min-width: 200px;
    max-width: 400px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
  }
}
