/*
 * NhPanel – Finanzen & Support (Rechnungen, Offene Posten, Guthaben, Bestellungen, Tickets).
 * Wird auf allen Kontoseiten geladen – daher alles unter .nh-shell-page (ohne Shell keine Wirkung).
 * Nur vorhandene Tokens/Komponenten aus panel.css (--nh-*, .nh-status, .nh-cell-*); keine Animationen.
 */

/* ---------- Allgemein ---------- */

.nh-shell-page .nh-text-danger { color: var(--nh-danger-ink) !important; }

.nh-shell-page .nh-cell-stack { display: block; min-width: 0; }
.nh-shell-page .nh-cell-line { display: block; line-height: 1.4; }
.nh-shell-page .nh-cell-line + .nh-cell-line { margin-top: 2px; }

/* Aktionen in Tabellenzeilen */
.nh-shell-page .nh-fin-actions {
    display: inline-flex;
    flex-wrap: nowrap; /* Aktionsspalte ist 1 % breit (panel.css) – sonst stünden die Knöpfe untereinander */
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
}

.nh-shell-page .nh-fin-actions .btn { display: inline-flex; align-items: center; justify-content: center; }

/* Zeilen mit Handlungsbedarf (Antwort erhalten, überfällig): Akzentkante links + leichter Ton */
.nh-shell-page .nh-fin-table tbody tr.nh-row-attention > td { background: var(--nh-primary-tint-2); }
.nh-shell-page .nh-fin-table tbody tr.nh-row-attention > td:first-child { box-shadow: inset 3px 0 0 var(--nh-primary); }
.nh-shell-page .nh-fin-table tbody tr.nh-row-attention--danger > td { background: rgba(180, 35, 24, .035); }
.nh-shell-page .nh-fin-table tbody tr.nh-row-attention--danger > td:first-child { box-shadow: inset 3px 0 0 var(--nh-danger-ink); }

/* Zellen über alle Spalten (Leerzustand, Bestelldetails) sind auch "letzte Spalte" – nicht 1 % breit/einzeilig (panel.css) */
.nh-shell-page .nh-shell-content .nh-fin-table tbody td[colspan] { width: auto; white-space: normal; }

/* Tabellenkopf "Betrag" u. ä. rechtsbündig, wenn so markiert */
.nh-shell-page .nh-fin-table th.text-end,
.nh-shell-page .nh-fin-table td.text-end { text-align: right; }

/* ---------- Schmale Tabellen (Zeilen-Karten, Container-Query aus panel.css) ---------- */

@container nhtable (max-width: 680px) {
    /* Spaltenname links, Wert rechts in einer Zeile – auch unter 576 px (Booking stellt Zellen dort auf block) */
    .nh-shell-page .nh-shell-content .nh-fin-table tbody td { display: flex; }

    /* panel.css gibt der letzten Spalte der breiten Tabelle width: 1 % + nowrap – in der Karte wären die Aktionen
       (und Leerzustände über alle Spalten) sonst nur ~3 px breit und die Knöpfe zerquetscht */
    .nh-shell-page .nh-shell-content .nh-fin-table tbody td:last-child { width: auto; }
    .nh-shell-page .nh-shell-content .nh-fin-table tbody td:first-child { white-space: normal; }

    /* Erste Spalte = Titel der Karte: volle Breite, linksbündig, ohne Spaltenname */
    .nh-shell-page .nh-shell-content .nh-fin-table tbody td:first-child,
    .nh-shell-page .nh-fin-table tbody td:first-child {
        display: block;
        text-align: left;
        padding-bottom: 6px !important;
    }

    .nh-shell-page .nh-fin-table tbody td:first-child::before { display: none; }

    /* Zeilen-Karte: Akzent an der Karte selbst statt an der ersten Zelle */
    .nh-shell-page .nh-fin-table tbody tr.nh-row-attention { box-shadow: inset 3px 0 0 var(--nh-primary); background: var(--nh-primary-tint-2); }
    .nh-shell-page .nh-fin-table tbody tr.nh-row-attention.nh-row-attention--danger { box-shadow: inset 3px 0 0 var(--nh-danger-ink); background: rgba(180, 35, 24, .035); }
    .nh-shell-page .nh-fin-table tbody tr.nh-row-attention > td,
    .nh-shell-page .nh-fin-table tbody tr.nh-row-attention > td:first-child { background: none; box-shadow: none; }

    /* Aktionen: ohne Spaltenname "Aktionen", volle Breite, Touch-Ziele >= 44 px */
    .nh-shell-page .nh-fin-table tbody td.nh-actions-cell::before { display: none; }
    .nh-shell-page .nh-fin-table .nh-fin-actions { display: flex; flex-wrap: wrap; width: 100%; justify-content: flex-start; }
    .nh-shell-page .nh-fin-table .nh-fin-actions .btn { flex: 1 1 0; min-height: 44px; }
    .nh-shell-page .nh-fin-table .nh-detail-actions .btn { min-height: 44px; }

    /* Bestelldetails hängen an ihrer Zeile */
    .nh-shell-page .nh-orders-table tbody tr.nh-order-detail { padding-top: 0; border-top: 0; background: var(--nh-surface-2); }
    .nh-shell-page .nh-orders-table tbody tr.nh-order-row.is-open { background: var(--nh-surface-2); }
    .nh-shell-page .nh-shell-content .nh-orders-table tr.nh-order-detail > td { background: none; }
}

