/* -----------------------------------------------------------------------
   File Lists – Front-end Styles
----------------------------------------------------------------------- */

/* Container wraps toolbar + list */
.fl-file-list-container {
    margin: 1.5em 0;
}

/* -----------------------------------------------------------------------
   Accordion header
----------------------------------------------------------------------- */
.fl-accordion-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    transition: background .18s;
    line-height: 1.3;
}

.fl-accordion-header:hover {
    background: #135e96;
}

.fl-accordion-header:focus-visible {
    outline: 3px solid #72aee6;
    outline-offset: 2px;
}

/* Folder icons */
.fl-folder-icon {
    flex-shrink: 0;
    opacity: .92;
}

.fl-accordion-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fl-accordion-count {
    font-size: 12px;
    font-weight: 500;
    opacity: .75;
    white-space: nowrap;
    background: rgba(255,255,255,.18);
    border-radius: 10px;
    padding: 2px 9px;
}

.fl-accordion-chevron {
    flex-shrink: 0;
    transition: transform .22s ease;
}

/* Collapsed state — header */
.fl-accordion-header[aria-expanded="false"] {
    border-radius: 6px;
}
.fl-accordion-header[aria-expanded="false"] .fl-accordion-chevron {
    transform: rotate(-90deg);
}

/* Collapsible body */
.fl-accordion-body {
    overflow: hidden;
    transition: max-height .28s ease, opacity .22s ease;
    max-height: 9999px; /* large enough for any list */
    opacity: 1;
}

.fl-accordion-body.fl-collapsed {
    max-height: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* When open, connect header to toolbar/list with no gap */
.fl-accordion-header[aria-expanded="true"] {
    border-radius: 6px 6px 0 0;
}
.fl-accordion-body .fl-toolbar {
    border-radius: 0; /* header takes the top radius */
}
.fl-accordion-body .fl-file-list-wrapper {
    border-radius: 0 0 6px 6px;
}
.fl-accordion-body .fl-filter-empty {
    border-radius: 0 0 6px 6px;
}

/* Edit-list link (visible to authorised users only) */
.fl-edit-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    font-size: 12px;
    color: #aaa;
    text-decoration: none;
    transition: color .15s;
}
.fl-edit-link:hover,
.fl-edit-link:focus {
    color: #2271b1;
    text-decoration: underline;
}

/* -----------------------------------------------------------------------
   Toolbar
----------------------------------------------------------------------- */
.fl-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f6f7f7;
    border: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    flex-wrap: wrap;
    min-height: 48px;
}

.fl-select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.fl-select-all-label input[type="checkbox"],
.fl-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #2271b1;
    flex-shrink: 0;
}

/* ZIP button */
.fl-zip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .18s, opacity .18s, transform .1s;
    line-height: 1.4;
    white-space: nowrap;
}

.fl-zip-btn:hover:not(:disabled) {
    background: #135e96;
}

.fl-zip-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.fl-zip-btn:disabled,
.fl-zip-btn[aria-disabled="true"] {
    opacity: .42;
    cursor: not-allowed;
    background: #2271b1;
}

.fl-zip-count {
    background: rgba(255,255,255,.25);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    display: none;
}
.fl-zip-count.fl-visible { display: inline-block; }

.fl-zip-status {
    font-size: 12px;
    color: #555;
    font-style: italic;
}
.fl-zip-status.fl-success { color: #276f48; font-style: normal; font-weight: 600; }
.fl-zip-status.fl-error   { color: #c00;    font-style: normal; }

/* -----------------------------------------------------------------------
   File list
----------------------------------------------------------------------- */
.fl-file-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    list-style: none;
    border: 1px solid #ddd;
    border-radius: 0 0 6px 6px;
    overflow: hidden;
}

/* Each file row */
.fl-item {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #ececec;
    background: #fff;
    transition: background .14s;
}
.fl-item:last-child { border-bottom: none; }
.fl-item:hover { background: #f8fafd; }
.fl-item.fl-checked { background: #eef4fb; }

/* Checkbox column */
.fl-check-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px 0 14px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Main link */
.fl-item-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px 12px 10px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
    transition: color .14s;
}

.fl-item-link:hover,
.fl-item-link:focus {
    color: inherit;
    text-decoration: none;
    outline: none;
}

/* Icon badge */
.fl-icon-wrap { flex-shrink: 0; }

.fl-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.3px;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* Image thumbnail */
.fl-item-link--image .fl-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
    display: block;
}

/* Text section */
.fl-item-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fl-item-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.3;
    color: #2271b1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.fl-item-link:hover .fl-item-title {
    text-decoration: underline;
}

