/* ============================================================
   Secretary — Component styling
   Nav active state, section labels, PageHeader, ProfileMenu.
   ============================================================ */

/* -----------------------------
   NavMenu refinements
   ----------------------------- */
fluent-nav-menu {
    background: transparent !important;
    --nav-menu-collapsed-width: var(--sidebar-width-collapsed);
}

/* Section labels above grouped nav items */
.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--neutral-foreground-hint);
    padding: var(--space-4) var(--space-3) var(--space-1);
    user-select: none;
}

.app-sidebar.is-collapsed .nav-section-label {
    display: none;
}

/* Nav links — calm, rounded, accent only on active */
fluent-nav-link {
    border-radius: 8px;
    margin: 2px var(--space-2);
    transition: background-color 120ms ease;
}

fluent-nav-link:hover {
    background: var(--neutral-layer-3);
}

fluent-nav-link[aria-current="page"],
fluent-nav-link.active {
    background: var(--brand-tint);
    color: var(--accent-foreground-rest);
}

fluent-nav-link[aria-current="page"] fluent-icon,
fluent-nav-link.active fluent-icon,
fluent-nav-link[aria-current="page"] svg,
fluent-nav-link.active svg {
    color: var(--accent-fill-rest);
    fill: var(--accent-fill-rest);
}

/* Group headers */
fluent-nav-group {
    margin-top: var(--space-2);
}

fluent-nav-group::part(expander) {
    border-radius: 8px;
    margin: 2px var(--space-2);
}

/* -----------------------------
   PageHeader
   ----------------------------- */
.page-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-1) var(--space-4);
    margin: 0 0 var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}

.page-header__main {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1 1 auto;
    min-width: 0;
}

.page-header__titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.page-header__title {
    font-size: 20px !important;
    line-height: 26px !important;
    font-weight: 600 !important;
    margin: 0 !important;
}

.page-header__subtitle {
    font-size: 13px;
    color: var(--neutral-foreground-hint);
    line-height: 18px;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* -----------------------------
   EntityBreadcrumb — own row inside the PageHeader, below title/icon
   ----------------------------- */
.page-header__breadcrumb-row {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 2px;
}

.page-header__back-small {
    height: 24px;
    width: 24px;
    min-width: 24px;
    flex-shrink: 0;
}

.page-header__back-small::part(control) {
    padding: 0;
}

.entity-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    min-width: 0;
}

.entity-breadcrumb__link,
.entity-breadcrumb__current {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 12.5px;
    line-height: 16px;
    white-space: nowrap;
}

.entity-breadcrumb__link {
    color: var(--neutral-foreground-hint);
    text-decoration: none;
    transition: color 0.12s ease, background-color 0.12s ease;
}

.entity-breadcrumb__link:hover {
    color: var(--accent-foreground-rest);
    background: var(--brand-tint);
}

.entity-breadcrumb__current {
    color: var(--neutral-foreground-rest);
    font-weight: 500;
}

.entity-breadcrumb__sep {
    flex-shrink: 0;
    opacity: 0.5;
}

.entity-breadcrumb svg {
    fill: currentColor !important;
}

/* -----------------------------
   ProfileMenu — sidebar-footer placement
   ----------------------------- */
.sidebar-profile-menu {
    flex: 1 1 auto;
    min-width: 0;
}

.sidebar-profile-menu fluent-profile-menu {
    width: 100%;
}

.app-sidebar.is-collapsed .sidebar-profile-menu fluent-profile-menu::part(header),
.app-sidebar.is-collapsed .sidebar-profile-menu fluent-profile-menu::part(footer-link) {
    display: none;
}

/* Fluent's anchored-region auto-centers the popover horizontally on the
   anchor — but the avatar sits in the bottom-left corner, so the popover
   clips off-screen. Pin it to start near the sidebar's left edge and pop
   above the anchor instead. */
.sidebar-profile-menu fluent-anchored-region {
    left: 8px !important;
    right: auto !important;
    transform: translateY(calc(-100% - 8px)) !important;
}

/* The profile-menu popover's header puts an "Abmelden" pill button at the
   right edge — give the popover enough room so the button doesn't clip. */
.sidebar-profile-menu fluent-anchored-region fluent-card {
    min-width: 360px;
}

/* -----------------------------
   Theme toggle button
   ----------------------------- */
.theme-toggle {
    --theme-toggle-size: 36px;
    width: var(--theme-toggle-size);
    height: var(--theme-toggle-size);
    border-radius: 8px;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--neutral-layer-3);
}

