/* =============================================================================
   Raproma — app-specific styles layered on AdminLTE + Bootstrap 5.
   Branding overrides (palette, fonts) come from /branding.css (later task).

   This file contains ONLY components that AdminLTE/Bootstrap do not supply:
   dashboard metric tiles, budget usage bar, ledger tables, status tags,
   jobs board cards, flash messages, permission matrix, docs layout,
   messaging thread, and invoice detail helpers.

   Shell/nav/auth/marketing/typography/button/form-field rules have been
   removed — Bootstrap 5 and AdminLTE provide equivalents.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   CSS custom properties — semantic tokens used by app-specific components.
   Branding values will be overridden in /branding.css.
   --------------------------------------------------------------------------- */
:root {
    /* Palette */
    --sandstone: #e7decd;
    --paper: #f6f2e9;
    --paper-raised: #fffdf8;
    --slate: #232b34;
    --slate-2: #5a6675;
    --slate-3: #8a93a0;
    --green: #3f6b52;
    --green-deep: #2e5340;
    --green-wash: rgba(63, 107, 82, 0.1);
    --rust: #b5532e;
    --brass: #b0894f;
    --line: rgba(35, 43, 52, 0.14);
    --line-strong: rgba(35, 43, 52, 0.28);

    /* App-shell neutrals */
    --surface: #ffffff;
    --canvas: #faf9f6;
    --border: #e9e7e1;
    --ink: #1b2227;
    --muted: #6e7682;

    /* Type */
    --font-display: "Inter Tight", system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;

    /* Fluid type scale */
    --step--1: clamp(0.78rem, 0.76rem + 0.1vw, 0.84rem);
    --step-0: clamp(0.95rem, 0.92rem + 0.15vw, 1.02rem);
    --step-1: clamp(1.18rem, 1.1rem + 0.4vw, 1.4rem);
    --step-2: clamp(1.5rem, 1.35rem + 0.75vw, 1.95rem);
    --step-3: clamp(2rem, 1.7rem + 1.5vw, 3rem);
    --step-4: clamp(2.7rem, 2.1rem + 3vw, 4.6rem);

    --radius: 6px;
    --radius-lg: 12px;
    --gutter: clamp(1.25rem, 4vw, 3rem);
}

/* ---------------------------------------------------------------------------
   Branding — navbar background (set via --app-navbar-bg from /branding.css)
   --------------------------------------------------------------------------- */
.app-header.navbar {
    background-color: var(--app-navbar-bg, var(--bs-body-bg)) !important;
}

/* ---------------------------------------------------------------------------
   Page-level layout helpers used by unconverted templates
   --------------------------------------------------------------------------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-head h1 {
    margin: 0;
}

.page-head__meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--slate-2);
    margin: 0 0 1rem;
}

.section-title {
    font-size: var(--step-1);
    margin: 2rem 0 0.75rem;
}

.lede {
    font-size: var(--step-0);
    color: var(--slate-2);
    max-width: 60ch;
    margin-bottom: 1.5rem;
}

.muted {
    color: var(--muted);
}

.empty {
    padding: 2rem 0;
    color: var(--slate-2);
}

.empty__hint {
    font-size: var(--step--1);
    color: var(--muted);
}

/* ---------------------------------------------------------------------------
   Flash messages
   --------------------------------------------------------------------------- */
.flash {
    font-size: var(--step--1);
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    margin-bottom: 1rem;
    max-width: 62ch;
}

.flash--success {
    color: var(--green-deep);
    background: rgba(63, 107, 82, 0.1);
    border-color: rgba(63, 107, 82, 0.3);
}

.flash--error {
    color: var(--rust);
    background: rgba(181, 83, 46, 0.1);
    border-color: rgba(181, 83, 46, 0.3);
}

/* ---------------------------------------------------------------------------
   Dashboard metric tiles — used by templates/dashboard/admin.html.twig
   --------------------------------------------------------------------------- */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 0.5rem;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.1rem 1.2rem;
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.metric:hover,
.metric:focus-visible {
    border-left-color: var(--green);
    transform: translateY(-1px);
}

.metric--accent {
    border-left-color: var(--brass);
}

.metric--accent:hover,
.metric--accent:focus-visible {
    border-left-color: var(--rust);
}