/* ---------- Bestellungen: Details in der Liste ---------- */

.nh-shell-page .nh-disclosure { gap: 6px; }
.nh-shell-page .nh-disclosure-icon { font-size: .85em; }
.nh-shell-page .nh-disclosure[aria-expanded="true"] .nh-disclosure-icon { transform: rotate(180deg); }

.nh-shell-page .nh-orders-table tr.nh-order-row.is-open > td { border-bottom-color: transparent !important; background: var(--nh-surface-2); }
.nh-shell-page .nh-orders-table tr.nh-order-row { scroll-margin-top: calc(var(--nh-header-offset) + 16px); }

.nh-shell-page .nh-shell-content .nh-orders-table tr.nh-order-detail > td {
    width: auto;
    padding: 4px 16px 18px;
    white-space: normal;
    background: var(--nh-surface-2);
}

.nh-shell-page .nh-orders-table tr.nh-order-detail:hover { background: none; }

.nh-shell-page .nh-order-detail-grid {
    display: grid;
    text-align: left;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px 28px;
    padding-top: 12px;
    border-top: 1px dashed var(--nh-line);
}

/* Block über die ganze Breite der Detailzeile (Stand einer Lastschrift-Bestellung, Support/DebitOrders.php) */
.nh-shell-page .nh-order-detail-grid .nh-detail-block--wide { grid-column: 1 / -1; }
.nh-shell-page .nh-shell-content .nh-detail-note { max-width: 78ch; margin: 0 0 4px; color: var(--nh-text); }

.nh-shell-page .nh-shell-content .nh-detail-title {
    margin: 0 0 8px;
    color: var(--nh-muted);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.nh-shell-page .nh-detail-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.nh-shell-page .nh-detail-list > li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
    padding: 7px 0;
    border-top: 1px solid var(--nh-line);
    color: var(--nh-text);
    overflow-wrap: anywhere;
}

.nh-shell-page .nh-detail-list > li:first-child { border-top: 0; padding-top: 0; }

/* Hostware (storefront.css) setzt vor jedes li in Tabellenzellen einer .card-table ein Pfeil-Icon
   (.card.card-table table tbody td ul li:before) – in der Detailliste wäre es ein zusätzliches Flex-Element */
.nh-shell-page .nh-fin-table .nh-detail-list > li::before { content: none; display: none; }
.nh-shell-page .nh-detail-list > li > span:first-child { min-width: 0; }
.nh-shell-page .nh-detail-list .nh-status { margin-left: 4px; }

.nh-shell-page .nh-detail-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }

.nh-shell-page .nh-detail-dl { margin: 0; }

.nh-shell-page .nh-detail-dl > div {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 12px;
    padding: 7px 0;
    border-top: 1px solid var(--nh-line);
}

.nh-shell-page .nh-detail-dl > div:first-child { border-top: 0; padding-top: 0; }
.nh-shell-page .nh-detail-dl dt { color: var(--nh-muted); font-size: .86rem; font-weight: 600; }
.nh-shell-page .nh-detail-dl dd { min-width: 0; margin: 0; color: var(--nh-ink); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.nh-shell-page .nh-detail-dl dd .nh-cell-meta { font-weight: 500; }

/* ---------- Guthaben / Offene Posten: Summe oben ---------- */

.nh-shell-page .nh-balance {
    margin: 0 0 18px;
    padding: 18px 20px;
    background: var(--nh-surface);
    border: 1px solid var(--nh-line);
    border-radius: var(--nh-radius);
}

.nh-shell-page .nh-balance-label { margin: 0; color: var(--nh-muted); font-size: .88rem; font-weight: 600; }

.nh-shell-page .nh-balance-value {
    margin: 2px 0 0;
    color: var(--nh-ink);
    font-size: 2rem;
    font-weight: 750;
    line-height: 1.15;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.nh-shell-page .nh-balance-meta { margin: 10px 0 0; color: var(--nh-muted); font-size: .9rem; }

.nh-shell-page .nh-balance-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px 20px;
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--nh-line);
}

