/* ═══════════════════════════════════════════════════════════════════
   F2F Deputies — Global Design System
   ═══════════════════════════════════════════════════════════════════ */

/* ── Navigation bar ──────────────────────────────────────────────── */
.dw-nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 1rem;
}

.dw-nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.dw-nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.dw-nav-link {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.15s;
}

.dw-nav-link:hover { color: white; }

.dw-nav-user {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    padding: 0.15rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
}

/* ── User menu dropdown ──────────────────────────────────────────── */
.dw-user-menu {
    position: relative;
}

.dw-user-menu-trigger {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: border-color 0.15s, color 0.15s;
}

.dw-user-menu-trigger:hover {
    color: white;
    border-color: rgba(255,255,255,0.6);
}

.dw-user-menu-caret {
    font-size: 0.65rem;
    line-height: 1;
}

.dw-user-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--neutral-layer-1, #fff);
    border: 1px solid var(--neutral-stroke-rest, #ddd);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 302;
    display: none;
    flex-direction: column;
    padding: 0.25rem 0;
}

.dw-user-menu.is-open .dw-user-menu-dropdown {
    display: flex;
}

.dw-user-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 301;
    display: none;
}

.dw-user-menu.is-open .dw-user-menu-backdrop {
    display: block;
}

.dw-user-menu.is-open .dw-user-menu-trigger {
    position: relative;
    z-index: 302;
}

.dw-user-menu-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--neutral-foreground-rest, #333);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.dw-user-menu-item:hover {
    background: var(--neutral-fill-hover, #f0f0f0);
}

/* ── Mobile nav divider ──────────────────────────────────────────── */
.dw-nav-mobile-divider {
    height: 1px;
    background: rgba(255,255,255,0.15);
    margin: 0.35rem 1rem;
}

.dw-nav-hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.35rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

/* Mobile — hide desktop links, show hamburger */
@media (max-width: 600px) {
    .dw-nav-links    { display: none; }
    .dw-nav-hamburger { display: block; }
}

/* Mobile dropdown panel (fixed below the header) */
.dw-nav-mobile-panel {
    position: fixed;
    top: var(--dw-header-height);
    left: 0;
    right: 0;
    z-index: 200;
    display: none;
    flex-direction: column;
    background-color: var(--accent-fill-rest);
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.dw-nav-mobile-panel.is-open { display: flex; }

.dw-nav-mobile-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.65rem 1.25rem;
    transition: background 0.15s;
}

.dw-nav-mobile-link:hover { background: rgba(255,255,255,0.1); }

.dw-nav-mobile-user {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    padding: 0.5rem 1.25rem 0.25rem;
}

/* ── Design tokens ───────────────────────────────────────────────── */
:root {
    --dw-page-max:       880px;
    --dw-narrow-max:     660px;
    --dw-gutter:         1.5rem;
    --dw-card-gap:       1.75rem;
    --dw-section-gap:    2.25rem;
    --dw-field-pad-v:    1rem;
    --dw-field-pad-h:    1.5rem;
    --dw-label-width:    38%;
    --dw-radius:         8px;
    --dw-header-height:  60px;
    /* Semantic colour shortcuts (not FluentUI tokens — used in forms) */
    --error:   #dc2626;
    --success: #16a34a;
}

