/* MediaVault - Dark Dropbox/Notion-inspired */
:root {
    --bg-0: #0d0f14;
    --bg-1: #14171f;
    --bg-2: #1b1f29;
    --bg-3: #232836;
    --bg-hover: #262b39;
    --bg-active: #2d3447;
    --border: #2a2f3d;
    --border-strong: #3a4156;
    --text: #e6e8ee;
    --text-dim: #9aa3b8;
    --text-muted: #6b7488;
    --accent: #5b8def;
    --accent-2: #7aa2ff;
    --accent-soft: rgba(91,141,239,0.12);
    --danger: #ef5b6b;
    --success: #58c896;
    --warning: #f0b36e;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow: 0 8px 28px rgba(0,0,0,0.45);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-0); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }
button { font-family: inherit; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
.muted { color: var(--text-dim); font-size: 13px; }
.danger { color: var(--danger) !important; }

/* Buttons */
.btn-primary, .btn-ghost {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    font-weight: 500; font-size: 13px; cursor: pointer;
    border: 1px solid transparent; transition: background .15s, transform .05s;
    user-select: none; text-decoration: none;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.block { display: flex; width: 100%; justify-content: center; padding: 10px; }
.btn-secondary { background: var(--bg-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--border-strong); }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-dim); border: 0; cursor: pointer;
    font-size: 16px;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); }
.icon-btn.active { background: var(--bg-3); color: var(--accent-2); }
.icon-btn.small { width: 24px; height: 24px; font-size: 14px; }

/* Forms */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.form-row input {
    width: 100%; padding: 10px 12px; background: var(--bg-1); border: 1px solid var(--border);
    color: var(--text); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.form-row input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; border: 1px solid var(--border); }
.alert-error { background: rgba(239,91,107,0.08); border-color: rgba(239,91,107,0.3); color: #ffb3bb; }
.alert-success { background: rgba(88,200,150,0.08); border-color: rgba(88,200,150,0.3); color: #b8efd4; }

/* Logo */
.logo-mark {
    width: 30px; height: 30px; background: linear-gradient(135deg, var(--accent), #8a5cff);
    color: white; font-weight: 700; font-size: 13px; letter-spacing: .04em;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; box-shadow: 0 4px 14px rgba(91,141,239,0.45);
}
.logo-mark.big { width: 56px; height: 56px; font-size: 22px; border-radius: 14px; }

/* Install + Login */
.install-body, .login-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 30% 20%, #1c2236, var(--bg-0) 55%);
    padding: 24px;
}
.install-card {
    background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 36px; max-width: 520px; width: 100%; box-shadow: var(--shadow);
}
.install-header { text-align: center; margin-bottom: 28px; }
.install-header h1 { margin: 14px 0 4px; font-size: 24px; }
.install-card h2 { font-size: 16px; margin-top: 20px; }
.install-card h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 12px; }

.check-list { list-style: none; padding: 0; margin: 0 0 22px; }
.check-list li { display: flex; justify-content: space-between; padding: 10px 14px; background: var(--bg-2); border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 13px; }
.check-list li.ok { border-left: 3px solid var(--success); }
.check-list li.fail { border-left: 3px solid var(--danger); }

.login-shell { width: 100%; max-width: 420px; }
.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand h1 { margin: 14px 0 4px; font-size: 28px; font-weight: 700; }
.login-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 20px; font-size: 18px; }

/* Topbar */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 18px; background: var(--bg-1); border-bottom: 1px solid var(--border);
    gap: 16px; position: sticky; top: 0; z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand-text { font-weight: 600; font-size: 15px; }
.breadcrumb { display: flex; align-items: center; gap: 4px; margin-left: 12px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.breadcrumb a { padding: 4px 8px; border-radius: 4px; color: var(--text-dim); }
.breadcrumb a:hover { background: var(--bg-2); color: var(--text); }
.breadcrumb .sep { opacity: 0.4; }
.breadcrumb .current { color: var(--text); font-weight: 500; padding: 4px 8px; }

.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-2); border-radius: 20px; font-size: 13px; }
.user-chip a { font-size: 12px; }

/* Workspace */
.workspace { display: grid; grid-template-columns: 260px 1fr; height: calc(100vh - 57px); }

/* Sidebar */
.sidebar { background: var(--bg-1); border-right: 1px solid var(--border); overflow-y: auto; padding: 14px 8px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.folder-tree { font-size: 14px; }

.tree-node { user-select: none; }
.tree-row { display: flex; align-items: center; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; gap: 4px; position: relative; }
.tree-row:hover { background: var(--bg-2); }
.tree-row.selected { background: var(--bg-3); color: var(--accent-2); }
.tree-row.drop-target { background: var(--accent-soft); outline: 1px dashed var(--accent); }
.tree-toggle { width: 18px; text-align: center; color: var(--text-muted); font-size: 10px; flex-shrink: 0; }
.tree-toggle.invisible { visibility: hidden; }
.tree-icon { width: 16px; flex-shrink: 0; opacity: 0.85; }
.tree-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 2px 0; }
.tree-children { padding-left: 16px; }
.tree-children.collapsed { display: none; }

