/* ================================================================
   ConVW – einheitliche Bedienung
   Eine Ebene über convw-style.css: Seitenkopf, Tabellen, Aktionen und
   Status sehen auf jeder Seite gleich aus und sitzen an derselben Stelle.
   ================================================================ */

/* Auf body statt :root: die Farben hängen von Variablen ab, die der helle Modus auf body.light-mode setzt */
body {
    --ux-control-height: 36px;
    --ux-search-width: 260px;
    --ux-filter-width: 190px;
    --ux-row-odd: color-mix(in srgb, var(--page-text-color) 3%, var(--card-background));
    --ux-row-even: color-mix(in srgb, var(--page-text-color) 8%, var(--card-background));
    --ux-row-hover: color-mix(in srgb, var(--primary-color) 16%, var(--card-background));
    --ux-muted: color-mix(in srgb, var(--page-text-color) 68%, transparent);
}

/* ── Seitenkopf: Titel links, dann Suche → Filter → Umschalter → "Neu" ── */
.lisorect-button-container {
    padding: 10px 16px;
    min-height: 58px;
    gap: 10px;
    flex-wrap: wrap;
}

.calendar-header {
    gap: 10px;
}

.page-heading {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: var(--ux-control-height);
    margin: 0 auto 0 0;
    padding-right: 20px;
    white-space: nowrap;
    color: var(--page-text-color);
}

.calendar-header input:not([type="checkbox"]):not([type="radio"]),
.calendar-header select,
.lisorect-button-container > input:not([type="checkbox"]):not([type="radio"]),
.lisorect-button-container > select {
    height: var(--ux-control-height);
    width: var(--ux-search-width);
    min-width: 0;
    max-width: var(--ux-search-width);
    flex: 0 0 auto;
    padding: 0 10px;
    font-size: 0.875rem;
    border: 1px solid var(--input-border-color);
    border-radius: 8px;
    background-color: var(--input-background);
    color: var(--input-text-color);
}

.calendar-header select,
.lisorect-button-container > select {
    width: var(--ux-filter-width);
    max-width: var(--ux-filter-width);
}

.calendar-header .btn,
.lisorect-button-container > .btn,
.lisorect-button-container > .btn-group > .btn {
    height: var(--ux-control-height);
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    font-size: 0.875rem;
    border-radius: 8px;
    white-space: nowrap;
}

.calendar-header .btn-group > .btn:not(:last-child),
.lisorect-button-container > .btn-group > .btn:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.calendar-header .btn-group > .btn:not(:first-child),
.lisorect-button-container > .btn-group > .btn:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ── Tabellen ─────────────────────────────────────────────────────── */
.lisorect-table th,
.lisorect-table td {
    padding: 9px 12px;
    vertical-align: middle;
}

.lisorect-table thead th {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.lisorect-table tbody tr:nth-child(odd) {
    background-color: var(--ux-row-odd);
}

.lisorect-table tbody tr:nth-child(even) {
    background-color: var(--ux-row-even);
}

.lisorect-table tbody tr:hover {
    background-color: var(--ux-row-hover);
}

.lisorect-table tbody tr {
    border-bottom: 1px solid color-mix(in srgb, var(--page-text-color) 8%, transparent);
}

/* Formularzeilen (Bearbeiten/Neu) sind keine Listenzeilen */
.lisorect-table tbody tr.row-edit-form,
.lisorect-table tbody tr.row-edit-form:hover {
    background-color: color-mix(in srgb, var(--primary-color) 7%, var(--card-background));
    cursor: default;
}

/* Aktionsspalte: immer rechts, Knöpfe gleich groß und mit Abstand */
.lisorect-table td:last-child:has(> .btn):not([colspan]) {
    text-align: right;
    white-space: nowrap;
}

.lisorect-table td > .btn,
.lisorect-table td > a.btn {
    height: 30px;
    min-width: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border-radius: 6px;
}

.lisorect-table td > .btn + .btn {
    margin-left: 6px;
}

/* ── Status: Anzeige (Pille) getrennt von der Aktion (Knopf) ──────── */
.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill--open { background: #f0a040; color: #1a1a1a; }
.status-pill--done { background: #2f9e5b; color: #fff; }
.status-pill--overdue { background: #e5484d; color: #fff; }

/* Arbeitsschritt-Nummer: wichtig, daher groß und in voller Schriftfarbe (hell: schwarz) */
.row-number {
    font-size: 1.05rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    color: var(--page-text-color);
}

/* ── Lesbarkeit: kein Grau auf Grau ───────────────────────────────── */
.text-muted {
    color: var(--ux-muted) !important;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.55;
}

.overdue-cell {
    color: #ff6b6f;
    font-weight: 600;
}

/* Tabellen in den Bereichen der Liegenschaft (Bootstrap .table): gleiche Knöpfe und Abstände */
.detail-section .table th,
.detail-section .table td {
    padding: 9px 12px;
    vertical-align: middle;
}

.table td > .btn,
.table td > a.btn {
    height: 30px;
    min-width: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border-radius: 6px;
}

.table td > .btn + .btn {
    margin-left: 6px;
}

.table td:last-child:has(> .btn):not([colspan]) {
    text-align: right;
    white-space: nowrap;
}

/* ── Reiter nach Zustand (Bereichsseiten) ─────────────────────────────── */
.status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-background);
}

.status-tab {
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--page-text-color);
    font-size: 0.875rem;
    white-space: nowrap;
    cursor: pointer;
}

    .status-tab:hover {
        border-color: var(--primary-color);
    }

.status-tab--active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--primary-text-color);
    font-weight: 600;
}

