:root {
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: #222;
}

body {
    margin: 0;
    background: #f4f4f6;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #34495e;
    color: #fff;
}

.brand {
    font-weight: 600;
}

.user {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.logout {
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
}

.logout-form {
    display: inline;
    margin: 0;
}

.content {
    width: 100%;
    max-width: 1520px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
    max-width: 320px;
}

button[type="submit"] {
    background: #2980b9;
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
}

button[type="submit"]:disabled {
    background: #b0bcc6;
    color: #eef1f4;
    cursor: not-allowed;
}

/* Login-Button ausgrauen, solange E-Mail oder Passwort leer ist.
   :placeholder-shown greift bei leeren Feldern; :not(:autofill) sorgt dafÃ¼r,
   dass vom Browser (auch im Vorschau-Zustand) ausgefÃ¼llte Felder als gefÃ¼llt
   gelten, bevor der Nutzer klickt. Zwei Regeln fÃ¼r Standard- und WebKit-Pseudo. */
form:has(#loginEmail:placeholder-shown:not(:autofill)) .login-submit,
form:has(#loginPassword:placeholder-shown:not(:autofill)) .login-submit {
    background: #b0bcc6;
    color: #eef1f4;
    cursor: not-allowed;
}

form:has(#loginEmail:placeholder-shown:not(:-webkit-autofill)) .login-submit,
form:has(#loginPassword:placeholder-shown:not(:-webkit-autofill)) .login-submit {
    background: #b0bcc6;
    color: #eef1f4;
    cursor: not-allowed;
}

.error {
    color: #c0392b;
}

.grid-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

.grid {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 15px;
}

.grid th, .grid td {
    border: 1px solid #ddd;
    padding: 0 0.5rem;
    height: 23px;
    line-height: 23px;
    text-align: left;
    white-space: nowrap;
}

.grid thead th {
    background: #ecf0f1;
    font-weight: 600;
}

.grid thead th a.sort-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    white-space: nowrap;
}

.grid thead th a.sort-link:hover {
    text-decoration: underline;
}

/* Linke Spalte fixieren, wenn horizontal gescrollt werden muss.
   position: sticky wirkt nur, wenn der .grid-wrapper tatsÃ¤chlich scrollt. */
.grid th:first-child,
.grid td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    box-shadow: 1px 0 0 #ddd;
}

.grid thead th:first-child {
    z-index: 3;
    background: #ecf0f1;
}

@media (max-width: 768px) {
    .content {
        padding: 0 0.75rem;
    }

    .grid {
        font-size: 13px;
    }

    .grid th, .grid td {
        padding: 0 0.35rem;
    }
}

/* Dokumente-Spalte im Child-Grid */
.doc-button {
    cursor: pointer;
    display: inline-block;
    border: 1px solid #bdc3c7;
    background: #ecf0f1;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 13px;
    white-space: nowrap;
    text-decoration: none;
    color: inherit;
}

.doc-button:hover {
    background: #d6dbdf;
}

/* Dokumente-Seite: Grid links, Vorschau rechts (analog DocumentForm) */
.doc-page {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    min-height: 85vh;
}

.doc-page-list {
    flex: 0 0 45%;
    max-width: 45%;
    overflow: auto;
}

.doc-page-preview {
    flex: 1 1 55%;
    display: flex;
    flex-direction: column;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    overflow: hidden;
    /* Feste HÃ¶he, damit der eingebettete PDF-Viewer beim Rendern eine stabile
       HÃ¶he erhÃ¤lt und alle Seiten (mit interner Bildlaufleiste) anzeigt. */
    height: 85vh;
}

.doc-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
    flex: 0 0 auto;
}

.doc-preview-frame {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    /* Explizite HÃ¶he statt rein Flex-abgeleiteter HÃ¶he: verhindert, dass der
       PDF-Viewer bei HÃ¶he 0 initialisiert und nur die erste Seite darstellt. */
    height: 100%;
    min-height: 0;
}

.doc-name {
    word-break: break-all;
}

.doc-open {
    text-decoration: none;
    border: 1px solid #2980b9;
    color: #2980b9;
    border-radius: 4px;
    padding: 0.15rem 0.6rem;
    white-space: nowrap;
}

.doc-open:hover {
    background: #2980b9;
    color: #fff;
}

@media (max-width: 768px) {
    .doc-page {
        flex-direction: column;
    }

    .doc-page-list,
    .doc-page-preview {
        flex: 1 1 auto;
        max-width: 100%;
    }
}