/* Content area */
.content { position: relative; overflow-y: auto; padding: 22px 28px; background: var(--bg-0); }
/* Grid: feste kleine Kacheln */
.file-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; }
.file-grid.view-list { display: flex; flex-direction: column; gap: 2px; }

/* Card */
.file-card {
    background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; cursor: pointer; transition: border-color .15s, transform .1s, background .15s;
    position: relative; display: flex; flex-direction: column;
    width: 120px;
}
.file-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.file-card.selected { border-color: var(--accent); background: var(--bg-2); box-shadow: 0 0 0 2px var(--accent-soft); }
.file-card.dragging { opacity: 0.4; transform: scale(0.95); }

/* Thumb-Bereich: quadratisch, feste Höhe */
.file-thumb {
    width: 120px; height: 90px;
    background: var(--bg-2);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; position: relative; flex-shrink: 0;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* SVG-Datei-Icon (modernes Dokument-Icon) */
.file-thumb svg { width: 54px; height: 66px; }

.file-card-body { padding: 7px 8px 8px; }
.file-card-name {
    font-size: 11px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--text); line-height: 1.3;
}
.file-card-meta { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* List view — bleibt unverändert breiter */
.view-list .file-card { width: auto; flex-direction: row; align-items: center; gap: 12px; padding: 8px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.view-list .file-card:hover { background: var(--bg-1); transform: none; box-shadow: none; }
.view-list .file-card.selected { background: var(--bg-2); box-shadow: none; }
.view-list .file-thumb { width: 36px; height: 36px; border-radius: var(--radius-sm); flex-shrink: 0; }
.view-list .file-thumb svg { width: 22px; height: 27px; }
.view-list .file-card-body { flex: 1; padding: 0; }
.view-list .file-card-name { font-size: 13px; }

/* Empty state */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-illu { font-size: 64px; color: var(--bg-3); margin-bottom: 12px; }
.empty-state h3 { margin: 0 0 8px; color: var(--text); font-weight: 500; }

/* Dropzone */
.dropzone-overlay {
    position: absolute; inset: 0; background: rgba(91,141,239,0.10);
    border: 2px dashed var(--accent); border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center; z-index: 20;
    pointer-events: none; margin: 12px;
}
.dropzone-msg { font-size: 18px; color: var(--accent-2); font-weight: 500; }

/* Modal */
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content { position: relative; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 90vw; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

.preview-content { width: 1100px; height: 80vh; }
.preview-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 14px; }
.preview-header span { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.preview-body { flex: 1; overflow: auto; background: var(--bg-0); display: flex; align-items: center; justify-content: center; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: white; }
.preview-body .file-fallback { padding: 40px; text-align: center; }

.confirm-content { width: 420px; padding: 22px; }
.confirm-content h3 { margin: 0 0 8px; }
.confirm-content p { color: var(--text-dim); margin: 0 0 18px; }
.confirm-content .modal-actions { padding: 0; border: 0; }

.trash-content { width: 780px; max-height: 80vh; }
.trash-list { padding: 12px 22px 22px; overflow-y: auto; }
.trash-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); }
.trash-item:hover { background: var(--bg-2); }
.trash-item .ti-name { flex: 1; }
.trash-item .ti-meta { color: var(--text-muted); font-size: 12px; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg-3); color: var(--text); padding: 12px 20px;
    border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200;
    font-size: 13px; border: 1px solid var(--border-strong);
    animation: toast-in .25s ease-out;
}
.toast.success { border-color: rgba(88,200,150,0.5); }
.toast.error { border-color: rgba(239,91,107,0.5); }
@keyframes toast-in { from { transform: translate(-50%, 20px); opacity: 0; } }

