/* Dashboard (dashboard.html): Navigation, Übersicht, Listen, Formulare, Löschen-Rückfrage.
   Mobil zuerst: Das Dashboard soll auch auf dem Handy bedienbar sein. */

.dash-header {
    padding-bottom: 0.75rem;
}

/* Bereichsmenü: umbrechende Reihe von Knöpfen */
.dash-nav {
    display: flex;
    gap: 0.4rem;
    max-width: 1100px;
    margin: 0.5rem auto 0;
    padding: 0 0.75rem 0.25rem;
    overflow-x: auto;               /* eine Zeile, seitlich wischbar */
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.dash-nav a {
    flex: none;
    scroll-snap-align: start;
    white-space: nowrap;
}

.dash-nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-size);
    padding: 0 0.9rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.9rem;
    text-decoration: none;
}

.dash-nav a:hover {
    background: rgba(255, 255, 255, 0.22);
}

.dash-nav a[aria-current="page"] {
    background: #fff;
    color: var(--color-primary);
    font-weight: bold;
}

.dash-main {
    max-width: 900px;
}

.dash-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
}

.dash-title h2 {
    font-size: 1.4rem;
}

.dash-title h2:focus {
    outline: none;
}

.count-note {
    font-size: 0.95rem;
    font-weight: normal;
    color: var(--color-muted);
}

/* ---------- Übersicht ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: block;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--color-card);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--color-primary);
}

.check-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    list-style: none;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 52px;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    background: var(--color-card);
    border-left: 5px solid var(--color-chip-border);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
}

.check-item.todo {
    border-left-color: #6f42c1;
}

.check-item.warn {
    border-left-color: #c4701f;
}

.check-item strong {
    min-width: 2rem;
}

/* ---------- Filterleiste und Liste ---------- */

.dash-filter {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dash-filter > div:first-child,
.dash-filter > button {
    grid-column: 1 / -1;            /* Suche und "Zurücksetzen" über die ganze Breite */
}

.dash-filter label {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.dash-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.6rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    background: var(--color-card);
    box-shadow: var(--shadow);
}

.dash-row.no-select {
    grid-template-columns: 1fr;
}

.dash-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-height: 0;
    margin-top: 0.2rem;
}

.dash-row-title {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-size); /* ausreichend große Tippfläche */
    font-weight: bold;
    color: var(--color-primary);
    text-decoration: none;
}

.dash-row-title:hover {
    text-decoration: underline;
}

.dash-row-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin-top: 0.25rem;
    font-size: 0.82rem;
    color: var(--color-muted);
}

.dash-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.dash-row-actions button,
.dash-row-actions .button-link {
    min-height: var(--tap-size);
    font-size: 0.85rem;
}

.status-badge {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: bold;
}

.status-badge.draft {
    background: #f3e5f5;
    color: #6a1b9a;
}

.status-badge.active {
    background: #e8f5e9;
    color: #1b5e20;
}

.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: var(--color-chip);
}

.bulk-bar label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--tap-size);
    cursor: pointer;
}

.bulk-bar input {
    width: 22px;
    height: 22px;
    min-height: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pagination button:disabled {
    visibility: hidden;
}

/* ---------- Formular ---------- */

.dash-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--color-card);
    box-shadow: var(--shadow);
}

.field label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: bold;
    font-size: 0.95rem;
}

.field .required-mark {
    color: #b02a37;
}

.field-help {
    margin-top: 0.3rem;
    font-size: 0.82rem;
    color: var(--color-muted);
}

.field-error {
    margin-top: 0.3rem;
    font-size: 0.88rem;
    font-weight: bold;
    color: #b02a37;
}

.field-error:empty {
    display: none;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
    border-color: #b02a37;
    border-width: 2px;
}

textarea.code-input {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9rem;
    white-space: pre;
    overflow-x: auto;
}

.image-preview {
    display: block;
    max-width: 100%;
    max-height: 220px;
    margin: 0.5rem 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    object-fit: contain;
}

.form-error-summary {
    padding: 0.7rem 0.9rem;
    border: 1px solid #f1aeb5;
    border-radius: 6px;
    background: #f8d7da;
    color: #842029;
    font-size: 0.92rem;
}

