/* Nextcloud File Share - Frontend Styles
 *
 * Optik folgt dem SVC-Theme (svc-theme/style.css). Die --nfs-* Variablen
 * greifen auf die Theme-Tokens zurück und haben Fallbacks, damit die Liste
 * auch ohne Theme (z. B. im Embed-iframe) gleich aussieht.
 */

.nfs-container {
    --nfs-accent: var(--c-red-600, #B91C1C);
    --nfs-accent-hover: var(--c-red-500, #DC2626);
    --nfs-accent-strong: var(--c-red-700, #991B1B);
    --nfs-accent-soft: var(--c-red-50, #FEF2F2);
    --nfs-accent-ring: rgba(185, 28, 28, 0.2);
    --nfs-text: var(--c-gray-800, #1F2937);
    --nfs-text-muted: var(--c-gray-500, #6B7280);
    --nfs-border: var(--c-gray-200, #E5E7EB);
    --nfs-border-strong: var(--c-gray-300, #D1D5DB);
    --nfs-surface: var(--c-white, #FFFFFF);
    --nfs-surface-alt: var(--c-gray-50, #F9FAFB);
    --nfs-radius: var(--radius-md, 12px);
    --nfs-radius-sm: var(--radius-sm, 8px);
    --nfs-btn-radius: 10px;
    --nfs-shadow: var(--shadow-card, 0 1px 3px rgba(0,0,0,0.05), 0 6px 16px rgba(0,0,0,0.03));
    --nfs-shadow-red: var(--shadow-red, 0 4px 16px rgba(185,28,28,0.25));
    --nfs-ease: cubic-bezier(0.16, 1, 0.3, 1);
    font-family: var(--font-body, 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    color: var(--nfs-text);
}

/* Container */
.nfs-file-list {
    margin: 0;
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius);
    overflow: hidden;
    background: var(--nfs-surface);
    box-shadow: var(--nfs-shadow);
}

.nfs-container > .nfs-file-list {
    margin: 0;
}

.nfs-container {
    margin: 20px 0;
}

/* Loading Indicator */
.nfs-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

.nfs-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--nfs-border);
    border-top-color: var(--nfs-accent);
    border-radius: 50%;
    animation: nfs-spin 0.8s linear infinite;
}

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

.nfs-container.nfs-loaded .nfs-loading {
    display: none;
}

.nfs-container:not(.nfs-loaded) .nfs-toolbar,
.nfs-container:not(.nfs-loaded) .nfs-file-list,
.nfs-container:not(.nfs-loaded) .nfs-breadcrumbs,
.nfs-container:not(.nfs-loaded) .nfs-cascade-selects,
.nfs-container:not(.nfs-loaded) .nfs-empty {
    display: none;
}

.nfs-container.nfs-navigating .nfs-file-list {
    opacity: 0.5;
    pointer-events: none;
}

.nfs-container.nfs-navigating .nfs-loading {
    display: flex !important;
}

/* Toolbar */
.nfs-toolbar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
}

.nfs-search-wrapper {
    flex: 1;
    max-width: 300px;
}

.nfs-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius-sm);
    font-size: 14px;
    background: var(--nfs-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.nfs-search-input:focus {
    outline: none;
    border-color: var(--nfs-accent);
    box-shadow: 0 0 0 2px var(--nfs-accent-ring);
}

.nfs-search-input::placeholder {
    color: var(--nfs-text-muted);
}

.nfs-file-count {
    font-size: 13px;
    color: var(--nfs-text-muted);
    white-space: nowrap;
}

/* Filter Chips */
.nfs-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 10px 0;
}

.nfs-filter-chip {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--nfs-border);
    border-radius: 999px;
    background: var(--nfs-surface);
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    color: var(--nfs-text);
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
}

.nfs-filter-chip:hover {
    background-color: var(--nfs-accent-soft);
    border-color: var(--c-red-300, #FCA5A5);
    color: var(--nfs-accent);
}

.nfs-filter-chip.nfs-filter-active {
    background-color: var(--nfs-accent);
    border-color: var(--nfs-accent);
    color: #fff;
}

.nfs-filter-chip:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: 2px;
}

/* Cascade-Selects (Ordner-Navigation per Dropdown) */
.nfs-cascade-selects {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
    align-items: center;
}

.nfs-cascade-selects .nfs-folder-select {
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 320px;
    padding: 8px 12px;
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius-sm);
    background: var(--nfs-surface);
    font-size: 14px;
    font-family: inherit;
    color: var(--nfs-text);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.nfs-cascade-selects .nfs-folder-select:hover {
    border-color: var(--nfs-border-strong);
}

.nfs-cascade-selects .nfs-folder-select:focus {
    outline: none;
    border-color: var(--nfs-accent);
    box-shadow: 0 0 0 2px var(--nfs-accent-ring);
}

.nfs-cascade-selects .nfs-folder-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Header */
.nfs-file-list-header {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 15px;
    padding: 12px 15px;
    background: var(--nfs-surface-alt);
    border-bottom: 1px solid var(--nfs-border);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--nfs-text-muted);
    user-select: none;
}

.nfs-file-list-header .nfs-file-name {
    min-width: 0;
}

.nfs-file-list-header .nfs-file-size {
    width: 100px;
    text-align: right;
}

.nfs-file-list-header .nfs-file-date {
    width: 180px;
    text-align: right;
}

.nfs-file-list-header .nfs-file-download {
    width: 100px;
}

/* Sortable Headers */
.nfs-sortable {
    cursor: pointer;
    transition: color 0.2s ease;
}

.nfs-sortable:hover {
    color: var(--nfs-accent);
}

.nfs-sortable::after {
    content: '';
    display: inline-block;
    margin-left: 5px;
    opacity: 0.3;
}

.nfs-sort-asc::after {
    content: '\25B2';
    opacity: 1;
    font-size: 10px;
}

.nfs-sort-desc::after {
    content: '\25BC';
    opacity: 1;
    font-size: 10px;
}

.nfs-sort-active {
    color: var(--nfs-accent);
}

/* Focus States */
.nfs-sortable:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.nfs-download-button:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--nfs-accent-ring);
}

.nfs-folder-link:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: 2px;
}

.nfs-breadcrumb-link:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* File Item */
.nfs-file-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--nfs-border);
    align-items: center;
    transition: background-color 0.2s ease;
}

