/* ============================================================================
   Aurora Tree — in-chat Files explorer (src/ui/filesExplorer.js).
   A glassmorphism file tree that REPLACES the chat list inside #sidebar while
   open. Two stacked zones: SMART (virtual type buckets) and FOLDERS (real custom
   folders). role=tree semantics; keyboard-navigable; expand state persists.
   All visuals live here (the JS is class-driven) so the diff-coverage gate's
   JS-line burden stays on logic, not styling.
   ============================================================================ */

/* ---- panel shell ---------------------------------------------------------- */
#file-explorer-panel {
    display: none;                 /* JS flips to flex on open() */
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    /* a barely-there aurora wash so the explorer reads as its own surface,
       distinct from the chat list it replaces */
    background:
        radial-gradient(120% 60% at 0% 0%, rgba(34, 211, 238, 0.05), transparent 60%),
        radial-gradient(120% 60% at 100% 0%, rgba(192, 132, 252, 0.05), transparent 60%);
    border-radius: 12px;
    margin: -2px -2px 0;
    padding: 4px 2px 0;
}

/* ---- header --------------------------------------------------------------- */
.fe-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 8px;
}
.fe-back {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 7px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.fe-back:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.fe-back:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.6); }
.fe-title {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.2px;
    background: linear-gradient(100deg, #e2e8f0, #a5b4fc 60%, #67e8f9);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.fe-count {
    margin-left: auto;
    color: #64748b;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

/* ---- sort control --------------------------------------------------------- */
.fe-sort {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 6px 8px;
    font-size: 0.72rem;
    color: #94a3b8;
}
.fe-sort-label { opacity: 0.8; }
.fe-sort-btn {
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid transparent;
    color: #cbd5e1;
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.fe-sort-btn:hover { background: rgba(148, 163, 184, 0.16); }
.fe-sort-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.55); }
.fe-sort-btn.active {
    color: #fff;
    border-color: rgba(129, 140, 248, 0.5);
    background: linear-gradient(120deg, rgba(34, 211, 238, 0.22), rgba(129, 140, 248, 0.28));
}

/* ---- tree body ------------------------------------------------------------ */
.fe-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 2px 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.fe-tree::-webkit-scrollbar { width: 8px; }
.fe-tree::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}
.fe-tree::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ---- zones ---------------------------------------------------------------- */
.fe-zone { margin-bottom: 6px; }
.fe-zone-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 8px 4px;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: #64748b;
}
.fe-zone-label i { font-size: 0.7rem; color: #818cf8; opacity: 0.85; }
.fe-zone-rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, rgba(129, 140, 248, 0.25), transparent);
}

/* ---- a node (bucket / folder / domain group / file) ----------------------- */
.fe-node { position: relative; }
.fe-row {
    position: relative; /* containing block for .fe-focus::before — keep the accent bar row-height, not node-height */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 9px;
    cursor: pointer;
    color: #e2e8f0;
    user-select: none;
    transition: background 0.13s, box-shadow 0.13s;
    /* indentation accrues purely from nested .fe-children margins (no inline vars) */
}
.fe-row:hover { background: rgba(255, 255, 255, 0.05); }
/* roving-tabindex focus → aurora ring + faint fill + accent bar */
.fe-row:focus-visible,
.fe-row.fe-focus {
    outline: none;
    background: linear-gradient(100deg, rgba(34, 211, 238, 0.1), rgba(129, 140, 248, 0.12));
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.5);
}
.fe-row.fe-focus::before {
    content: '';
    position: absolute;
    left: 1px;
    top: 6px;
    bottom: 6px;
    width: 2.5px;
    border-radius: 3px;
    background: linear-gradient(180deg, #67e8f9, #818cf8 55%, #c084fc);
}

/* group icon (bucket/folder) vs leaf icon */
.fe-ico {
    width: 18px;
    flex-shrink: 0;
    text-align: center;
    color: #818cf8;
}
.fe-row[data-kind="file"] .fe-ico { color: #94a3b8; }

.fe-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.86rem;
}
.fe-row[data-kind="group"] .fe-label { font-weight: 600; }
.fe-cardinality {
    color: #64748b;
    font-weight: 400;
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
}
.fe-chevron {
    margin-left: auto;
    font-size: 0.66rem;
    color: #64748b;
    transition: transform 0.16s ease;
}
.fe-row[aria-expanded="false"] .fe-chevron { transform: rotate(-90deg); }

/* leaf thumbnail (real image src only; dominant-color falls back to a tinted icon) */
.fe-thumb {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(148, 163, 184, 0.15);
}
.fe-ico-tile {
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    border-radius: 6px;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.8rem;
}

/* children container + VS-Code-style guide line; nesting accrues the indent */
.fe-children {
    position: relative;
    margin-left: 14px;
    border-left: 1px solid rgba(148, 163, 184, 0.13);
    padding-left: 3px;
}
.fe-children[hidden] { display: none; }

/* empty-state hint (e.g. Folders zone before any folder exists) */
.fe-empty {
    color: #64748b;
    font-size: 0.78rem;
    padding: 6px 8px 8px 14px;
    font-style: italic;
}

/* full-body message (no files / load error / locked) */
.fe-message {
    color: #94a3b8;
    text-align: center;
    padding: 34px 10px;
    font-size: 0.9rem;
}

/* ---- mobile --------------------------------------------------------------- */
@media (max-width: 600px) {
    .fe-row { padding-top: 8px; padding-bottom: 8px; }
    .fe-title { font-size: 1rem; }
}