.metric__figure {
    font-family: var(--font-mono);
    font-size: var(--step-2);
    line-height: 1;
    color: var(--slate);
    font-variant-numeric: tabular-nums;
}

.metric__label {
    font-size: var(--step--1);
    color: var(--slate-2);
}

@media (prefers-reduced-motion: reduce) {
    .metric {
        transition: none;
    }
    .metric:hover,
    .metric:focus-visible {
        transform: none;
    }
}

/* ---------------------------------------------------------------------------
   Ledger table — used by multiple templates
   --------------------------------------------------------------------------- */
.ledger {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
    font-size: var(--step-0);
}

.ledger th,
.ledger td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--line);
}

.ledger th {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--slate-2);
}

.ledger .num {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.ledger__primary {
    font-weight: 600;
    color: var(--ink);
}

.ledger__action {
    text-align: right;
}

.ledger tbody tr:hover {
    background: var(--canvas);
}

.ledger tfoot th,
.ledger tfoot td {
    border-top: 2px solid var(--ink);
    font-weight: 700;
    color: var(--ink);
}

/* ---------------------------------------------------------------------------
   Status tags — used by multiple templates
   --------------------------------------------------------------------------- */
.tag {
    display: inline-block;
    font-size: var(--step--1);
    line-height: 1.4;
    padding: 0.1rem 0.55rem;
    margin: 0 0.25rem 0.25rem 0;
    border-radius: 999px;
    background: rgba(35, 43, 52, 0.06);
    color: var(--slate-2);
}

.tag--accent {
    background: var(--green-wash);
    color: var(--green-deep);
}

/* Invoice / payment status tags */
.tag--issued {
    background: rgba(176, 137, 79, 0.16);
    color: #7a5a23;
}

.tag--paid,
.tag--completed {
    background: var(--green-wash);
    color: var(--green-deep);
}

.tag--void,
.tag--failed {
    background: rgba(181, 83, 46, 0.12);
    color: var(--rust);
}

/* ---------------------------------------------------------------------------
   Budget usage bar — used by templates/admin/budget/_bar.html.twig
   and templates/admin/budget/show.html.twig
   --------------------------------------------------------------------------- */
.bar {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    width: 140px;
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.bar__fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
}

.bar__fill--ok {
    background: var(--green);
}

.bar__fill--warn {
    background: var(--brass);
}

.bar__fill--over {
    background: var(--rust);
}

.bar__threshold {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--slate-3);
}

.bar__label {
    margin-left: 0.5rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--muted);
    vertical-align: middle;
}

.bar__label--warn {
    color: #7a5a23;
}

.bar__label--over {
    color: var(--rust);
}

.budget-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    margin: 1.25rem 0;
    font-family: var(--font-mono);
    font-size: var(--step-1);
    color: var(--ink);
}

.budget-bar {
    max-width: 480px;
    margin: 1rem 0 1.5rem;
}

.budget-bar .bar {
    width: 100%;
    height: 14px;
}

/* Budget status banners */
.banner {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    margin: 0 0 1.25rem;
    font-weight: 500;
}

.banner--warn {
    background: rgba(176, 137, 79, 0.14);
    color: #7a5a23;
}

.banner--over {
    background: rgba(181, 83, 46, 0.12);
    color: var(--rust);
}

/* ---------------------------------------------------------------------------
   Jobs board — used by templates/admin/job/index.html.twig
   --------------------------------------------------------------------------- */
.board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
    align-items: start;
}

.board__heading {
    font-size: var(--step-0);
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--brass);
}

.board__count {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--slate-2);
}

.card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin-top: 0.85rem;
}

.card__title {
    font-size: var(--step-0);
    margin: 0 0 0.3rem;
}

.card__meta {
    font-size: var(--step--1);
    color: var(--slate-2);
    margin: 0 0 0.3rem;
}

.card__figure {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--slate);
    margin: 0 0 0.6rem;
}

.card__action {
    display: inline-block;
    margin: 0 0.4rem 0 0;
}

/* ---------------------------------------------------------------------------
   Development management hub — templates/admin/development/show.html.twig
   --------------------------------------------------------------------------- */
.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.75rem;
}

.group-block {
    margin-bottom: 2rem;
}

.group-block__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.group-block__head h2 {
    font-size: var(--step-1);
    margin: 0;
}