/* ── Global base ─────────────────────────────────────────────────── */
body {
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ── Page containers ─────────────────────────────────────────────── */
.dw-page {
    max-width: var(--dw-page-max);
    margin: 0 auto;
    padding: var(--dw-section-gap) var(--dw-gutter);
}

.dw-page-narrow {
    max-width: var(--dw-narrow-max);
    margin: 0 auto;
    padding: var(--dw-section-gap) var(--dw-gutter);
}

@media (max-width: 600px) {
    .dw-page, .dw-page-narrow { padding: 1.5rem 1rem; }
}

/* ── FluentCard default padding ──────────────────────────────────── */
fluent-card {
    padding: var(--dw-card-gap);
    border-radius: var(--dw-radius);
    contain: none !important;               /* #113 — override shadow-DOM paint containment so dropdowns aren't clipped */
    content-visibility: visible !important;  /* #113 — prevent implicit re-containment from content-visibility: auto */
}

/* ── Card with header/body split (override default padding) ───────── */
fluent-card.dw-card-split {
    padding: 0;
    border-radius: var(--dw-radius);
}

.dw-card-split .dw-card-header {
    border-radius: var(--dw-radius) var(--dw-radius) 0 0;
    overflow: hidden; /* clip header corners without clipping the whole card (#113) */
}

.dw-card-header {
    padding: 1rem var(--dw-field-pad-h);
    font-weight: 600;
    font-size: 0.9375rem;
    letter-spacing: 0.01em;
    background: var(--neutral-fill-rest);
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

/* ── Definition list field rows ──────────────────────────────────── */
dl.dw-fields { margin: 0; }

.dw-field-row {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: var(--dw-field-pad-v) var(--dw-field-pad-h);
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

.dw-field-row:last-child { border-bottom: none; }

.dw-field-label {
    flex: 0 0 var(--dw-label-width);
    font-size: 0.875rem;
    color: var(--neutral-foreground-rest);
    padding-top: 0.1rem;
}

.dw-field-value { flex: 1; font-size: 0.9375rem; }

.dw-field-actions { flex: 0 0 auto; text-align: right; }

/* ── Correction form panel ───────────────────────────────────────── */
.dw-correction-panel {
    background: var(--neutral-fill-rest);
    border-bottom: 1px solid var(--neutral-stroke-rest);
    padding: 1.25rem var(--dw-field-pad-h);
}

.dw-form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.dw-form-input {
    width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: inherit;
    background: white;
}

.dw-form-input:focus {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 1px;
    border-color: var(--accent-fill-rest);
}

.dw-field-hint {
    font-size: 0.8125rem;
    color: var(--neutral-foreground-rest);
    margin-top: 0.3rem;
    line-height: 1.4;
}

.dw-field-group { margin-bottom: 1.25rem; }

.dw-field-error {
    font-size: 0.875rem;
    color: var(--error);
    margin-top: 0.3rem;
}

.dw-btn-row { display: flex; gap: 0.625rem; margin-top: 0.25rem; }

.dw-btn-primary {
    font-size: 0.8125rem;
    padding: 0.35rem 0.75rem;
    background: var(--accent-fill-rest);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
}

.dw-btn-primary:hover { background: var(--accent-fill-hover); }
.dw-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.dw-btn-outline {
    font-size: 0.8125rem;
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.4;
}

.dw-btn-outline:hover { background: var(--neutral-fill-hover); }

.dw-correct-btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: var(--neutral-foreground-rest);
    white-space: nowrap;
}

.dw-correct-btn:hover { background: var(--neutral-fill-hover); }

/* ── Correction history ──────────────────────────────────────────── */
.dw-correction-footer {
    padding: 0.75rem var(--dw-field-pad-h);
    background: transparent;
}

.dw-history-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8125rem;
    color: var(--accent-foreground-rest);
    cursor: pointer;
    font-family: inherit;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.15s;
}

.dw-history-btn:hover { text-decoration-color: currentColor; }

.dw-history-table {
    width: 100%;
    font-size: 0.8rem;
    margin-top: 0.75rem;
    border-collapse: collapse;
}

.dw-history-th {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    padding: 0.35rem 0.5rem;
    border-bottom: 2px solid var(--neutral-stroke-rest);
    color: var(--neutral-foreground-rest);
}

.dw-history-td {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
    vertical-align: top;
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

.dw-mono { font-family: monospace; }
.dw-nowrap { white-space: nowrap; }

/* ── Step indicator ──────────────────────────────────────────────── */
.dw-steps {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: var(--neutral-fill-rest);
    border-radius: var(--dw-radius);
    margin-bottom: 2rem;
    border: 1px solid var(--neutral-stroke-rest);
}

.dw-step-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
}

.dw-step-sep {
    margin: 0 0.5rem;
    color: var(--neutral-stroke-strong-rest);
    font-size: 0.75rem;
    user-select: none;
}

.dw-step-num {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    flex-shrink: 0;
    line-height: 1;
}

.dw-step-num--active  { background: var(--accent-fill-rest); color: white; }
.dw-step-num--done    { background: var(--neutral-fill-strong-rest); color: white; }
.dw-step-num--pending { background: transparent; border: 1.5px solid var(--neutral-stroke-rest); color: var(--neutral-foreground-hint); }

.dw-step-label--active  { font-weight: 700; color: var(--accent-foreground-rest); }
.dw-step-label--done    { color: var(--neutral-foreground-rest); }
.dw-step-label--pending { color: var(--neutral-foreground-hint); }

/* ── Hero (home page) ────────────────────────────────────────────── */
.dw-hero {
    padding: 3rem 0 2.5rem;
    margin-bottom: 2.25rem;
    border-bottom: 1px solid var(--neutral-stroke-rest);
}

.dw-hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.15;
    margin: 0 0 0.875rem 0;
}

.dw-hero p {
    font-size: 1.0625rem;
    color: var(--neutral-foreground-rest);
    line-height: 1.65;
    margin: 0;
}

/* ── FluentWizard — natural page flow, no inner scrollbar ───────── */
/* FluentWizard defaults to height:100% which, inside FluentBodyContent's  */
/* overflow-y:auto viewport, constrains the 1fr content row and creates an */
/* inner scroll box. Setting height:auto makes the grid intrinsically sized */
/* so 1fr resolves to auto and the step content expands naturally.          */
.fluent-wizard { height: auto !important; }

/* ── Page heading block ──────────────────────────────────────────── */
.dw-page-heading { margin-bottom: 2rem; }

.dw-page-heading h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0 0 0.375rem 0;
}

