/* ---- Variables ---- */
:root {
    --bg:            #f8fbf9;
    --surface:       #fff;
    --surface-alt:   #eef7f2;
    --surface-hover: #f0faf4;
    --text:          #1a2e24;
    --text-muted:    #666;
    --text-faint:    #999;
    --border:        #cfe3d7;
    --border-table:  #ddd;
    --border-footer: #e0ece6;
    --accent:        #1f7a4d;
    --accent-shadow: rgba(31,122,77,.15);
    --accent-hover:  #f2b705;
    --input-border:  #ccc;
}

[data-theme="dark"] {
    --bg:            #0f1a14;
    --surface:       #1a2e24;
    --surface-alt:   #162619;
    --surface-hover: #1e3328;
    --text:          #e0ede6;
    --text-muted:    #8aaa96;
    --text-faint:    #6a8a76;
    --border:        #2a4a36;
    --border-table:  #2a4a36;
    --border-footer: #2a4a36;
    --accent:        #2fb87a;
    --accent-hover:  #f2b705;
    --input-border:  #3a5a46;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: Arial, sans-serif;
    background: var(--bg);
    margin: 0;
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background .2s, color .2s;
}

main {
    flex: 1;
    padding-bottom: 56px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- Header (fixiert) ---- */
header {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 15px;
    background: var(--surface);
    border-bottom: 3px solid var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

header a.logo-link {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

header img { height: 50px; }

header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .12s, color .12s;
}

.logout-btn:hover {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.logout-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.logout-btn.active:hover {
    background: #dc3545;
    border-color: #dc3545;
}

/* ---- Theme Toggle ---- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent);
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s, color .12s, border-color .12s;
}

.theme-toggle:hover {
    background: var(--surface-alt);
    color: var(--accent-hover);
}

/* ---- Breadcrumb ---- */
.breadcrumb {
    padding: 10px 15px;
    background: var(--surface-alt);
    font-size: 14px;
    color: var(--text);
}

/* ---- Toolbar ---- */
.toolbar {
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-input-wrap input {
    width: 100%;
    padding: 9px 34px 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--input-border);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    transition: background .2s, color .2s, border-color .15s;
}

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

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 15px;
    padding: 0;
    display: none;
    line-height: 1;
}

.search-clear:hover { color: #dc3545; }

.search-meta {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 2px;
    min-height: 16px;
}

/* ---- Global-Suche Toggle ---- */
.global-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .12s, color .12s, border-color .12s;
}

.global-toggle:hover { background: var(--surface-alt); }

.global-toggle.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---- Filter-Chips (lokal + global) ---- */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 15px 10px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    transition: background .15s, color .15s;
}

.filter-chip:hover { background: var(--surface-alt); }

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

.filter-chip .chip-count {
    background: rgba(0,0,0,.12);
    border-radius: 10px;
    padding: 0 5px;
    font-size: 11px;
}

.filter-chip.active .chip-count { background: rgba(255,255,255,.25); }

/* ---- Tabelle (lokal + global) ---- */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--surface-alt);
    color: var(--text);
    padding: 10px;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    user-select: none;
}

th .sort-arrow {
    display: inline-block;
    width: 14px;
    color: var(--text-faint);
    font-size: 11px;
    margin-left: 3px;
}

th.sort-asc  .sort-arrow::after { content: '▲'; color: var(--accent); }
th.sort-desc .sort-arrow::after { content: '▼'; color: var(--accent); }
th:not(.sort-asc):not(.sort-desc) .sort-arrow::after { content: '⇅'; }

th.no-sort { cursor: default; }
th.no-sort .sort-arrow { display: none; }

td {
    padding: 10px;
    border-bottom: 1px solid var(--border-table);
    vertical-align: middle;
    color: var(--text);
    min-width: 0;
}

/* Symlinks: Aktions-Spalte immer auf Inhaltbreite einfrieren */
#symlinksTable td:last-child,
#symlinksTable th:last-child {
    width: 1px;
    white-space: nowrap;
}

