/* =========================================================
   Core layout (do NOT block scrolling)
   ========================================================= */

.filemanager-host {
    height: 100%;
    min-height: 0;
    min-width: 0;
    width: 100%;
}

.fm-root {
    height: 100%;
    min-height: 0;
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.fm-toolbar {
    flex: 0 0 auto;
    min-width: 0;
}

.fm-breadcrumbs {
    flex: 0 0 auto;
    margin-top: .5rem;
    margin-bottom: .5rem;

    white-space: nowrap;
    overflow-x: auto;
}

.fm-content {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;

    display: flex;
    flex-direction: column;
}

/* This is the vertical scroll container for LIST + ICON views */
.fm-main-scroll {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;

    overflow: auto; /* IMPORTANT */
}

/* =========================================================
   LIST view helpers (if you have wrappers)
   ========================================================= */

.fm-list {
    width: 100%;
}

.fm-list table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate; /* improves sticky header painting */
    border-spacing: 0;
}

/* ✅ Sticky headers (scoped to file manager only) */
.fm-list thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bs-body-bg);
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

/* =========================================================
   ICON view (Virtualize rows -> each row is a grid)
   ========================================================= */

.fm-icon-row {
    display: grid;
    grid-template-columns: repeat(var(--fm-icon-cols, 6), minmax(0, 1fr));
    gap: 12px;
    padding: 12px 0;
}

.fm-icon-item {
    position: relative;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    background: var(--bs-body-bg);

    height: 200px; /* keep in sync with IconRowHeight in component */
}

.fm-icon-main {
    width: 100%;
    height: 100%;
    padding: 10px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.fm-icon-main i {
    font-size: 80px;
    line-height: 1;
}

.fm-icon-thumb {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: .5rem;
}

.fm-icon-label {
    width: 100%;
    text-align: center;
    font-size: .9rem;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hover actions ONLY in icon view */
.fm-icon-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    gap: 4px;
    z-index: 2;
}

.fm-icon-item:hover .fm-icon-actions {
    display: flex;
}

.fm-icon-actions .btn {
    padding: 2px 6px;
    border: none;
    background: transparent;
    color: var(--bs-secondary);
}

.fm-icon-actions .btn:hover {
    color: var(--bs-body-color);
}

/* =========================================================
   COLUMNS view (horizontal scroller ONLY inside columns area)
   ========================================================= */

.fm-columns-host {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;

    display: flex;
    flex-direction: column;
}

.fm-columns-wrap {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;

    overflow-x: auto;   /* horizontal scroll lives here */
    overflow-y: hidden; /* no vertical scroll here */

    padding-top: 8px;   /* the margin/padding you wanted above columns */
    padding-bottom: 8px;
}

.fm-columns {
    height: 100%;
    display: inline-flex;
    align-items: stretch;
    gap: 0;
}

.fm-column {
    width: 25vw;        /* wider columns */
    min-width: 420px;
    max-width: 620px;

    height: 100%;
    border: 1px solid var(--bs-border-color);
    border-right: 0;
}

.fm-column:last-child {
    border-right: 1px solid var(--bs-border-color);
}

.fm-column-list {
    height: 100%;
    min-height: 0;
    overflow-y: auto;  /* vertical scroll per-column */
}

/* Actions ALWAYS visible in columns view */
.fm-column-actions {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* =========================================================
   SORT control (dropdown + direction button — clean join)
   ========================================================= */

.fm-sort-group {
    display: inline-flex;
}

/* Hard-reset border radius for both buttons, INCLUDING dropdown-toggle */
.fm-sort-group > .btn,
.fm-sort-group > .btn.dropdown-toggle {
    border-radius: 0 !important;
}

/* Left button gets left rounding only */
.fm-sort-group > .btn:first-child {
    border-top-left-radius: .375rem !important;
    border-bottom-left-radius: .375rem !important;
}

/* Right button gets right rounding only */
.fm-sort-group > .btn:last-child {
    border-top-right-radius: .375rem !important;
    border-bottom-right-radius: .375rem !important;
}

/* Remove seam spacing and double border between them */
.fm-sort-group > .btn + .btn {
    margin-left: 0 !important;
    border-left: 0 !important;
}

/* Column list items are selectable */
.fm-column-item {
    cursor: pointer;
}

/* Selected item (independent of the active folder chain) */
.fm-selected {
    outline: 2px solid rgba(13, 110, 253, .25);
    outline-offset: -2px;
}

/* Details column */
.fm-column.fm-details {
    width: 28vw;
    min-width: 460px;
    max-width: 720px;
    height: 100%;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}

.fm-details-body {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 14px;
    overflow: auto;
}

.fm-details-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
}

.fm-details-icon {
    font-size: 84px;
    line-height: 1;
    color: var(--bs-secondary);
}

.fm-details-thumb {
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--bs-border-color);
}

.fm-details-name {
    font-weight: 600;
    max-width: 100%;
}

.fm-details-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fm-details-row {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 10px;
    align-items: start;
}

.fm-details-label {
    font-size: .85rem;
    color: var(--bs-secondary);
}

.fm-details-value {
    min-width: 0;
}

.fm-details-code {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fm-details-actions {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Sticky header needs the nearest scrolling ancestor to be the vertical scroller.
   Bootstrap .table-responsive sets overflow-y:hidden which breaks sticky headers. */
.fm-list .table-responsive {
    overflow-y: visible !important;
}

/* Ensure header paints above rows */
.fm-list .table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bs-body-bg);
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

/* QuickGrid table layout + sticky header */
.fm-list .fm-quickgrid {
    width: 100%;
    table-layout: fixed;
}

.fm-list .fm-quickgrid thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bs-body-bg);
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

/* =========================================================
   LIST VIEW (QuickGrid virtualization stability)
   ========================================================= */

.fm-main-scroll {
    /* you already have this, keeping it explicit */
    overflow: auto;
}

/* Ensure QuickGrid table doesn’t “grow” wider/taller from content */
.fm-quickgrid {
    width: 100%;
    table-layout: fixed; /* critical: prevents reflow/jitter */
}

/* Sticky header */
.fm-quickgrid thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bs-body-bg);
}

/* Virtualize row-height MUST match ItemSize (44) */
.fm-quickgrid tbody tr {
    height: 44px;
}

/* Prevent content from changing row height */
.fm-quickgrid th,
.fm-quickgrid td {
    padding-top: .5rem;
    padding-bottom: .5rem;
    white-space: nowrap;         /* no wrapping */
    overflow: hidden;            /* clamp */
    text-overflow: ellipsis;     /* show … */
    vertical-align: middle;
}

/* Buttons inside cells should not introduce extra line-height */
.fm-quickgrid .btn,
.fm-quickgrid .btn-link {
    line-height: 1.1;
}

/* Keep icon sizing predictable */
.fm-quickgrid i {
    line-height: 1;
}