.dw-page-heading p {
    color: var(--neutral-foreground-rest);
    margin: 0;
    font-size: 0.9375rem;
}

/* ── Review step sections ────────────────────────────────────────── */
.dw-review-section { margin-bottom: 1.75rem; }

.dw-review-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.875rem;
    padding-bottom: 0.625rem;
    border-bottom: 2px solid var(--accent-fill-rest);
}

.dw-review-section-header h3 {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--neutral-foreground-rest);
    margin: 0;
}

/* ── Spinner keyframe ────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Message bar visibility ──────────────────────────────────────── */
/* FluentMessageBar renders as <div class="fluent-messagebar intent-*">   */
/* Add a left accent border to make alerts stand out from white cards.    */
.fluent-messagebar.intent-success { border-left: 4px solid #22c55e; }
.fluent-messagebar.intent-error   { border-left: 4px solid #ef4444; }
.fluent-messagebar.intent-warning { border-left: 4px solid #f59e0b; }
.fluent-messagebar.intent-info    { border-left: 4px solid #3b82f6; }

/* ── Blazor error UI ─────────────────────────────────────────────── */
#blazor-error-ui {
    background: #fffbeb;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 0.9rem;
    border-top: 3px solid #f59e0b;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.75rem;
    font-size: 1.1rem;
    opacity: 0.6;
}

#blazor-error-ui .dismiss:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════════
   Transaction UI — Responsive & Accessibility (FR-029)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Focus indicators (WCAG 2.1 AA visible focus) ────────────────── */
:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 2px;
}

fluent-button:focus-visible,
fluent-text-field:focus-visible,
fluent-number-field:focus-visible,
fluent-select:focus-visible,
fluent-text-area:focus-visible,
fluent-date-picker:focus-visible,
fluent-switch:focus-visible,
fluent-checkbox:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 2px;
}

/* ── Transaction list row focus/hover ─────────────────────────────── */
[data-testid="transaction-row"]:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: -2px;
    border-radius: 4px;
}

[data-testid="transaction-row"]:hover {
    background: var(--neutral-fill-hover);
}

/* ── Balance summary grid responsive ─────────────────────────────── */
.dw-balance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 2rem;
}

/* ── Filter grid responsive ──────────────────────────────────────── */
.dw-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

/* ── Mobile (320px–768px) ────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Transaction list items: stack vertically on mobile */
    [data-testid="transaction-row"] {
        grid-template-columns: 1fr !important;
        gap: 0.35rem !important;
        padding: 0.75rem !important;
    }

    /* Balance summary: single column on mobile */
    .dw-balance-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    /* Filter controls: single column on mobile */
    .dw-filter-grid {
        grid-template-columns: 1fr !important;
    }

    /* Action button groups: full width stacking */
    [data-testid="transaction-form-panel"] [style*="display: flex"][style*="gap: 0.75rem"],
    [data-testid="transaction-form-panel"] [style*="display: flex"][style*="gap: 0.5rem"] {
        flex-direction: column;
    }

    /* FluentCard detail grids: single column */
    fluent-card [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Form page headings stack vertically */
    .dw-page-heading [style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column;
    }
}

/* ── Auth pages (Login / Logout) ─────────────────────────────────── */
.dw-auth-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--brand-background);
    padding: var(--dw-gutter);
}

.dw-auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--neutral-layer-1, #fff);
    border: 1px solid var(--neutral-stroke-rest);
    border-radius: var(--dw-radius);
    padding: var(--dw-card-gap);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 4px 16px rgba(26, 74, 114, 0.08); /* brand-primary at low opacity */
}

.dw-auth-wordmark {
    display: block;
    width: 100%;
    max-width: 200px;
    height: auto;
}

.dw-auth-status {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--text-muted);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════
   Footer — Layout & z-index fixes (Issue #175)
   ═══════════════════════════════════════════════════════════════════ */

/* Fix: FluentLayout's scoped .layout CSS sets height:100% which
   constrains the layout to parent height. We override via inline
   style (min-height:100vh; height:auto) on <FluentLayout> so it
   fills the viewport on short pages but grows with content. */

/* Fix: FluentFooter scoped CSS sets z-index:10 creating a stacking
   context that clips dropdowns rendered above the footer. */
footer {
    z-index: auto !important;
    position: relative;
}

/* ── Footer content layout ───────────────────────────────────────── */
.dw-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem 1.5rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.dw-footer-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.dw-footer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dw-footer-brand img {
    height: 28px;
    width: auto;
    max-width: min(100%, 230px);
}

.dw-footer-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.dw-footer-links a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: color 0.15s;
}

.dw-footer-links a:hover {
    color: rgba(255,255,255,1);
    text-decoration: underline;
}

.dw-footer-copyright {
    text-align: center;
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.45);
    border-top: 1px solid rgba(255,255,255,0.12);
    padding-top: 0.75rem;
}

/* ── Footer responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .dw-footer-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .dw-footer-links {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}