.nfs-file-item:last-child {
    border-bottom: none;
}

.nfs-file-item:hover {
    background-color: var(--nfs-surface-alt);
}

.nfs-file-item[style*="display: none"] + .nfs-file-item {
    border-top: none;
}

/* File Name */
.nfs-file-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.nfs-file-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nfs-text-muted);
}

.nfs-folder-item .nfs-file-icon {
    color: var(--nfs-accent);
}

.nfs-file-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--nfs-text);
}

/* File Size */
.nfs-file-size {
    width: 100px;
    text-align: right;
    color: var(--nfs-text-muted);
    font-size: 14px;
}

/* File Date */
.nfs-file-date {
    width: 180px;
    text-align: right;
    color: var(--nfs-text-muted);
    font-size: 14px;
}

/* Download Button */
.nfs-file-download {
    width: 100px;
}

.nfs-download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: var(--nfs-accent);
    color: #fff;
    text-decoration: none;
    border: none;
    border-radius: var(--nfs-btn-radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.2;
    text-align: center;
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.25);
    transition: all 0.25s var(--nfs-ease);
    white-space: nowrap;
}

.nfs-download-button:hover,
.nfs-download-button:focus {
    background-color: var(--nfs-accent-hover);
    color: #fff;
    box-shadow: var(--nfs-shadow-red);
    transform: translateY(-1px);
}

.nfs-download-button:active {
    background-color: var(--nfs-accent-strong);
    transform: none;
}