/* Symlinks: Name-Spalte darf schrumpfen */
#symlinksTable td:first-child {
    max-width: 220px;
    overflow: hidden;
}

tr:hover { background: var(--surface-hover); }

/* Pfad-Spalte in globaler Tabelle */
.td-path {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-path a { color: var(--text-muted); font-size: 12px; }
.td-path a:hover { color: var(--accent); }

/* ---- File-icon Farben ---- */
.icon-image   { color: #198754; }
.icon-pdf     { color: #dc3545; }
.icon-word    { color: #0d6efd; }
.icon-excel   { color: #198754; }
.icon-ppt     { color: #fd7e14; }
.icon-archive { color: #6c757d; }
.icon-audio   { color: #20c997; }
.icon-video   { color: #dc3545; }
.icon-font    { color: #6c757d; }
.icon-binary  { color: #495057; }
.icon-db      { color: #0dcaf0; }
.icon-js      { color: #b8a000; }
.icon-code    { color: #6f42c1; }
.icon-markup  { color: #0d6efd; }
.icon-text    { color: #6c757d; }
.icon-default { color: #adb5bd; }
.bi-folder-fill { color: #ffc107; }

.file-icon { font-size: 16px; flex-shrink: 0; }

/* ---- File row layout ---- */
.file-link-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
}

/* ---- Buttons ---- */
.preview-btn,
.download-btn,
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s, color .12s;
}

.preview-btn:hover,
.download-btn:hover,
.copy-btn:hover { background: var(--surface-hover); color: var(--accent-hover); }

.copy-btn.copied { border-color: #198754; color: #198754; }

/* ---- Image thumbnail ---- */
.preview {
    max-height: 40px;
    margin-top: 5px;
    border-radius: 4px;
    display: block;
}

/* ---- Search highlight ---- */
mark {
    background: #fff3cd;
    color: #1a2e24;
    border-radius: 2px;
    padding: 0 1px;
}

[data-theme="dark"] mark {
    background: #5a4a00;
    color: #ffe080;
}

/* ---- Status-Zeilen (global) ---- */
.g-status {
    padding: 30px 15px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.g-status.error   { color: #dc3545; }
.g-status.loading { color: var(--accent); }
.g-status.loading i { display: inline-block; animation: spin .8s linear infinite; }

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

/* ---- Modal ---- */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,.65);
}

.modal.show { display: block; }

.modal-window {
    position: absolute;
    top: 4%; left: 4%;
    width: 92%; height: 92%;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 40px rgba(0,0,0,.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 12px 15px;
    background: var(--accent);
    color: #fff;
}

.modal-title {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.modal-actions a,
.modal-actions button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: var(--accent);
    border: 0;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}

.modal-actions a:hover,
.modal-actions button:hover { color: var(--accent-hover); }

.modal-body { flex: 1; background: var(--surface); overflow: hidden; }
.modal-body.is-video { background: #000; }
.modal-body iframe { width: 100%; height: 100%; border: 0; }
.modal-body video { width: 100%; height: 100%; display: block; }

/* ---- Table scroll wrapper ---- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Footer (fixiert) ---- */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    text-align: center;
    padding: 14px 15px;
    font-size: 13px;
    color: var(--text-faint);
    border-top: 1px solid var(--border-footer);
    background: var(--surface);
    transition: background .2s, border-color .2s;
}

/* ================================================================ */
/* SHORTLINKS                                                       */
/* ================================================================ */

.symlinks-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity .12s;
}
.btn-add:hover { opacity: .85; }

.sl-vfolder-row td { color: var(--text); }
.sl-vfolder-row:hover { background: var(--surface-hover); }

.sl-url {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}

.sl-delete-btn { color: #dc3545 !important; border-color: #dc3545 !important; }
.sl-delete-btn:hover { background: #dc3545 !important; color: #fff !important; }

.sl-delete-disabled {
    color: #aaa !important;
    border-color: #ddd !important;
    cursor: not-allowed !important;
    opacity: .5;
}
.sl-delete-disabled:hover { background: none !important; color: #aaa !important; }

.sl-lock-btn { color: var(--text-muted) !important; }
.sl-lock-btn:hover { color: var(--accent) !important; }
.sl-lock-btn.sl-locked { color: var(--accent) !important; border-color: var(--accent) !important; }

.sl-pin-active { color: var(--accent) !important; border-color: var(--accent) !important; }

.sl-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
    font-size: 14px;
}

.sl-count {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 4px 2px;
    text-align: right;
}

/* ---- Shortlink Modal ---- */
.sl-modal-window {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(540px, 96vw);
    height: auto;
    max-height: 90vh;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 40px rgba(0,0,0,.3);
}

.sl-modal-body {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sl-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 10px;
}

.sl-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.sl-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-shadow);
}

.sl-slug-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}
.sl-slug-wrap .sl-input { flex: 1; }

.sl-preview {
    font-family: monospace;
    font-size: 13px;
    padding: 10px 12px;
    background: var(--surface-alt);
    border-radius: 6px;
    color: var(--text-muted);
    word-break: break-all;
    border: 1px solid var(--border);
}
.sl-preview.has-value { color: var(--accent); font-weight: 600; }

.sl-error {
    font-size: 13px;
    color: #dc3545;
    background: #fff5f5;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 4px;
}

.sl-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.sl-btn-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity .12s;
}
.sl-btn-save:hover { opacity: .85; }
.sl-btn-save:disabled { opacity: .5; cursor: not-allowed; }

.sl-btn-cancel {
    padding: 9px 16px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .12s;
}
.sl-btn-cancel:hover { background: var(--surface-alt); }

/* ---- Responsive: Tablet ≤ 768px ---- */
@media (max-width: 768px) {
    header h2 {
        font-size: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .modal-window { top: 0; left: 0; width: 100%; height: 100%; border-radius: 0; }
    .modal-header { flex-direction: column; align-items: stretch; }
    .modal-actions { justify-content: flex-end; }

    /* Dateiliste scrollt horizontal – alle Spalten bleiben sichtbar */

    /* Symlinks: Erstellt + Aufrufe ausblenden */
    #symlinksTable td:nth-child(4),
    #symlinksTable th:nth-child(4),
    #symlinksTable td:nth-child(5),
    #symlinksTable th:nth-child(5) { display: none; }


    .global-toggle span { display: none; }
    .td-path { max-width: 140px; }

    /* Icons enger setzen */
    .file-link-row { gap: 4px; }

    /* Dateiname: Auge-Icon ausblenden, Name sichtbar + abgeschnitten */
    .preview-btn { flex: 1; min-width: 0; border: none; background: none; padding: 2px 0; }
    .preview-btn .bi-eye { display: none; }
    .preview-btn span {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Action-Buttons kompakt, nur Icon */
    .download-btn, .copy-btn { padding: 5px 7px; flex-shrink: 0; }

    /* Thumbnail ausblenden */
    .preview { display: none; }
}

/* ---- Responsive: Mobil ≤ 480px ---- */
@media (max-width: 480px) {
    header img { height: 36px; }

    /* Suche + Toggle untereinander */
    .search-wrap { flex-wrap: wrap; }
    .global-toggle { width: 100%; justify-content: center; }


    /* Symlinks: Kurz-URL-Spalte ausblenden */
    #symlinksTable td:nth-child(2),
    #symlinksTable th:nth-child(2) { display: none; }

    /* Pfad-Spalte in globaler Tabelle kürzen */
    .td-path { max-width: 100px; font-size: 11px; }


    /* Tabellen-Padding enger */
    td, th { padding: 8px 6px; }

    /* Icons bleiben sichtbar – Tabelle scrollt horizontal wenn nötig */
}
