/* ===== Basis-Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    background-color: #f5f5f5;
    color: #212121;
}

/* ===== Header / TitleBar ===== */
.app-header {
    background: linear-gradient(to right, #00597d, #db0625);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.app-header img.logo {
    height: 36px;
    width: 36px;
    border-radius: 50%;
    cursor: pointer;
    background: white;
    padding: 3px;
    object-fit: contain;
}

/* ===== Main-Content ===== */
.content-area {
    padding: 16px;
    overflow-y: auto;
}

/* ===== Cards / Borders ===== */
.card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #e8e8e8;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.btn:hover { background: #d4d4d4; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: #00597d;
    color: white;
    border-color: #004d6b;
}
.btn-primary:hover { background: #004d6b; }

.btn-danger {
    background: #db0625;
    color: white;
    border-color: #b5051e;
}
.btn-danger:hover { background: #b5051e; }

/* ===== Footer-Leiste ===== */
.footer-bar {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== Formulare ===== */
.form-label {
    font-weight: 600;
    display: block;
    margin-top: 10px;
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}

.form-input:focus {
    outline: none;
    border-color: #00597d;
    box-shadow: 0 0 0 2px rgba(0,89,125,0.2);
}

.form-input.input-error {
    border-color: #db0625;
    background: rgba(219, 6, 37, 0.06);
}

.form-input.input-error:focus {
    border-color: #db0625;
    box-shadow: 0 0 0 2px rgba(219,6,37,0.2);
}

.input-hint-error {
    font-size: 11px;
    color: #db0625;
    margin-top: 4px;
}

/* ===== Floating Label Field ===== */
.form-field {
    position: relative;
    margin-top: 16px;
}

.form-field input.form-input {
    padding-top: 22px;
    padding-bottom: 6px;
}

.form-field label {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #999;
    font-weight: normal;
    pointer-events: none;
    transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 20px);
    margin: 0;
}

.form-field input.form-input:focus ~ label,
.form-field input.form-input:not(:placeholder-shown) ~ label {
    top: 8px;
    transform: none;
    font-size: 11px;
    color: #00597d;
    font-weight: 600;
}

.form-field input[type="date"].form-input ~ label {
    top: 8px;
    transform: none;
    font-size: 11px;
    font-weight: 600;
    color: #999;
}

.form-field input[type="date"].form-input:focus ~ label {
    color: #00597d;
}

/* ===== Checkbox-Zeile ===== */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    cursor: pointer;
}

/* ===== Input Group ===== */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-field {
    flex: 1;
    min-width: 0;
    margin-top: 0;
}

.input-group .form-input {
    border-radius: 5px 0 0 5px;
}

.input-group-addon {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-left: none;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    user-select: none;
}

.input-group-addon:hover { background: #e4e4e4; }

/* ===== Spezialrechte-Tabelle ===== */
.rechte-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}

.rechte-table th {
    text-align: center;
    padding: 6px 8px;
    background: #f0f0f0;
    border-bottom: 2px solid #ccc;
    font-weight: 600;
}

.rechte-table th:first-child { text-align: left; }

.rechte-table th.clickable {
    cursor: pointer;
    user-select: none;
}

.rechte-table th.clickable:hover {
    background: #d8e8f0;
    text-decoration: underline;
}

.rechte-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #eee;
    text-align: center;
    vertical-align: middle;
    height: 38px;
}

.rechte-table td:first-child { text-align: left; font-weight: 500; }