/* Description */
.fl-item-desc {
    font-size: 12.5px;
    color: #555;
    line-height: 1.45;
    display: block;
    /* Allow wrapping — descriptions can be multi-line */
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.fl-item-info {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #aaa;
    align-items: center;
    margin-top: 1px;
}

.fl-item-ext {
    background: #f0f0f1;
    color: #666;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
}

/* Download arrow */
.fl-download-icon {
    flex-shrink: 0;
    color: #ccc;
    display: flex;
    align-items: center;
    transition: color .18s, transform .18s;
}

.fl-item-link:hover .fl-download-icon {
    color: #2271b1;
    transform: translateY(2px);
}

/* Error / empty states */
.fl-error { color: #c00; font-style: italic; }
.fl-empty { color: #888; font-style: italic; }

/* -----------------------------------------------------------------------
   Filter
----------------------------------------------------------------------- */
.fl-filter-wrap {
    display: flex;
    align-items: center;
    position: relative;
    flex: 1 1 180px;
    min-width: 120px;
    max-width: 320px;
}

.fl-filter-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.fl-filter-input {
    width: 100%;
    padding: 5px 28px 5px 30px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    color: #333;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
    -webkit-appearance: none;
    appearance: none;
}
/* Hide browser's native clear button — we have our own */
.fl-filter-input::-webkit-search-cancel-button { display: none; }

.fl-filter-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,.15);
}

.fl-filter-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
    padding: 0 2px;
    transition: color .15s;
}
.fl-filter-clear:hover { color: #555; }

/* Filter highlight */
mark.fl-highlight {
    background: #fff176;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* No-results message — hidden by default, shown by JS */
.fl-filter-empty {
    display: none;
    padding: 14px 16px;
    font-size: 13px;
    color: #888;
    font-style: italic;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    background: #fafafa;
    margin: 0;
}

/* Divider between filter wrap and select-all */
.fl-toolbar-divider {
    width: 1px;
    height: 22px;
    background: #ddd;
    flex-shrink: 0;
}

/* -----------------------------------------------------------------------
   Responsive
----------------------------------------------------------------------- */
@media (max-width: 520px) {
    .fl-item-link {
        padding: 10px 10px 10px 8px;
        gap: 10px;
    }
    .fl-icon { width: 38px; height: 38px; }
    .fl-item-link--image .fl-thumb { width: 44px; height: 44px; }
    .fl-download-icon { display: none; }
    .fl-toolbar { gap: 8px; }
    .fl-zip-btn { font-size: 12px; padding: 5px 10px; }
}

/* -----------------------------------------------------------------------
   Front-end – Folder rows
----------------------------------------------------------------------- */
.fl-folder {
    border-bottom: 1px solid #e8eaec;
}
.fl-folder:last-child { border-bottom: none; }

/* Folder toggle button */
.fl-folder-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: #f0f6fc;
    border: none;
    border-bottom: 1px solid #e2e4e7;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: #1d2327;
    text-align: left;
    transition: background .15s;
}
.fl-folder-btn:hover { background: #e5f0fb; }
.fl-folder-btn:focus-visible { outline: 2px solid #2271b1; outline-offset: -2px; }

.fl-fld-icon { flex-shrink: 0; color: #f9a825; }

.fl-folder-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fl-folder-badge {
    font-size: 11px;
    font-weight: 500;
    color: #888;
    background: #e8eaec;
    border-radius: 10px;
    padding: 1px 8px;
    white-space: nowrap;
}

.fl-folder-chevron {
    flex-shrink: 0;
    color: #aaa;
    transition: transform .2s ease;
}
.fl-folder-btn[aria-expanded="false"] .fl-folder-chevron {
    transform: rotate(-90deg);
}

/* Folder body */
.fl-folder-body {
    overflow: hidden;
    transition: max-height .25s ease, opacity .2s ease;
    max-height: 9999px;
    opacity: 1;
}
.fl-folder-body--collapsed {
    max-height: 0 !important;
    opacity: 0;
    pointer-events: none;
}

/* Indented file rows inside folders */
.fl-folder-body .fl-item {
    padding-left: 24px;
    background: #fafcff;
}
.fl-folder-body .fl-item:hover { background: #f0f6fc; }
.fl-folder-body .fl-item.fl-checked { background: #e5eef8; }

/* Empty folder */
.fl-folder-empty {
    padding: 12px 20px;
    font-size: 12.5px;
    color: #aaa;
    font-style: italic;
}
