/*
 * Runde 32: Zur Zahlung bereit (eine Wahrheit), Freigabeschleife mit fester Leiste, Hinweisblock, Dashboard und Handy-Liste.
 *
 * Copyright © Fabian Stamminger @ The Platform Group
 */

/* ---- Dashboard "Als Nächstes": nur freigegebene Zeilen haben einen Zahlungsknopf, sonst öffnet die ganze Zeile den Beleg ---- */
.dash-next-item.is-open { display: block; padding: 0; }
.dash-next-open { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .5rem 0; min-height: 44px; color: inherit; text-decoration: none; }
.dash-next-open:hover .dash-next-vendor { text-decoration: underline; }
.dash-next-open:focus-visible { outline: 2px solid #0E1115; outline-offset: 2px; border-radius: 6px; }
@media (max-width: 640px) { .dash-next-open { grid-template-columns: minmax(0, 1fr) auto; } .dash-next-open .dash-next-due { grid-column: 1 / -1; } }
.pay-empty-stages { margin-top: .25rem; }

/* ---- Freigabeschleife: eine feste Leiste (Lieferant und Betrag links, eine Hauptaktion rechts), "Mehr" auch am Desktop ---- */
.doc-review-nav .btn-icon-quick { min-width: 44px; min-height: 44px; }
.doc-bar-more { display: contents; }
.doc-detail-actionbar .doc-save-state { flex: none; overflow: visible; text-overflow: clip; max-width: none; white-space: nowrap; }
.doc-detail-actionbar .doc-save-state i { color: #1E7B4F; margin-right: .25rem; }
.doc-detail-actionbar .doc-save-state[data-kind="error"] i, .doc-detail-actionbar .doc-save-state[data-kind="saving"] i, .doc-detail-actionbar .doc-save-state[data-kind="pending"] i { display: none; }
#documentDetailModal .doc-detail-actionbar.has-decision { gap: 12px; }
@media (min-width: 768px) {
  #documentDetailModal .doc-detail-actionbar.has-decision .doc-bar-summary { display: block; order: -1; flex: 1 1 0; min-width: 0; font-weight: 700; font-size: 1rem; color: #0E1115; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #documentDetailModal .doc-detail-actionbar.has-decision .doc-bar-summary:empty { display: none; }
  #documentDetailModal .doc-bar-more { display: inline-flex; position: relative; }
  #documentDetailModal .doc-detail-more { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-width: 44px; padding: 0; font-size: 0; }
  #documentDetailModal .doc-detail-more i { font-size: 1.125rem; margin: 0; }
  #documentDetailModal .doc-detail-more-menu { display: block; position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 8; min-width: 220px; padding: .25rem; background: #fff; border: 1px solid #D8DCE4; border-radius: 12px; box-shadow: 0 12px 32px rgba(14, 17, 21, .18); }
  #documentDetailModal .doc-detail-more-menu[hidden] { display: none; }
}
@media (max-width: 767px) {
  #documentDetailModal .doc-detail-actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid #D8DCE4; }
  #documentDetailModal .doc-page-body { padding-bottom: 120px; }
  #documentDetailModal .doc-bar-more { display: contents; }
}

/* ---- Hinweisblock "Das fehlt noch" (R32-03) ---- */
.issue-block { margin: 0 0 16px; padding: 16px; background: #fff; border: 1px solid #D8DCE4; border-left: 4px solid #B45309; border-radius: 12px; box-shadow: 0 1px 2px rgba(14, 17, 21, .06); }
.issue-head { margin: 0 0 8px; font-size: 1rem; font-weight: 900; letter-spacing: -.01em; color: #0E1115; display: flex; align-items: center; gap: 8px; }
.issue-head i { color: #B45309; }
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.issue-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #D8DCE4; }
.issue-item:first-child { border-top: 0; }
.issue-text { font-size: .9375rem; color: #333840; min-width: 0; }
.issue-item .doc-warn-btn { flex: none; min-height: 44px; }
@media (max-width: 767px) { .issue-item { flex-direction: column; align-items: stretch; } .issue-item .doc-warn-btn { width: 100%; } }

/* ---- Dashboard: "Zuletzt hochgeladen" auch unter 1440 px, dort drei kompakte Zeilen ---- */
.dash-recent { display: block; }
.dash-recent-more { font-weight: 400; color: var(--orlop-muted-text, #565C67); font-size: .8125rem; }
@media (max-width: 1439px) { #dashRecentList .dash-recent-item:nth-child(n+4) { display: none; } }
#dashboardRecent .dash-waiting-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: nowrap; }
#dashboardRecent .dash-waiting-head .btn-textlink { white-space: nowrap; flex: none; }

/* ---- R32 Nacharbeit: Handy-Leiste mit Lieferant und Betrag, Titel bricht um (D-1603) ---- */
@media (max-width: 767px) {
  #documentDetailModal .doc-detail-actionbar.has-decision { flex-wrap: wrap; }
  #documentDetailModal .doc-detail-actionbar.has-decision #docBarSummary { display: block; flex: 1 1 100%; order: -1; min-width: 0; font-weight: 700; font-size: .9375rem; color: #0E1115; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #documentDetailModal .doc-detail-actionbar.has-decision #docBarSummary:empty { display: none; }
  #documentDetailModal .doc-page-head .doc-detail-title { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
}

/* ---- R33: Titel, Split-Button, Lesemodus, Meldungen ---- */
.doc-title-nr { white-space: nowrap; }
.doc-page-head .doc-detail-title { overflow-wrap: break-word; }
@media (max-width: 767px) { #documentDetailModal .doc-page-head .doc-detail-title { overflow-wrap: break-word; } }
.approve-group { position: relative; display: inline-flex; align-items: stretch; }
.approve-group.has-split .doc-approve-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.approve-caret { min-width: 44px; min-height: 44px; padding: 0 12px; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255, 255, 255, .28); }
.stage-menu { position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 30; margin: 0; padding: 6px; list-style: none; min-width: 300px; max-width: min(92vw, 380px); background: #fff; border: 1px solid #D8DCE4; border-radius: 12px; box-shadow: 0 8px 24px rgba(14, 17, 21, .16); outline: none; }
.stage-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: grid; gap: 2px; min-height: 44px; color: #0E1115; }
.stage-item.is-active { background: #F5F6F8; box-shadow: inset 0 0 0 2px #0E1115; }
.stage-item.is-locked { cursor: default; color: var(--orlop-muted-text, #565C67); }
.stage-label { font-weight: 700; font-size: .9375rem; }
.stage-sub { font-size: .8125rem; color: var(--orlop-muted-text, #565C67); }
.stage-why { color: #6B3F00; }
.stage-confirm { position: fixed; inset: 0; z-index: 1400; background: rgba(14, 17, 21, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.stage-confirm-box { background: #fff; border-radius: 16px; padding: 20px; max-width: 420px; width: 100%; box-shadow: 0 12px 40px rgba(14, 17, 21, .3); }
.stage-confirm-box h2 { margin: 0 0 8px; font-size: 1.125rem; font-weight: 900; letter-spacing: -.01em; }
.stage-confirm-box p { margin: 0 0 16px; color: #333840; font-size: .9375rem; }
.stage-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.stage-confirm-actions button { min-height: 44px; }
.doc-wait-line { font-weight: 700; color: #0E1115; font-size: .9375rem; }
.doc-remind-btn { min-height: 36px; margin-left: 8px; }
html { scroll-padding-bottom: calc(var(--bar-h, 0px) + env(safe-area-inset-bottom, 0px) + 16px); }
.toast-say { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { .stage-menu, .stage-confirm { transition: none; animation: none; } }

/* ---- R33-04: Fehlerzustand im Dashboard ohne leere Karten, Banner mit Titel und Code ---- */
.stats-error-body { display: grid; gap: 2px; min-width: 0; }
.stats-error-title { font-weight: 900; color: #0E1115; letter-spacing: -.01em; }
.stats-error-code { justify-self: start; min-height: 24px; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.dash-error #dashboardRecent { display: none; }
@media (pointer: coarse) { .stats-error-code { min-height: 44px; } }

/* ---- R33-06: ein zentraler Fokusring für alle bedienbaren Elemente ---- */
:focus-visible { outline: 2px solid #0E1115; outline-offset: 2px; }

/* ---- R33 Nacharbeit: Lesemodus am Handy zeigt Wartezeile und Erinnern (D-1648) ---- */
@media (max-width: 767px) {
  #documentDetailModal .doc-detail-actionbar.is-readonly .doc-bar-left { display: flex !important; flex: 1 1 100%; flex-wrap: wrap; gap: 8px; width: 100%; order: 0; }
  #documentDetailModal .doc-detail-actionbar.is-readonly .doc-wait-line { flex: 1 1 100%; white-space: normal; }
  #documentDetailModal .doc-detail-actionbar.is-readonly .doc-remind-btn { min-height: 44px; margin-left: 0; flex: 1 1 0; }
  #documentDetailModal .doc-detail-actionbar.is-readonly .doc-bar-right { grid-template-columns: 1fr; }
  #documentDetailModal .doc-page-sub #docHeadStatus { white-space: normal; overflow: visible; text-overflow: clip; max-width: 100%; }
}

/* ---- R33 Nacharbeit: Zahlungen, ein SEPA-Auslöser, Auswahlleiste verdeckt die Fußzeile nicht (D-1649) ---- */
.pay-head-actions [hidden] { display: none !important; }
.pay-selbar-clear { min-height: 44px; padding: 0 8px; }
@media (min-width: 768px) {
  .pay-selbar { position: sticky; left: auto; transform: none; bottom: 16px; width: fit-content; margin: 16px auto 0; }
}
#docHeadStatus { font-size: 13px; }