/* ---------------------------------------------------------------------------
   Permission matrix — templates/admin/permission_group, staff/edit, etc.
   --------------------------------------------------------------------------- */
.matrix {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin: 0 0 1.5rem;
}

.matrix legend {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 0.5rem;
}

.matrix__grid {
    display: flex;
    flex-direction: column;
}

.matrix__row {
    display: grid;
    grid-template-columns: 11rem 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0;
    border-top: 1px solid var(--border);
}

.matrix__row:first-child {
    border-top: 0;
    padding-top: 0;
}

.matrix__module {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink);
}

.matrix__opts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.75rem;
}

.matrix__opt {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.92rem;
    color: var(--slate-2);
    cursor: pointer;
}

.matrix__opt input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--green);
    cursor: pointer;
}

@media (max-width: 560px) {
    .matrix__row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
}

.form-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

/* ---------------------------------------------------------------------------
   Billing / invoice detail
   --------------------------------------------------------------------------- */
.invoice-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem 2.5rem;
    padding: 1.1rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.invoice-meta__label {
    display: block;
    font-size: var(--step--1);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.15rem;
}

.invoice-balance {
    display: flex;
    gap: 2.5rem;
    margin-bottom: 1rem;
    color: var(--slate-2);
}

.invoice-balance strong {
    color: var(--ink);
    font-family: var(--font-mono);
}

.payment-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--canvas);
}

/* ---------------------------------------------------------------------------
   Documentation — templates/admin/docs/*
   --------------------------------------------------------------------------- */
.docs__cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.docs__card {
    display: block;
    padding: 1.1rem 1.2rem;
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.docs__card:hover,
.docs__card:focus-visible {
    border-left-color: var(--green);
    transform: translateY(-1px);
}

.docs__card h3 {
    margin: 0 0 0.3rem;
    font-size: var(--step-0);
}

.docs__card p {
    margin: 0;
    font-size: var(--step--1);
    color: var(--slate-2);
}

.docs {
    display: grid;
    grid-template-columns: 15rem 1fr;
    gap: clamp(1.5rem, 4vw, 3rem);
    align-items: start;
    margin-top: 1rem;
}

.docs__toc {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: 0.15rem;
    border-left: 1px solid var(--line);
    padding-left: 0.75rem;
}

.docs__toc-link {
    font-size: var(--step--1);
    color: var(--slate-2);
    text-decoration: none;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius);
}

.docs__toc-link:hover {
    background: var(--green-wash);
    color: var(--slate);
}

.docs__toc-link.is-active {
    color: var(--green-deep);
    font-weight: 600;
    background: var(--green-wash);
}

.prose {
    max-width: 70ch;
}

.prose h2 {
    font-size: var(--step-1);
    margin: 1.6rem 0 0.5rem;
}

.prose p,
.prose li {
    color: var(--slate);
}

.prose ul,
.prose ol {
    padding-left: 1.2rem;
    margin: 0 0 1rem;
}

.prose li {
    margin: 0.3rem 0;
}

.docs__nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

@media (max-width: 860px) {
    .docs {
        grid-template-columns: 1fr;
    }

    .docs__toc {
        position: static;
    }
}

.joint-parties {
    font-size: var(--step-1);
    font-weight: 600;
    color: var(--ink);
    margin: 0.25rem 0;
}

.plain-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.plain-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    color: var(--slate-2);
}

/* ---------------------------------------------------------------------------
   Messaging thread — templates/admin/messaging/*
   --------------------------------------------------------------------------- */
.thread {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.msg {
    max-width: 80%;
    padding: 0.7rem 0.95rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
}

.msg--staff {
    align-self: flex-start;
    background: var(--green-wash);
    border-color: transparent;
}

.msg--client {
    align-self: flex-end;
    background: var(--canvas);
}

.msg__meta {
    margin: 0 0 0.25rem;
    font-size: var(--step--1);
    color: var(--muted);
}

.msg__body {
    margin: 0;
    color: var(--ink);
}

.reply-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 640px;
}

.reply-form textarea,
.reply-form input[type="text"] {
    width: 100%;
    font: inherit;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--paper-raised);
    color: var(--slate);
}

/* ---------------------------------------------------------------------------
   Global reduced-motion override
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}
