/* =========================
   Reset / Base
========================= */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f4f6f9;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1d2733;
    --muted: #6b7280;
    --danger: #c62828;
    --danger-soft: #fff1f1;
    --shadow: 0 3px 10px rgba(0, 0, 0, .08);
    --shadow-menu: 0 8px 24px rgba(0, 0, 0, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 20px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.narrow {
    max-width: 520px;
    margin: 40px auto;
}

/* =========================
   Topbar
========================= */

.topbar {
    background: #1d3557;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    font-size: 22px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* =========================
   Cards / Alerts
========================= */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: var(--shadow);
    overflow: visible;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
}

.card.full-width {
    grid-column: 1 / -1;
    width: 100%;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin: 16px 0;
}

.alert-success {
    background: #e7f7eb;
    color: #1c6a33;
}

.alert-error {
    background: #fdeaea;
    color: #9c2020;
}
.alert input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
}

/* =========================
   Forms / Buttons
========================= */

label {
    display: block;
    margin: 12px 0 6px;
    font-weight: bold;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
input[type="number"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccd3db;
    border-radius: 8px;
    background: #fff;
}

.btn {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-light {
    background: #fff;
    color: #1d3557;
    border: 1px solid #d7deea;
}

.btn-light:hover {
    background: #eef4ff;
}

.btn-small {
    padding: 6px 10px;
    font-size: 13px;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #a61f1f;
}

/* =========================
   Layout Helpers
========================= */

.main-head,
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.toolbar-actions,
.sidebar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-actions form {
    margin: 0;
}

.grid.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* =========================
   Explorer Layout
========================= */

.explorer-page {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.explorer-sidebar {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: var(--card);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border);
}

.explorer-sidebar.collapsed {
    width: 70px;
    overflow: hidden;
}

.explorer-sidebar.collapsed .search-form,
.explorer-sidebar.collapsed .tree-wrap,
.explorer-sidebar.collapsed .shared-box,
.explorer-sidebar.collapsed h2 {
    display: none;
}

.explorer-main {
    overflow: visible;
}

.inline-rename-input {
    width: 100%;
    font-size: inherit;
    padding: 2px 4px;
}

/* =========================
   Search / Shared Box
========================= */

.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-form input[type="text"] {
    flex: 1;
}

.shared-box {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.shared-item {
    margin-bottom: 12px;
}

.list {
    padding-left: 18px;
}

.compact li {
    margin-bottom: 10px;
}

/* =========================
   Tree
========================= */

.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding-left: 16px;
}

.tree li {
    margin: 4px 0;
}

.tree-node {
    position: relative;
}

.tree-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    padding: 6px 10px;
    border-radius: 8px;
    max-width: calc(100% - 32px);
}

.tree-link:hover {
    background: #eef4ff;
}

.tree-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: bold;
}

.tree-toggle,
.tree-spacer {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    vertical-align: middle;
}

.tree-toggle {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: #4b5563;
    border-radius: 4px;
    padding: 0;
    font-size: 12px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.tree-toggle:hover {
    background: #eef2f7;
}

.tree-node.open > .tree-toggle {
    transform: rotate(90deg);
}

.tree-children {
    display: none;
    margin-left: 8px;
}

.tree-node.open > .tree-children {
    display: block;
}

.tree-node.open > .tree-toggle {
    transform: rotate(90deg);
}

.tree-wrap {
    max-height: 60vh;
    overflow: auto;
}

/* =========================
   Breadcrumbs
========================= */

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}

.breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: #9aa4b2;
}

/* =========================
   Explorer Header
========================= */

.explorer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    overflow: visible;
}

.explorer-header-left {
    min-width: 0;
    flex: 1;
    overflow: visible;
}

.explorer-header-right {
    flex: 0 0 auto;
}

.folder-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-bottom: 6px;
    overflow: visible;
}

.folder-title-row h1 {
    margin: 0;
    min-width: 0;
}

.explorer-subline {
    margin-top: 2px;
}

.folder-header-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    overflow: visible;
}

/* =========================
   Underfolders / Cards
========================= */

.item-main {
    flex: 1;
    min-width: 0;
}

.item-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.item-card {
    border: 1px solid #e4e9ef;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    overflow: visible;
}

.item-title {
    min-width: 0;
    margin-bottom: 8px;
}

.item-title a,
.item-title strong {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-actions {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    min-width: 60px;
    overflow: visible;
}

/* =========================
   Tables / Files
========================= */

.table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
}

.table th,
.table td {
    border-bottom: 1px solid #e4e9ef;
    text-align: left;
    padding: 12px 10px;
    vertical-align: middle;
}

.table th {
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
    background: #f8fafc;
}