/* -----------------------------
   Card containers — match modern SaaS feel
   ----------------------------- */
.card-container,
.card-container-simple {
    max-width: 1400px;
    width: 100%;
}

/* -----------------------------
   Sidebar collapse trigger
   ----------------------------- */
.sidebar-collapse-toggle {
    margin-left: auto;
}

/* -----------------------------
   StatCard — KPI tile (reusable)
   ----------------------------- */
.stat-card {
    flex: 1 1 0;
    min-width: 160px;
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-card__icon {
    margin-bottom: var(--space-1);
}

.stat-card__value {
    font-size: 24px;
    line-height: 28px;
    font-weight: 600;
    color: var(--accent-fill-rest);
}

.stat-card__label {
    font-size: 13px;
    line-height: 16px;
    color: var(--neutral-foreground-hint);
}

.stat-card-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
    width: 100%;
}

@media (max-width: 1024px) {
    .stat-card-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 540px) {
    .stat-card-row {
        grid-template-columns: 1fr;
    }
}

/* -----------------------------
   StatusBadge — consistent status pill (theme-aware)
   ----------------------------- */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge--neutral { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.status-badge--info    { background: var(--status-info-bg);    color: var(--status-info-fg); }
.status-badge--success { background: var(--status-success-bg); color: var(--status-success-fg); }
.status-badge--warning { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.status-badge--danger  { background: var(--status-danger-bg);  color: var(--status-danger-fg); }

/* -----------------------------
   Text utilities (replace inline color/size)
   ----------------------------- */
.text-hint   { color: var(--neutral-foreground-hint); }
.text-muted  { color: var(--neutral-foreground-disabled); }
.text-sm     { font-size: 12px; line-height: 16px; }
.text-base   { font-size: var(--type-ramp-base-font-size); line-height: var(--type-ramp-base-line-height); }
.text-lg     { font-size: var(--type-ramp-plus-1-font-size); line-height: var(--type-ramp-plus-1-line-height); }

/* -----------------------------
   Plain data table (hand-rolled tables — match the DataGrid look)
   ----------------------------- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--type-ramp-base-font-size);
}

.data-table th {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    font-weight: 600;
    color: var(--neutral-foreground-hint);
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

.data-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}

/* -----------------------------
   EmptyState — placeholder for empty lists/grids
   ----------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    color: var(--neutral-foreground-hint);
}

.empty-state__icon {
    color: var(--neutral-foreground-disabled);
    margin-bottom: var(--space-1);
}

.empty-state__icon svg {
    width: 28px;
    height: 28px;
}

.empty-state__title {
    font-size: var(--type-ramp-plus-1-font-size);
    line-height: var(--type-ramp-plus-1-line-height);
    font-weight: 600;
    color: var(--neutral-foreground-rest);
}

.empty-state__message {
    font-size: 13px;
    max-width: 420px;
}

.empty-state__actions {
    margin-top: var(--space-2);
}

/* -----------------------------
   Bank statement rows — invoice file drop target
   ----------------------------- */
/* FluentDataGrid rows are display:contents — paint the cells, not the tr */
tr.fluent-data-grid-row.invoice-drop-hover > td {
    background: color-mix(in srgb, var(--accent-fill-rest) 12%, transparent);
    box-shadow: inset 0 2px 0 0 var(--accent-fill-rest), inset 0 -2px 0 0 var(--accent-fill-rest);
}

tr.fluent-data-grid-row.invoice-drop-hover > td:first-child {
    box-shadow: inset 2px 0 0 0 var(--accent-fill-rest), inset 0 2px 0 0 var(--accent-fill-rest), inset 0 -2px 0 0 var(--accent-fill-rest);
}

tr.fluent-data-grid-row.invoice-drop-hover > td:last-child {
    box-shadow: inset -2px 0 0 0 var(--accent-fill-rest), inset 0 2px 0 0 var(--accent-fill-rest), inset 0 -2px 0 0 var(--accent-fill-rest);
}

/* -----------------------------
   Dialog helper text — sub-label under a field, heading or message.
   Was duplicated in every Beschaffungs-Dialog; defined once here.
   ----------------------------- */
.dlg-sub {
    font-size: 13px;
    line-height: 18px;
    color: var(--neutral-foreground-hint);
    margin-top: var(--space-1);
}

.dlg-hint {
    color: var(--neutral-foreground-hint);
}

/* -----------------------------
   Marge line — „Kundenpreis − Warenpreis = Marge".
   Shared by the Beschaffungs-Tabelle and the Unterpositions-Dialog.
   ----------------------------- */
.margin-line {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    align-items: baseline;
    font-size: 13px;
    line-height: 18px;
    font-variant-numeric: tabular-nums;
}

.margin-line .hint { color: var(--neutral-foreground-hint); }
.margin-line .good { color: var(--status-success-fg); }
.margin-line .bad  { color: var(--status-danger-fg); }

/* Boxed variant — used where the line stands on its own inside a dialog. */
.margin-line--boxed {
    padding: var(--space-3) var(--space-4);
    border-radius: 12px;
    background: var(--neutral-layer-3);
}

/* -----------------------------
   Beschaffungs-Tabelle — hand-rolled grouped table (FluentDataGrid cannot render
   a Gruppenkopf plus indented Unterpositionen). Shared by ProcurementPage and
   ProcurementTaskRow, which is why it lives here rather than in a page <style>.
   ----------------------------- */
.proc-scroll {
    width: 100%;
    overflow-x: auto;
}

.proc-table {
    min-width: 1010px;
}

.proc-table td {
    vertical-align: top;
}

/* Money and counts never wrap — a broken „2.254,60 €" costs a line on every row.
   The sub-line under a figure may wrap; it is only present on a few rows and would
   otherwise force every money column wide enough for its longest annotation. */
.proc-table .ta-end {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.proc-table .ta-end .proc-sub {
    white-space: normal;
}

/* Gruppenkopf: Kunde › Auftrag. A heading with air above it, not a filled band —
   the groups have to separate without adding another block of colour. */
.proc-table .proc-group > td {
    background: transparent;
    border-bottom: 1px solid var(--neutral-stroke-rest);
    padding-top: var(--space-5);
    padding-bottom: var(--space-2);
}

.proc-table tbody tr:first-child.proc-group > td {
    padding-top: var(--space-2);
}

.proc-group__customer {
    font-weight: 600;
    font-size: var(--type-ramp-plus-1-font-size);
    line-height: var(--type-ramp-plus-1-line-height);
}

.proc-group__order {
    color: var(--neutral-foreground-hint);
    margin-left: var(--space-2);
}

.proc-title {
    font-weight: 600;
}

/* Eingetroffen/storniert — settled work stops competing with what still needs doing. */
.proc-row--done .proc-title {
    font-weight: 400;
    color: var(--neutral-foreground-hint);
}

.proc-row--sub > td {
    background: var(--neutral-layer-2);
}

.proc-row--sub .proc-cell-first {
    padding-left: var(--space-6);
}

.proc-sub {
    font-size: 12px;
    line-height: 16px;
    color: var(--neutral-foreground-hint);
    margin-top: var(--space-1);
}

.proc-muted {
    color: var(--neutral-foreground-hint);
}

.proc-table .good { color: var(--status-success-fg); font-weight: 600; }
.proc-table .bad  { color: var(--status-danger-fg);  font-weight: 600; }

/* Chips */
.proc-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px var(--space-2);
    border-radius: 999px;
    font-size: 11px;
    line-height: 16px;
    font-weight: 600;
    white-space: nowrap;
}

/* „aus Lager" is information. Amber in this table already means „Offen", so this
   chip must not borrow it. */
.proc-chip--stock {
    margin-left: var(--space-2);
    background: var(--status-info-bg);
    color: var(--status-info-fg);
}

.proc-chip--later {
    margin-right: var(--space-2);
    background: var(--status-neutral-bg);
    color: var(--status-neutral-fg);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
}

/* Exactly one primary action plus one overflow menu — never a wrapping cluster. */
.proc-actions {
    display: inline-flex;
    gap: var(--space-1);
    align-items: center;
    justify-content: flex-end;
    white-space: nowrap;
}

/* FluentMenuButton always puts a chevron in its end slot. Beside the „…" overflow
   icon, with no label between them, it reads as a second button. */
.proc-actions .fluent-menubutton-container fluent-button svg[slot="end"] {
    display: none;
}

/* Billing state on the Produkte grid: a compact sign next to the status badge —
   Pause = zurückgestellt, Checkmark = verrechnet. Tooltip carries the words. */
.billing-sign {
    display: inline-flex;
    vertical-align: middle;
    margin-left: var(--space-1);
}