.status-tab-count {
    display: inline-block;
    min-width: 20px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    background: color-mix(in srgb, var(--page-text-color) 16%, transparent);
}

.status-tab--urgent .status-tab-count {
    background: #e5484d;
    color: #fff;
}

/* ── Zuletzt bearbeitete Zeile ────────────────────────────────────────────
   Bleibende Markierung (Balken links, leichte Tönung) und ein kurzes Aufleuchten
   nach dem Schließen des Bearbeitungsfensters: "das war der Schritt". */
tr.row-last-edited > td {
    box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--primary-color, #36b2a6) 13%, transparent);
}

tr.row-last-edited > td:first-child {
    box-shadow: inset 5px 0 0 var(--primary-color, #36b2a6),
                inset 0 0 0 999px color-mix(in srgb, var(--primary-color, #36b2a6) 13%, transparent);
}

tr.row-flash > td {
    animation: row-flash 2.6s ease-out;
}

@keyframes row-flash {
    0%, 20% { background-color: color-mix(in srgb, var(--primary-color, #36b2a6) 55%, transparent); }
    100%    { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    tr.row-flash > td { animation: none; }
}

/* ══ Einheitliches Bearbeitungsfenster (EditDialog) ═══════════════════════
   Über der Liste, unter den Rückfragen (ConfirmDialog 1200). */
.ux-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: rgba(10, 14, 12, 0.55);
    cursor: default;
    text-align: left;
    font-weight: normal;
}

.ux-dialog {
    display: flex;
    flex-direction: column;
    width: min(760px, 100%);
    max-height: 100%;
    border-radius: 14px;
    border: 1px solid var(--border-color, #d0d0d0);
    border-top: 4px solid var(--primary-color, #36b2a6);
    background: var(--card-background, #fff);
    color: var(--page-text-color, #1a1a1a);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.ux-dialog--wide {
    width: min(1280px, 100%);
}

.ux-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px 8px 20px;
    border-bottom: 1px solid var(--border-color, #d0d0d0);
}

.ux-dialog-titles {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 14px;
    min-width: 0;
}

.ux-dialog-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.ux-dialog-number {
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ux-dialog-sub {
    font-size: 0.95rem;
    opacity: 0.75;
}

.ux-dialog-close {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1.8rem;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.6;
    cursor: pointer;
}

    .ux-dialog-close:hover { opacity: 1; }

/* Nur der Inhalt scrollt */
.ux-dialog-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 20px;
}

/* Knöpfe ganz unten, immer sichtbar: links Löschen, rechts Abbrechen/Speichern */
.ux-dialog-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-top: 1px solid var(--border-color, #d0d0d0);
}

.ux-dialog-foot .ux-dialog-spacer,
.ux-dialog-foot .form-error-inline {
    flex: 1;
    min-width: 0;
}

/* Formularfelder im Fenster untereinander statt in einer langen Zeile */
.ux-dialog-body .lisorect-form-row {
    flex-wrap: wrap;
    align-items: flex-end;
}

.ux-dialog-body .form-group {
    margin-bottom: 0;
}

@media (max-width: 700px) {
    .ux-dialog-backdrop { padding: 0; }
    .ux-dialog { height: 100%; border-radius: 0; }
    .ux-dialog-body { padding: 10px 12px; }
    .ux-dialog-foot { padding: 10px 12px; }
}

/* ══ Bestätigung nach Speichern/Löschen (FeedbackHost) ════════════════════ */
.ux-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 1150;
    display: flex;
    align-items: baseline;
    gap: 7px;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--border-color, #d0d0d0);
    border-left: 5px solid #2f9e5b;
    background: var(--card-background, #fff);
    color: var(--page-text-color, #1a1a1a);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: ux-toast 4s ease-out forwards;
}

.ux-toast--deleted { border-left-color: #e5484d; }
.ux-toast-icon { font-weight: 800; color: #2f9e5b; }
.ux-toast--deleted .ux-toast-icon { color: #e5484d; }

.ux-toast-number {
    font-size: 1.1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ux-toast-detail { opacity: 0.75; }

@keyframes ux-toast {
    0%   { opacity: 0; transform: translate(-50%, 12px); }
    8%   { opacity: 1; transform: translate(-50%, 0); }
    85%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 0); }
}

/* Aufleuchten über convwUx.markEdited (zwei gleiche Animationen zum Neustarten) */
@keyframes ux-row-flash-a {
    0%, 20% { background-color: color-mix(in srgb, var(--primary-color, #36b2a6) 55%, transparent); }
    100%    { background-color: transparent; }
}

@keyframes ux-row-flash-b {
    0%, 20% { background-color: color-mix(in srgb, var(--primary-color, #36b2a6) 55%, transparent); }
    100%    { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .ux-toast { animation: none; }
}

.ux-dialog-body--flush {
    padding: 8px 16px 0;
}

/* Raster für Formulare im Fenster: 4 Spalten, auf schmalen Bildschirmen untereinander */
.ux-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 14px;
    align-items: end;
}

.ux-form-grid .ux-span-2 { grid-column: span 2; }
.ux-form-grid .ux-span-3 { grid-column: span 3; }
.ux-form-grid .ux-span-all { grid-column: 1 / -1; }

@media (max-width: 700px) {
    .ux-form-grid { grid-template-columns: minmax(0, 1fr); }
    .ux-form-grid .ux-span-2,
    .ux-form-grid .ux-span-3 { grid-column: 1 / -1; }
}

.ux-checks {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    min-height: 38px;
}

.ux-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    margin: 0;
}