.nh-shell-page .nh-balance-facts dt { color: var(--nh-muted); font-size: .82rem; font-weight: 600; }
.nh-shell-page .nh-balance-facts dd { margin: 2px 0 0; color: var(--nh-ink); font-weight: 650; font-variant-numeric: tabular-nums; }

@media (max-width: 575.98px) {
    .nh-shell-page .nh-balance { padding: 16px; }
    .nh-shell-page .nh-balance-value { font-size: 1.75rem; }
}

/* ---------- Ticket-Detail: Unterhaltung ---------- */

.nh-shell-page .hw-subtitle .nh-ticket-subject { overflow-wrap: anywhere; }
.nh-shell-page .hw-subtitle .nh-status { margin-left: 8px; vertical-align: 1px; }

.nh-shell-page .nh-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 16px;
    padding: 0;
    list-style: none;
}

.nh-shell-page .nh-msg {
    max-width: 88%;
    min-width: 0;
    padding: 12px 16px 14px;
    background: var(--nh-surface);
    border: 1px solid var(--nh-line);
    border-radius: 12px;
    color: var(--nh-text);
}

.nh-shell-page .nh-msg--support { margin-right: auto; border-top-left-radius: 4px; }

.nh-shell-page .nh-msg--own {
    margin-left: auto;
    background: var(--nh-primary-tint-2);
    border-color: rgba(81, 67, 217, .18);
    border-top-right-radius: 4px;
}

.nh-shell-page .nh-msg-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    margin-bottom: 6px;
}

.nh-shell-page .nh-msg-author { color: var(--nh-ink); font-size: .92rem; font-weight: 650; }
.nh-shell-page .nh-msg-author i { color: var(--nh-muted); }

.nh-shell-page .nh-msg-role {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--nh-primary-tint);
    color: var(--nh-primary-ink);
    font-size: .74rem;
    font-weight: 700;
}

.nh-shell-page .nh-msg-time { margin-left: auto; color: var(--nh-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }

.nh-shell-page .nh-msg-body { line-height: 1.55; overflow-wrap: anywhere; }
.nh-shell-page .nh-msg-body > :last-child,
.nh-shell-page .nh-msg-body p:last-child { margin-bottom: 0; }
.nh-shell-page .nh-msg-body p { margin: 0 0 .6em; }
.nh-shell-page .nh-msg-body img { max-width: 100%; height: auto; }
.nh-shell-page .nh-msg-body pre { max-width: 100%; white-space: pre-wrap; }
.nh-shell-page .nh-msg-body table { display: block; max-width: 100%; overflow-x: auto; }
.nh-shell-page .nh-msg-body a { overflow-wrap: anywhere; }

.nh-shell-page .nh-msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid var(--nh-line);
    list-style: none;
}

.nh-shell-page .nh-msg-files > li { min-width: 0; max-width: 100%; }

.nh-shell-page .nh-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--nh-line);
    border-radius: var(--nh-radius-sm);
    background: var(--nh-surface);
    color: var(--nh-primary-ink);
    font-size: .86rem;
    font-weight: 600;
    text-decoration: none;
}

.nh-shell-page .nh-msg-file:hover { border-color: rgba(81, 67, 217, .3); text-decoration: underline; text-underline-offset: 3px; }
.nh-shell-page .nh-msg-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nh-shell-page .nh-msg-file-size { flex: 0 0 auto; color: var(--nh-muted); font-weight: 500; }

.nh-shell-page .nh-thread-end { margin: 0 0 24px; }

@media (max-width: 575.98px) {
    .nh-shell-page .nh-msg { max-width: 94%; padding: 11px 13px 12px; }
    .nh-shell-page .nh-msg-file { min-height: 44px; }
    .nh-shell-page .nh-thread-end .btn { min-height: 44px; display: inline-flex; align-items: center; }
}

/* Ticket-Detail: Details-Karte (Seitenleiste) */
.nh-shell-page .nh-detail-dl--stack dd .nh-status { vertical-align: 1px; }