/* Aktionsleiste: auf dem Handy am unteren Rand angeheftet, damit "Speichern" immer erreichbar ist */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    position: sticky;
    bottom: 0;
    margin: 0 -1rem -1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #e3e7eb;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--color-card);
}

.form-actions .push-right {
    margin-left: auto;
}

/* Auf dem Handy teilen sich die Hauptknöpfe eine Zeile; "weiteres anlegen" gibt es nur am Rechner */
.form-actions > * {
    flex: 1 1 auto;
}

#saveNewBtn {
    display: none;
}

.danger-btn {
    background-color: #b02a37;
}

.danger-btn:hover {
    background-color: #8f1f2b;
}

/* ---------- KI-Fragen ---------- */

.ai-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-result {
    padding: 0.8rem 1rem;
    border-radius: 6px;
    background: #f3e5f5;
    color: #4a148c;
}

/* ---------- Löschen-Rückfrage ---------- */

.confirm-dialog {
    width: min(92vw, 30rem);
    margin: auto;
    padding: 1.25rem;
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.confirm-dialog h2 {
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
}

.impact-list {
    margin: 0.5rem 0 0 1.25rem;
}

.impact-warning {
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #5d4a00;
    font-size: 0.92rem;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ---------- Meldung ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 200;
    max-width: min(92vw, 30rem);
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius);
    background: #1b5e20;
    color: #fff;
    box-shadow: var(--shadow-hover);
    transform: translateX(-50%);
}

.toast.is-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

.toast.is-error {
    background: #842029;
}

@media (min-width: 700px) {
    .dash-nav {
        flex-wrap: wrap;
        justify-content: center;
        overflow-x: visible;
    }

    .dash-filter {
        grid-template-columns: 2fr repeat(auto-fit, minmax(10rem, 1fr));
        align-items: end;
    }

    .dash-filter > div:first-child,
    .dash-filter > button {
        grid-column: auto;
    }

    .dash-form {
        padding: 1.5rem;
    }

    .form-actions {
        position: static;
        margin: 0;
        padding: 0.5rem 0 0;
        border: none;
    }

    .form-actions > * {
        flex: 0 0 auto;
    }

    #saveNewBtn {
        display: inline-flex;
    }
}

/* ---------- Hilfe (#/hilfe, Text in dashboard-hilfe.html) ---------- */

.dash-help {
    max-width: 60rem;
}

.dash-help > p {
    margin-bottom: 1rem;
}

.dash-help details {
    margin: 0.75rem 0;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dash-help summary {
    padding: 0.8rem 1rem;
    min-height: var(--tap-size);
    font-weight: 600;
    cursor: pointer;
}

.dash-help details[open] > summary {
    border-bottom: 1px solid var(--color-border);
}

.dash-help details > *:not(summary) {
    margin-left: 1rem;
    margin-right: 1rem;
}

.dash-help details > summary + * {
    margin-top: 0.8rem;
}

.dash-help details > :last-child {
    margin-bottom: 1rem;
}

.dash-help p,
.dash-help ul,
.dash-help ol {
    margin-bottom: 0.7rem;
}

.dash-help ul,
.dash-help ol {
    padding-left: 1.4rem;
}

.dash-help li {
    margin: 0.3rem 0;
}

.dash-help h4 {
    margin: 1.1rem 1rem 0.4rem;
}

.dash-help pre {
    overflow-x: auto;
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
    background: #F5F3F0;
    color: var(--color-text);
    border: 1px solid #DBCEC3;
    font-size: 0.9rem;
}

.dash-help code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.9em;
}

.dash-help :not(pre) > code {
    padding: 0.05rem 0.35rem;
    border-radius: 4px;
    background: var(--color-chip);
}

.help-table-wrap {
    overflow-x: auto;
}

.dash-help table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.dash-help th,
.dash-help td {
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.dash-help thead th {
    background: var(--color-chip);
}

.dash-help tbody th {
    white-space: nowrap;
}

/* Löschen in der Liste: roter Rand und rote Schrift, damit es nicht mit "Bearbeiten" verwechselt wird */
.secondary-btn[data-delete] {
    color: var(--color-danger);
    border-color: var(--color-danger);
}

.secondary-btn[data-delete]:hover {
    background-color: #FBEAE8;
}