/* Error Message */
.nfs-error {
    padding: 15px;
    background-color: var(--nfs-accent-soft);
    border: 1px solid var(--c-red-200, #FECACA);
    border-radius: var(--nfs-radius-sm);
    color: var(--c-red-800, #7F1D1D);
    margin: 20px 0;
}

.nfs-error p {
    margin: 0;
}

/* Empty Message */
.nfs-empty {
    padding: 30px;
    text-align: center;
    color: var(--nfs-text-muted);
    background-color: var(--nfs-surface-alt);
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius-sm);
    margin: 20px 0;
}

.nfs-empty p {
    margin: 0;
    font-style: italic;
}

/* Breadcrumbs */
.nfs-breadcrumbs {
    padding: 10px 15px;
    background: var(--nfs-surface-alt);
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius-sm);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 0;
}

.nfs-breadcrumbs + .nfs-toolbar {
    margin-top: 10px;
}

.nfs-breadcrumb-link {
    color: var(--nfs-accent);
    font-weight: 500;
    text-decoration: none;
}

.nfs-breadcrumb-link:hover {
    text-decoration: underline;
}

.nfs-breadcrumb-separator {
    color: var(--nfs-text-muted);
    margin: 0 4px;
}

.nfs-breadcrumb-current {
    color: var(--nfs-text);
    font-weight: 600;
}

/* Folder Items */
.nfs-folder-item {
    background-color: var(--nfs-surface);
}

.nfs-folder-item:hover {
    background-color: var(--nfs-accent-soft);
}