/* Context menu */
.ctxmenu {
    position: fixed; background: var(--bg-2); border: 1px solid var(--border-strong);
    border-radius: var(--radius); padding: 6px; min-width: 200px; box-shadow: var(--shadow);
    z-index: 150;
}
.ctxmenu button {
    display: flex; width: 100%; padding: 8px 12px; background: transparent; color: var(--text);
    border: 0; text-align: left; font-size: 13px; cursor: pointer; border-radius: var(--radius-sm); gap: 8px;
}
.ctxmenu button:hover { background: var(--bg-hover); }
.ctxmenu button.danger { color: var(--danger); }
.ctxmenu .sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Inline rename input */
.rename-input {
    width: 100%; padding: 4px 6px; background: var(--bg-3); border: 1px solid var(--accent);
    color: var(--text); border-radius: 4px; font-family: inherit; font-size: inherit;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Mobile */
@media (max-width: 768px) {
    .workspace { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .preview-content { width: 95vw; height: 85vh; }
}

/* Text-Vorschau */
.text-preview {
    padding: 20px 24px;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    max-height: 70vh;
    background: var(--bg-0);
    border-radius: var(--radius);
    margin: 0;
}

/* ============================================================
   DRAG & DROP — Indikatoren und Handles
   ============================================================ */

/* Drop-Indikator zwischen Dateien (Grid) */
.file-grid:not(.view-list) .drop-indicator {
    width: 3px;
    align-self: stretch;
    background: var(--accent);
    border-radius: 2px;
    margin: 4px 0;
    opacity: 0;
    transition: opacity .12s;
    pointer-events: none;
    flex-shrink: 0;
}
.file-grid:not(.view-list) .drop-indicator.active {
    opacity: 1;
    pointer-events: auto;
}
/* Grid muss flex sein für vertikale Indikatoren */
/* Grid: flex für DnD-Placeholder-Kompatibilität */
.file-grid:not(.view-list) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

/* Drop-Indikator zwischen Dateien (Liste) */
.view-list .drop-indicator {
    height: 2px;
    width: 100%;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0;
    transition: opacity .12s;
    pointer-events: none;
    margin: -1px 0;
}
.view-list .drop-indicator.active {
    opacity: 1;
    pointer-events: auto;
}

/* Drop-Indikator im Ordner-Baum */
.tree-children .drop-indicator {
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    margin: 1px 8px;
    opacity: 0;
    transition: opacity .12s;
    pointer-events: none;
}
.tree-children .drop-indicator.active {
    opacity: 1;
    pointer-events: auto;
}

/* Drag-Handle auf Datei-Karten */
.drag-handle {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0;
    cursor: grab;
    transition: opacity .15s;
    border-radius: 3px;
    background: rgba(0,0,0,.4);
    line-height: 1;
}
.file-card:hover .drag-handle { opacity: 1; }
.file-card.dragging { opacity: 0.4; transform: scale(0.97); }

/* Tree-Row Drag-Feedback */
.tree-row.dragging { opacity: 0.4; }
.tree-row.drop-target {
    background: var(--accent-soft) !important;
    outline: 1px dashed var(--accent);
    border-radius: var(--radius-sm);
}

/* ============================================================
   UPLOAD-FORTSCHRITTS-PANEL
   ============================================================ */
.upload-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    background: var(--bg-1);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    z-index: 1100;
    overflow: hidden;
    animation: slideUp .2s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.upload-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.upload-panel-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 0;
}

/* Einzelne Upload-Zeile */
.upload-item {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    transition: background .1s;
}
.upload-item:hover { background: var(--bg-2); }

.upload-item-icon {
    width: 32px; height: 32px;
    border-radius: 6px;
    background: var(--bg-3);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.upload-item-body { min-width: 0; }
.upload-item-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    margin-bottom: 5px;
}
.upload-item-bar-wrap {
    height: 4px;
    background: var(--bg-3);
    border-radius: 2px;
    overflow: hidden;
}
.upload-item-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .15s linear;
}
.upload-item-bar.done    { background: #4caf82; }
.upload-item-bar.error   { background: #ef5b6b; }

.upload-item-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 3px;
}
.upload-item-status {
    font-size: 16px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* Gesamt-Fortschritt (bei mehreren Dateien) */
.upload-overall {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border);
}
.upload-overall-bar {
    height: 5px;
    background: var(--bg-3);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 5px;
}
.upload-overall-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width .2s linear;
}
#upload-overall-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* Neue saubere DnD-Zustände */
.tree-row.drop-above {
    box-shadow: 0 -2px 0 0 var(--accent);
    border-radius: 0;
}
.tree-row.drop-below {
    box-shadow: 0 2px 0 0 var(--accent);
    border-radius: 0;
}
.__mv_ph { pointer-events: none; }

/* Embed-Code-Dialog */
.embed-content { width: min(520px, 95vw); }
.embed-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.embed-textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px 14px;
    background: var(--bg-0);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: "SF Mono", "Fira Code", Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
    outline: none;
    transition: border-color .15s;
}
.embed-textarea:focus { border-color: var(--accent); }

/* ============================================================
   ORDNER-KACHELN im Grid
   ============================================================ */
.folder-card {
    border-color: #2a3050;
}
.folder-card:hover {
    border-color: var(--accent);
    background: var(--bg-2);
}
.folder-thumb {
    background: linear-gradient(160deg, #1a1f38 0%, #151929 100%) !important;
    padding: 8px;
}
.folder-thumb svg {
    width: 100%;
    height: 100%;
}

/* Trennlinie zwischen Ordnern und Dateien */
.file-grid .folder-section-end {
    width: 100%;
    height: 0;
    border-top: 1px solid var(--border);
    margin: 4px 0 8px;
}

/* Listen-Ansicht: Ordner-Kachel als Zeile */
.view-list .folder-card {
    background: var(--bg-0) !important;
    border: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
}
.view-list .folder-thumb {
    background: transparent !important;
    padding: 4px;
}
.view-list .folder-thumb svg { width: 22px; height: 18px; }
.folder-card.drop-target {
    border-color: var(--accent) !important;
    background: var(--accent-soft) !important;
    box-shadow: 0 0 0 2px var(--accent-soft);
}