/* ===== Admin-Ansicht (Main.cs-Äquivalent) ===== */
.admin-guard { padding: 2rem; }
.admin-page { display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; background: #2c3e50; color: #fff; padding: 0.5rem 1rem; }
.admin-topbar .brand { font-weight: 600; }
.admin-topbar .user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.admin-topbar .logout, .admin-menu-link-button { background: transparent; border: 1px solid #fff; color: #fff; padding: 0.15rem 0.6rem; border-radius: 4px; cursor: pointer; font: inherit; }
.admin-menu { background: #34495e; }
.admin-menu-bar { list-style: none; display: flex; margin: 0; padding: 0; }
.admin-menu-item { position: relative; }
.admin-menu-title { display: block; color: #fff; padding: 0.5rem 1rem; cursor: default; }
.admin-menu-item:hover .admin-menu-title { background: #46617c; }
.admin-submenu { list-style: none; margin: 0; padding: 0; position: absolute; top: 100%; left: 0; min-width: 240px; white-space: nowrap; background: #fff; border: 1px solid #ccc; box-shadow: 0 2px 6px rgba(0,0,0,0.2); display: none; z-index: 100; }
.admin-menu-item:hover .admin-submenu { display: block; }
.admin-submenu li a, .admin-submenu li .admin-menu-link-button { display: block; width: 100%; text-align: left; padding: 0.5rem 1rem; color: #2c3e50; text-decoration: none; border: none; background: transparent; cursor: pointer; font: inherit; }
.admin-submenu li a:hover, .admin-submenu li .admin-menu-link-button:hover { background: #eef2f6; }
.admin-submenu li.admin-submenu-separator { height: 0; padding: 0; margin: 0.35rem 0; border-top: 1px solid #d5dde5; }
.admin-content { flex: 1; padding: 1rem 1.5rem; overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; }
.admin-table th, .admin-table td { border: 1px solid #ddd; padding: 0.4rem 0.6rem; text-align: left; }
.admin-table th { background: #ecf0f1; }
.admin-table tr.selected-row td { background: #dceeff; }
/* Per-Maus veränderbare Spaltenbreiten für Tabellen */
.resizable-table {
	table-layout: fixed;
	width: auto;
	max-width: none;
}
.resizable-table th {
	position: relative;
	overflow: hidden;
	min-width: 0;
	width: 160px;
	white-space: nowrap;
	text-overflow: ellipsis;
	padding-right: 12px;
	box-sizing: border-box;
}
.resizable-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-sizing: border-box; min-width: 0; }
.resizable-table th .rz-grip {
	position: absolute;
	top: 0;
	right: 0;
	width: 10px;
	height: 100%;
	cursor: col-resize;
	user-select: none;
	z-index: 2;
	box-sizing: border-box;
	opacity: 0.35;
	transition: opacity 0.15s ease;
}
.resizable-table th .rz-grip::after {
	content: "";
	position: absolute;
	right: 2px;
	bottom: 2px;
	width: 5px;
	height: 5px;
	background:
		linear-gradient(135deg, transparent 45%, #607080 45%, #607080 60%, transparent 60%),
		linear-gradient(135deg, transparent 70%, #607080 70%, #607080 85%, transparent 85%);
}
.resizable-table th .rz-grip:hover { opacity: 1; }
.log-stacktrace
.doc-preview { margin-top: 1rem; }
.doc-preview-frame-wrap { position: relative; }
.doc-preview-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; background: rgba(255,255,255,0.85); border: 1px solid #ccc; z-index: 1; }
.admin-back { margin-bottom: 1rem; }

#navWaitOverlay { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(255,255,255,0.6); }
#navWaitOverlay.active { display: flex; align-items: center; justify-content: center; }
#navWaitOverlay .nav-wait-box { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 1.5rem 2rem; background: #fff; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.25); }
#navWaitOverlay .nav-wait-spinner { width: 40px; height: 40px; border: 4px solid #ccc; border-top-color: #0d6efd; border-radius: 50%; animation: navWaitSpin 0.8s linear infinite; }
#navWaitOverlay .nav-wait-text { font-size: 0.95rem; color: #333; }
@keyframes navWaitSpin { to { transform: rotate(360deg); } }

.modal-overlay { position: fixed; inset: 0; z-index: 2100; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; }
.modal-dialog { background: #fff; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,0.3); padding: 1.5rem; min-width: 360px; max-width: 90vw; max-height: 90vh; overflow: auto; }
.modal-dialog h2 { margin-top: 0; }

.link-button { border: none; background: transparent; color: #0d6efd; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; text-align: left; }
.link-button:hover { color: #0a58ca; }
.checkbox-group { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.5rem; }
.checkbox-group label { font-weight: normal; }
.admin-form { display: flex; flex-direction: column; gap: 0.35rem; }
.admin-form > label { font-weight: 600; margin-top: 0.35rem; }
.admin-form > input, .admin-form > select, .admin-form > textarea { width: 100%; box-sizing: border-box; }