.nfs-folder-link {
    color: var(--nfs-text);
    text-decoration: none;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nfs-folder-link:hover {
    text-decoration: none;
    color: var(--nfs-accent);
}

/* No Results */
.nfs-no-results {
    padding: 20px 15px;
    text-align: center;
    color: var(--nfs-text-muted);
    font-style: italic;
    display: none;
}

/* Pagination / Load More */
.nfs-paginated-hidden {
    display: none !important;
}

.nfs-show-all-wrapper {
    padding: 15px;
    text-align: center;
}

.nfs-show-all-button {
    display: inline-flex;
    align-items: center;
    padding: 8px 20px;
    background: transparent;
    border: 1.5px solid var(--nfs-border);
    border-radius: var(--nfs-btn-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--c-gray-700, #374151);
    font-family: inherit;
    transition: all 0.25s var(--nfs-ease);
}

.nfs-show-all-button:hover {
    border-color: var(--c-red-400, #EF4444);
    color: var(--nfs-accent);
}

.nfs-show-all-button:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: 2px;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .nfs-file-list-header {
        display: none;
    }

    .nfs-file-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 15px;
    }

    .nfs-file-name {
        grid-column: 1;
    }

    .nfs-file-size,
    .nfs-file-date {
        width: auto;
        text-align: left;
        font-size: 13px;
    }

    .nfs-file-size::before {
        content: "Größe: ";
        font-weight: 600;
    }

    .nfs-file-date::before {
        content: "Geändert: ";
        font-weight: 600;
    }

    .nfs-file-download {
        width: auto;
    }

    .nfs-download-button {
        display: flex;
        width: 100%;
        padding: 12px;
    }

    .nfs-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .nfs-search-wrapper {
        max-width: none;
    }

    .nfs-file-count {
        text-align: right;
    }

    .nfs-breadcrumbs {
        font-size: 13px;
        padding: 8px 12px;
    }

    .nfs-cascade-selects {
        flex-direction: column;
        align-items: stretch;
    }

    /* Untereinander: flex-basis 200px wäre sonst die Höhe jedes Menüs. */
    .nfs-cascade-selects .nfs-folder-select {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .nfs-search-input,
    .nfs-sortable,
    .nfs-file-item,
    .nfs-download-button,
    .nfs-filter-chip,
    .nfs-show-all-button {
        transition: none;
    }

    .nfs-download-button:hover,
    .nfs-download-button:focus {
        transform: none;
    }

    .nfs-spinner {
        animation: none;
        opacity: 0.7;
    }
}

@media screen and (max-width: 480px) {
    .nfs-file-icon {
        width: 18px;
        height: 18px;
    }

    .nfs-file-name-text {
        font-size: 14px;
    }

    .nfs-file-item {
        padding: 12px;
    }
}

/* ------------------------------------------------------------------
 * Nextcloud-Events (Block nfs/events, ab 1.7.0)
 * ---------------------------------------------------------------- */

/* Spezifischer als .entry-content ul/li des Themes (Einzug, Aufzählungspunkte). */
.nfs-events ul.nfs-events__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nfs-events .nfs-events__item {
    margin: 0;
    line-height: 1.4;
}

.nfs-events--list .nfs-events__list {
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius);
    background: var(--nfs-surface);
    box-shadow: var(--nfs-shadow);
    overflow: hidden;
}

.nfs-events--list .nfs-events__item + .nfs-events__item {
    border-top: 1px solid var(--nfs-border);
}

.nfs-events__link {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 16px 20px;
    color: var(--nfs-text);
    text-decoration: none;
    transition: background-color 0.2s var(--nfs-ease), color 0.2s var(--nfs-ease);
}

.nfs-events__link:hover,
.nfs-events__link:focus-visible {
    background: var(--nfs-accent-soft);
    color: var(--nfs-accent-strong);
}

.nfs-events__link:focus-visible {
    outline: 2px solid var(--nfs-accent);
    outline-offset: -2px;
}

.nfs-events__date {
    flex: 0 0 auto;
    min-width: 9.5em;
    color: var(--nfs-text-muted);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.nfs-events__title {
    flex: 1 1 auto;
    font-weight: 600;
}

.nfs-events__arrow {
    flex: 0 0 auto;
    color: var(--nfs-accent);
    transition: transform 0.2s var(--nfs-ease);
}

.nfs-events__link:hover .nfs-events__arrow {
    transform: translateX(3px);
}

/* Kacheln */
.nfs-events--cards .nfs-events__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.nfs-events--cards .nfs-events__link {
    flex-direction: column;
    gap: 6px;
    height: 100%;
    box-sizing: border-box;
    padding: 20px;
    border: 1px solid var(--nfs-border);
    border-radius: var(--nfs-radius);
    background: var(--nfs-surface);
    box-shadow: var(--nfs-shadow);
}

.nfs-events--cards .nfs-events__link:hover {
    border-color: var(--nfs-accent);
}

.nfs-events--cards .nfs-events__date {
    min-width: 0;
}

.nfs-events--cards .nfs-events__date--none {
    display: none;
}

.nfs-events--cards .nfs-events__title {
    font-size: 1.125rem;
}

.nfs-events--cards .nfs-events__arrow {
    margin-top: auto;
}

/* Detailseite */
.nfs-event__back {
    margin: 0 0 8px;
}

.nfs-event__back a {
    color: var(--c-red-600, #B91C1C);
    font-weight: 600;
    text-decoration: none;
}

.nfs-event__back a:hover {
    text-decoration: underline;
}

.nfs-event__date {
    margin: 0 0 4px;
    color: var(--c-gray-500, #6B7280);
}

/* Hinweis nur für die Redaktion */
.nfs-events__admin {
    margin: 12px 0 0;
    font-size: 0.8125rem;
    color: var(--c-gray-500, #6B7280);
}

@media (max-width: 600px) {
    .nfs-events--list .nfs-events__link {
        flex-wrap: wrap;
        gap: 2px 12px;
        padding: 14px 16px;
    }

    .nfs-events--list .nfs-events__date {
        flex-basis: 100%;
        min-width: 0;
    }

    .nfs-events--list .nfs-events__date--none {
        display: none;
    }

    .nfs-events--list .nfs-events__title {
        flex: 1 1 0;
    }
}