.table tr {
    transition: background 0.15s ease;
}

.table tr:hover td {
    background: #f1f5ff;
}

.table th:last-child,
.table td:last-child {
    width: 280px;
}

.table th:nth-child(1),
.table td:nth-child(1) {
    width: 34%;
}

.table th:nth-child(2),
.table td:nth-child(2) {
    width: 20%;
}

.table th:nth-child(3),
.table td:nth-child(3) {
    width: 12%;
}

.table th:nth-child(4),
.table td:nth-child(4) {
    width: 16%;
}

.table th:nth-child(5),
.table td:nth-child(5) {
    width: 18%;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.file-icon {
    flex: 0 0 auto;
    font-size: 20px;
    line-height: 1;
}

.file-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.cell-muted {
    color: var(--muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    width: auto;
    overflow: visible;
}

.table td {
    overflow: visible;
}

.table {
    overflow: visible;
}

/* =========================
   Action Buttons / Menus
========================= */

.action-menu-toggle {
    width: 40px;
    height: 36px;
    font-size: 18px;
    font-weight: bold;
}

.action-btn,
.action-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d7deea;
    border-radius: 8px;
    background: #fff;
    color: #1d3557;
    text-decoration: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    transition: all 0.15s ease;
}

.action-btn:hover,
.action-menu-toggle:hover {
    background: #eef4ff;
    border-color: #c7d2fe;
}

.action-menu {
    position: relative;
    overflow: visible;
}

.action-menu-list {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    min-width: 240px;
    background: #fff;
    border: 1px solid #dfe6ef;
    border-radius: 10px;
    box-shadow: var(--shadow-menu);
    padding: 8px;
    z-index: 9999;
    animation: menuFade 0.15s ease;
}

.action-menu.open .action-menu-list {
    display: block;
}

.action-menu-list a,
.action-menu-list button {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    text-align: left;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
}

.action-menu-list a:hover,
.action-menu-list button:hover {
    background: #f3f6fb;
}

.action-menu-list .danger {
    color: #b42318;
}

.action-menu-list form {
    margin: 0;
}

.menu-rename-form {
    padding: 6px 0;
}

.menu-rename-form input[type="text"] {
    width: 100%;
    margin-bottom: 8px;
    padding: 9px 10px;
    border: 1px solid #ccd3db;
    border-radius: 8px;
}

.menu-note {
    padding: 9px 10px;
    font-size: 13px;
    color: var(--muted);
}

@keyframes menuFade {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   Badges / Admin UI
========================= */

.table-inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.table-inline-form select {
    padding: 8px 10px;
    border: 1px solid #ccd3db;
    border-radius: 8px;
    background: #fff;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
}

.status-active {
    background: #e7f7eb;
    color: #1c6a33;
}

.status-inactive {
    background: #fdeaea;
    color: #9c2020;
}

.admin-create-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: end;
}

.admin-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-edit-form,
.admin-password-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-edit-form input,
.admin-password-form input {
    min-width: 180px;
}

/*.audit-pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    max-width: 420px;
}

.audit-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

.audit-filter-grid select,
.audit-cleanup-form input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccd3db;
    border-radius: 8px;
    background: #fff;
}

.audit-filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.audit-cleanup-stack {
    display: grid;
    gap: 16px;
}

.audit-cleanup-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: end;
    margin-top: 12px;
}*/

.audit-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

.audit-filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.audit-cleanup-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.audit-cleanup-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
}

.audit-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.audit-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.audit-table th,
.audit-table td {
    padding: 12px 14px;
    vertical-align: top;
    text-align: left;
    border-bottom: 1px solid #d9dee7;
}

.audit-table th:nth-child(1),
.audit-table td:nth-child(1) {
    width: 160px;
}

.audit-table th:nth-child(2),
.audit-table td:nth-child(2) {
    width: 180px;
}

.audit-table th:nth-child(3),
.audit-table td:nth-child(3) {
    width: 170px;
}

.audit-table th:nth-child(4),
.audit-table td:nth-child(4) {
    width: 220px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.audit-table th:nth-child(5),
.audit-table td:nth-child(5) {
    width: 130px;
    white-space: nowrap;
}

.audit-table th:nth-child(6),
.audit-table td:nth-child(6) {
    width: auto;
}

.audit-pre {
    margin: 0;
    padding: 10px 12px;
    background: #f3f4f6;
    border: 1px solid #d8dde6;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .audit-cleanup-form {
        grid-template-columns: 1fr;
    }
}

/* =========================
   Upload / Dropzone / Queue
========================= */

.progress {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0;
}

.progress .bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
}

#upload-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.upload-dropzone {
    border: 2px dashed #cbd5f5;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