.rechte-table tr:hover td { background: #f9f9f9; }

/* ===== Spinner ===== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(0,89,125,0.25);
    border-top-color: #00597d;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Dialog-Overlay ===== */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.dialog-box {
    background: white;
    border-radius: 8px;
    padding: 24px 28px;
    min-width: 320px;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.dialog-box h5 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #00597d;
}

.dialog-box p {
    margin: 0 0 20px 0;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    line-height: 1.5;
}

.dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== Blazor Error UI ===== */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ===== API-Keys Tabelle ===== */
.apikeys-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.apikeys-table thead {
    background: #f0f0f0;
}

.apikeys-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.apikeys-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.apikeys-table th.sortable:hover {
    background: #d8e8f0;
}

.apikeys-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.apikeys-table tbody tr:last-child td {
    border-bottom: none;
}

.apikeys-table tbody tr:hover td {
    background: #f5f9fc;
}

.apikeys-table tbody tr.row-expired td {
    background: #fde8eb;
}

.apikeys-table tbody tr.row-expired:hover td {
    background: #fad5da;
}

.apikeys-table td.column-expired {
    background: #fde8eb;
    color: #b5051e;
    font-weight: 500;
}

.apikeys-table tbody tr:hover td.column-expired {
    background: #fad5da;
}

.sort-icon {
    font-size: 11px;
    color: #00597d;
}

/* ===== Aktions-Links ===== */
.action-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.action-links a {
    color: #00597d;
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.action-links a:hover {
    text-decoration: underline;
}

.action-links a.link-danger {
    color: #db0625;
}

/* ===== Dark-Mode-Toggle ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 4px 8px;
    border-radius: 50%;
    line-height: 1;
    color: white;
    opacity: 0.85;
    transition: opacity 0.15s, background 0.15s;
    flex-shrink: 0;
}

.btn-theme-toggle:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

/* ===== Dark Mode ===== */
body.dark {
    background-color: #1e1e1e;
    color: #d4d4d4;
}

body.dark .card {
    background: #252526;
    border-color: #3e3e42;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

body.dark .btn {
    background: #3c3c3c;
    border-color: #555;
    color: #d4d4d4;
}

body.dark .btn:hover { background: #4a4a4a; }

body.dark .btn-primary {
    background: #00597d;
    color: white;
    border-color: #004d6b;
}

body.dark .btn-primary:hover { background: #004d6b; }

body.dark .btn-danger {
    background: rgba(255, 107, 128, 0.12);
    color: #ff6b80;
    border-color: rgba(255, 107, 128, 0.45);
}

body.dark .btn-danger:hover {
    background: rgba(255, 107, 128, 0.22);
    border-color: #ff6b80;
}

body.dark .footer-bar {
    background: #252526;
    border-top-color: #3e3e42;
}

body.dark .form-input {
    background: #2d2d2d;
    border-color: #555;
    color: #d4d4d4;
}

body.dark .form-input:focus {
    border-color: #00597d;
    box-shadow: 0 0 0 2px rgba(0,89,125,0.4);
}

body.dark .form-input.input-error {
    border-color: #db0625;
    background: rgba(219,6,37,0.15);
}

body.dark .form-field label { color: #777; }

body.dark .form-field input.form-input:focus ~ label,
body.dark .form-field input.form-input:not(:placeholder-shown) ~ label {
    color: #4db8d4;
}

body.dark .input-group-addon {
    background: #3c3c3c;
    border-color: #555;
    color: #d4d4d4;
}

body.dark .input-group-addon:hover { background: #4a4a4a; }

body.dark .rechte-table th {
    background: #2d2d2d;
    border-bottom-color: #555;
    color: #d4d4d4;
}

body.dark .rechte-table th.clickable:hover { background: #1e3040; }

body.dark .rechte-table td { border-bottom-color: #3e3e42; }

body.dark .rechte-table tr:hover td { background: #2a2a2a; }

body.dark .dialog-box {
    background: #252526;
    color: #d4d4d4;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

body.dark .dialog-box h5 { color: #4db8d4; }

body.dark .apikeys-table {
    background: #252526;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

body.dark .apikeys-table thead { background: #2d2d2d; }

body.dark .apikeys-table th {
    border-bottom-color: #555;
    color: #d4d4d4;
}

body.dark .apikeys-table th.sortable:hover { background: #1e3040; }

body.dark .apikeys-table td { border-bottom-color: #3e3e42; }

body.dark .apikeys-table tbody tr:hover td { background: #2a3a4a; }

body.dark .apikeys-table tbody tr.row-expired td { background: #3a1520; }

body.dark .apikeys-table tbody tr.row-expired:hover td { background: #4a1c28; }

body.dark .apikeys-table td.column-expired {
    background: #3a1520;
    color: #ff6b80;
}

body.dark .apikeys-table tbody tr:hover td.column-expired { background: #4a1c28; }

body.dark .sort-icon { color: #4db8d4; }

body.dark .action-links a { color: #4db8d4; }

body.dark .action-links a.link-danger { color: #ff6b80; }