.upload-dropzone:hover {
    border-color: var(--primary);
    background: #eef4ff;
}

.upload-dropzone.dragover {
    border-color: var(--primary);
    background: #eef4ff;
}

.upload-queue {
    margin-top: 16px;
    display: grid;
    gap: 10px;
}

.upload-item {
    border: 1px solid #e4e9ef;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.upload-item-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    margin-bottom: 6px;
}

.upload-item-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-item-status {
    color: var(--muted);
    flex: 0 0 auto;
}

.upload-progress {
    height: 6px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
}

/* =========================
   Flash
========================= */

.flash-share-box {
    display: grid;
    gap: 8px;
}

.flash-share-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccd3db;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
}

.flash-share-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.flash-copy-state {
    font-size: 13px;
    color: #1c6a33;
    min-height: 18px;
}

/* =========================
   Trash
========================= */

.trash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.trash-header-left {
    flex: 1;
    min-width: 0;
}

.trash-header-right {
    flex: 0 0 auto;
}

.trash-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.trash-header-right form {
    margin: 0;
}

.trash-meta {
    margin-top: 8px;
}

.trash-list {
    display: grid;
    gap: 14px;
}

.trash-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: 14px 16px;
    border: 1px solid #e4e9ef;
    border-radius: 12px;
    background: #fff;
    overflow: visible;
}

.trash-row-main {
    min-width: 0;
    flex: 1;
}

.trash-name {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-bottom: 6px;
}

.trash-icon {
    font-size: 20px;
    line-height: 1;
    flex: 0 0 auto;
}

.trash-name-text {
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trash-meta-lines {
    display: grid;
    gap: 4px;
}

.trash-row-actions {
    flex: 0 0 auto;
    overflow: visible;
}

.inline-form {
    margin: 0;
}

/* =========================
   Toast
========================= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 220px;
    max-width: 320px;
    padding: 12px 14px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    background: #1f2937;
    color: #fff;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #166534;
}

.toast-error {
    background: #991b1b;
}

/* =========================
   Responsive
========================= */

@media (max-width: 1100px) {
    .explorer-page {
        grid-template-columns: 1fr;
    }

    .explorer-sidebar {
        position: static;
        max-height: none;
    }

    .grid.two {
        grid-template-columns: 1fr;
    }

    .item-card {
        flex-direction: column;
    }

    .item-actions {
        min-width: 100%;
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

    @media (max-width: 1000px) {
    .admin-create-grid,
    .audit-filter-grid,
    .audit-cleanup-form {
        grid-template-columns: 1fr;
    }
}

    @media (max-width: 900px) {
    .table {
        table-layout: auto;
    }

    .table th:nth-child(2),
    .table td:nth-child(2),
    .table th:nth-child(4),
    .table td:nth-child(4) {
        display: none;
    }

    .table th:nth-child(1),
    .table td:nth-child(1) {
        width: auto;
    }

    .table th:nth-child(5),
    .table td:nth-child(5) {
        width: 120px;
    }

    .explorer-header {
        flex-direction: column;
        align-items: stretch;
    }

    .explorer-header-right {
        width: 100%;
    }

    .folder-title-row {
        flex-wrap: wrap;
    }

    .trash-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .trash-header-right {
        width: 100%;
    }

    .trash-header-actions {
        justify-content: flex-start;
    }

    .trash-row {
        flex-direction: column;
    }

    .trash-row-actions {
        width: 100%;
    }

    .upload-item-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* =========================
   QR-Code
========================= */

.qr-code-container img {
    display: block;
    max-width: 220px;
    padding: 10px;
    background: #fff;
    border: 1px solid #d9e0e7;
    border-radius: 12px;
}

.qr-wrap {
    display: inline-block;
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #d9e0e7;
}

.qr-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

/* =========================
   Share / Links Styling
========================= */

.flash-share-box {
    background: #eaf6ee;
    border: 1px solid #c7e7d3;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.flash-share-input {
    width: 100%;
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #cfd8e3;
    background: #fff;
    font-size: 13px;
}

.flash-share-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.flash-copy-state {
    font-size: 12px;
    color: #16a34a;
    margin-left: 6px;
}

/* =========================
   Link Cards
========================= */

.item-card input[type="text"] {
    width: 100%;
    margin-top: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #d9e0e7;
    font-size: 12px;
    background: #f8fafc;
}

/* =========================
   Buttons verbessern
========================= */

.btn-small {
    font-size: 12px;
    padding: 5px 10px;
}

.btn-light {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #d1d9e0;
}

.btn-light:hover {
    background: #e2e8f0;
}

/* =========================
   Muted Text
========================= */

.muted.small {
    font-size: 12px;
    color: #64748b;
}