/* Complaint form, receipt and tracking pages (resources/views/diwan). Built on kobar.css tokens;
   loaded only by those three pages. Status colours reuse the .alert palette in kobar.css. */

.dw-page { --dw-tint: #EEF2E4; --dw-tint-line: #C9D9B0; }

.dw-sheet {
    background: var(--k-paper); border: 1px solid var(--k-line); border-radius: 16px;
    padding: 1.5rem 1.25rem;
}
@media (min-width: 768px) { .dw-sheet { padding: 2.25rem 2.5rem; } }
.dw-sheet__title { font-family: var(--k-display); font-weight: 700; font-size: 1.35rem; margin: 0 0 .75rem; color: var(--k-ink); }
.dw-sheet p { line-height: 1.85; }
.dw-muted { color: var(--k-ink-3); }

/* ------------------------------------------------------------- form steps */
.dw-step { margin: 0 0 2rem; padding: 0 0 2rem; border-bottom: 1px solid var(--k-line-soft); min-width: 0; }
.dw-step__title {
    display: flex; align-items: center; gap: .75rem; float: none; width: 100%;
    margin-bottom: 1.25rem; font-family: var(--k-display); font-weight: 700; font-size: 1.3rem; color: var(--k-ink);
}
.dw-step__n {
    display: inline-grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%;
    background: var(--k-olive); color: #fff; font-size: 1rem; font-family: var(--k-sans);
}
.dw-opt { font: 400 .85rem var(--k-sans); color: var(--k-ink-3); }
.dw-why { color: var(--k-ink-2); line-height: 1.8; margin-bottom: 1rem; max-width: 40rem; }
.dw-err { margin-top: .4rem; font-size: .875rem; color: var(--ram-error); }
.form-control.is-invalid { border-color: var(--ram-error); }
.dw-page .form-control { min-height: 3rem; }
.dw-page .form-text { color: var(--k-ink-3); line-height: 1.7; }

/* Honeypot: present for bots, gone for people and screen readers. */
.dw-hp { position: absolute; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* kind: two large choices */
.dw-kinds { display: grid; gap: .75rem; }
@media (min-width: 576px) { .dw-kinds { grid-template-columns: 1fr 1fr; } }
.dw-kind { position: relative; display: block; cursor: pointer; }
.dw-kind input, .dw-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dw-kind__box {
    display: flex; flex-direction: column; gap: .25rem; height: 100%; padding: 1rem 1.1rem;
    border: 1px solid var(--k-line); border-radius: 12px; background: var(--k-paper);
    transition: border-color .2s, background-color .2s, box-shadow .2s;
}
.dw-kind__box b { font-family: var(--k-display); font-size: 1.05rem; color: var(--k-ink); }
.dw-kind__box small { color: var(--k-ink-3); line-height: 1.6; font-size: .875rem; }
.dw-kind:hover .dw-kind__box { border-color: var(--k-olive-3); }
.dw-kind input:checked + .dw-kind__box { border-color: var(--k-olive); background: var(--dw-tint); box-shadow: inset 0 0 0 1px var(--k-olive); }
.dw-kind input:focus-visible + .dw-kind__box, .dw-chip input:focus-visible + span { outline: 3px solid var(--k-lime); outline-offset: 2px; }

/* category: one-tap chips */
.dw-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.dw-chip { position: relative; cursor: pointer; }
.dw-chip span {
    display: inline-flex; align-items: center; min-height: 2.75rem; padding: .5rem 1.1rem;
    border: 1px solid var(--k-line); border-radius: 999px; background: var(--k-paper); color: var(--k-ink);
    font-weight: 500; transition: background-color .2s, border-color .2s, color .2s;
}
.dw-chip:hover span { border-color: var(--k-olive-3); }
.dw-chip input:checked + span { background: var(--k-olive); border-color: var(--k-olive); color: #fff; }
.dw-chips.is-invalid .dw-chip span { border-color: var(--ram-error); }

/* map */
.dw-map__btn { min-height: 2.75rem; display: inline-flex; align-items: center; }
.dw-map__frame { height: 20rem; margin-top: .75rem; border: 1px solid var(--k-line); border-radius: 12px; overflow: hidden; z-index: 0; }
.dw-map__frame[hidden] { display: none; }
.dw-pin {
    width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    background: var(--k-ochre); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(20, 26, 14, .45);
}

/* photos: the styled button stands in for the native input once diwan.js has run */
.dw-file-btn { display: none; }
.dw-js .dw-file-btn { display: flex; width: max-content; }
.dw-js #dw-photos { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dw-js #dw-photos:focus-visible + .dw-file-btn, .dw-js .dw-file-btn:has(+ #dw-photos:focus-visible) { outline: 3px solid var(--k-lime); outline-offset: 2px; }
.dw-page .form-control::placeholder { color: var(--k-ink-3); opacity: .75; }
.dw-thumbs { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }
.dw-thumbs:empty { display: none; }
.dw-thumb { position: relative; width: 6rem; height: 6rem; border-radius: 10px; overflow: hidden; border: 1px solid var(--k-line); }
.dw-thumb img { width: 100%; height: 100%; object-fit: cover; }
.dw-thumb button {
    position: absolute; top: .25rem; inset-inline-end: .25rem; width: 2rem; height: 2rem; border: 0; border-radius: 50%;
    background: rgba(22, 29, 16, .78); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.dw-thumb button:hover { background: var(--k-night); }

.dw-submit .k-btn { min-width: 14rem; }
.dw-submit .k-btn[disabled] { opacity: .7; cursor: progress; }
@media (max-width: 575.98px) { .dw-submit .k-btn { width: 100%; } }

/* aside */
@media (min-width: 992px) { .dw-aside { position: sticky; top: 6.5rem; } }
.dw-card { background: var(--k-paper); border: 1px solid var(--k-line); border-radius: 14px; padding: 1.25rem 1.35rem; margin-bottom: 1rem; }
.dw-card--track { background: var(--dw-tint); border-color: var(--dw-tint-line); }
.dw-card__k { margin: 0 0 .5rem; color: var(--k-ink-2); font-weight: 600; }
.dw-card__title { font-family: var(--k-display); font-size: 1.05rem; margin: 0 0 .75rem; color: var(--k-ink); }
.dw-privacy { margin: 0 0 .75rem; padding-inline-start: 1.1rem; }
.dw-privacy li { font-size: .9rem; line-height: 1.75; color: var(--k-ink-2); margin-bottom: .5rem; }
.dw-unavailable { max-width: 44rem; }

/* ----------------------------------------------------------------- receipt */
.dw-receipt, .dw-track { max-width: 46rem; margin-inline: auto; }
.dw-code-sheet { text-align: center; }
.dw-code-sheet__k { margin: 0 0 .75rem; font-weight: 600; color: var(--k-ink-2); }
.dw-code {
    margin: 0 auto 1.25rem; padding: 1.1rem 1rem; max-width: 30rem;
    border: 2px dashed var(--k-olive-3); border-radius: 14px; background: var(--k-stone);
    font: 700 clamp(1.6rem, 1rem + 3vw, 2.75rem)/1.2 var(--k-display); letter-spacing: .05em;
    font-variant-numeric: tabular-nums; color: var(--k-olive); user-select: all; white-space: nowrap;
}
.dw-code-sheet__hint { max-width: 32rem; margin: 0 auto 1.5rem; color: var(--k-ink-2); }
.dw-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.dw-sheet:not(.dw-code-sheet) .dw-actions { justify-content: flex-start; }
.dw-btn-lg { display: inline-flex; align-items: center; justify-content: center; min-height: 3.25rem; padding: .7rem 1.4rem; }
@media (max-width: 575.98px) { .dw-actions > * { width: 100%; } }
.dw-code-sheet__link { margin: 1.25rem 0 0; font-size: .9rem; word-break: break-all; }
.dw-selflink { padding: .75rem 1rem; border-radius: 10px; background: var(--k-stone); font-size: .9rem; word-break: break-all; text-align: start; }

/* ---------------------------------------------------------------- tracking */
.dw-code-input { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.dw-result__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.dw-result__code { margin: 0; font: 700 1.6rem/1.2 var(--k-display); letter-spacing: .06em; color: var(--k-olive); }
.dw-result__sub { font-family: var(--k-display); font-size: 1.1rem; margin: 1.75rem 0 1rem; color: var(--k-ink); }
.dw-facts { display: grid; gap: .9rem 2rem; margin: 0; }
@media (min-width: 576px) { .dw-facts { grid-template-columns: 1fr 1fr; } }
.dw-facts dt { font-size: .85rem; font-weight: 500; color: var(--k-ink-3); }
.dw-facts dd { margin: .15rem 0 0; font-weight: 600; color: var(--k-ink); }

/* One mapper for the four Diwan statuses (Complaint::STATUSES). */
.dw-status { display: inline-flex; align-items: center; padding: .35rem .9rem; border-radius: 999px; font-weight: 600; font-size: .9rem; border: 1px solid; }
.dw-status--sm { padding: .1rem .6rem; font-size: .8rem; }
.dw-status--new { color: #1E4E62; background: #E6F1F5; border-color: #BCD8E3; }
.dw-status--in_progress { color: #6E4609; background: #FBF1DF; border-color: #EBD3A6; }
.dw-status--resolved { color: #2B3A1E; background: #EDF3E3; border-color: #C9D9B0; }
.dw-status--rejected { color: #7A2A1E; background: #F8E9E4; border-color: #E6C2B6; }

.dw-timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--k-line); }
.dw-timeline li { position: relative; padding: 0 1.25rem 1.25rem; }
.dw-timeline li::before {
    content: ""; position: absolute; inset-inline-start: -7px; top: .35rem; width: 12px; height: 12px;
    border-radius: 50%; background: var(--k-paper); border: 2px solid var(--k-olive-3);
}
.dw-timeline li:first-child::before { background: var(--k-olive-3); }
.dw-timeline time { display: block; font-size: .85rem; color: var(--k-ink-3); margin-bottom: .25rem; }
.dw-timeline p { margin: .35rem 0 0; line-height: 1.8; white-space: pre-line; }

/* dark theme: the tints are light-only */
html.dark .dw-page { --dw-tint: #222A1B; --dw-tint-line: #333D2B; }
html.dark .dw-chip input:checked + span { background: #9DBC30; border-color: #9DBC30; color: #11160C; }
html.dark .dw-code, html.dark .dw-result__code { color: #C9DDA5; }

@media (prefers-reduced-motion: reduce) {
    .dw-kind__box, .dw-chip span { transition: none; }
}
.dw-err:empty { display: none; }

/* ------------------------------------------------------- transparency (P3) */
.dw-stats__window { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: 0 0 1.25rem; font-weight: 600; color: var(--k-ink-2); }
.dw-stats__window .dw-muted { font-weight: 400; }

/* Totals: the lead figure spans two rows on wide screens, the rest sit beside it. */
.dw-totals { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; margin-bottom: 2rem; }
@media (min-width: 992px) { .dw-totals { grid-template-columns: 1.4fr repeat(2, 1fr); } }
.dw-total {
    display: flex; flex-direction: column; justify-content: flex-end; gap: .35rem; min-width: 0;
    padding: 1.1rem 1.25rem; border: 1px solid var(--k-line); border-radius: 14px; background: var(--k-paper);
}
.dw-total__n { font: 700 clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem)/1.1 var(--k-display); color: var(--k-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dw-total__l { color: var(--k-ink-2); line-height: 1.5; font-size: .95rem; }
.dw-total__l small { color: var(--k-ink-3); }
.dw-total--lead { grid-column: 1 / -1; background: var(--k-olive); border-color: var(--k-olive); }
.dw-total--lead .dw-total__n { font-size: clamp(2.4rem, 1.6rem + 3.5vw, 4rem); color: #fff; }
.dw-total--lead .dw-total__l { color: var(--k-on-dark-2); font-size: 1.05rem; }
@media (min-width: 992px) { .dw-total--lead { grid-column: auto; grid-row: span 2; } }

.dw-stats__grid { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 1200px) { .dw-stats__grid { grid-template-columns: 5fr 7fr; } }

/* Months as horizontal bars: reads the same in RTL and LTR and fits a phone. */
.dw-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; color: var(--k-ink-2); margin: 0 0 1rem; }
.dw-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.dw-key { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; }
.dw-key--in, .dw-bar--in .dw-bar__fill { background: var(--k-olive-2); }
.dw-key--out, .dw-bar--out .dw-bar__fill { background: var(--k-ochre); }
.dw-months { list-style: none; margin: 0; padding: 0; }
.dw-month { display: grid; grid-template-columns: minmax(6.5rem, 9rem) 1fr; column-gap: .75rem; row-gap: .2rem; padding: .55rem 0; border-top: 1px solid var(--k-line-soft); }
.dw-month__name { grid-row: span 2; align-self: center; font-weight: 600; color: var(--k-ink); line-height: 1.4; }
.dw-month__name small { display: block; font-weight: 400; color: var(--k-ink-3); font-size: .78rem; }
.dw-bar { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.dw-bar__fill { display: block; height: .7rem; min-inline-size: 2px; border-radius: 0 4px 4px 0; }
[dir="rtl"] .dw-bar__fill { border-radius: 4px 0 0 4px; }
/* A hidden count is a short hatched stub, so it never reads as zero or as a real length. */
.dw-bar__fill.is-hidden { inline-size: 1.25rem; background: repeating-linear-gradient(-45deg, var(--k-line) 0 3px, transparent 3px 6px); border: 1px solid var(--k-line); }
.dw-bar__n { flex: none; font-size: .85rem; color: var(--k-ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dw-month.is-partial .dw-bar__fill { opacity: .55; }

/* Categories: a table from md up, one card per subject on phones. */
.dw-table { width: 100%; border-collapse: collapse; }
.dw-table th, .dw-table td { padding: .7rem .5rem; border-top: 1px solid var(--k-line-soft); text-align: start; vertical-align: top; }
.dw-table thead th { border-top: 0; font-size: .82rem; font-weight: 600; color: var(--k-ink-3); line-height: 1.4; }
.dw-table tbody th { font-weight: 600; color: var(--k-ink); }
.dw-table td { font-variant-numeric: tabular-nums; color: var(--k-ink-2); }
@media (max-width: 767.98px) {
    .dw-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .dw-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .75rem; padding: .85rem 0; border-top: 1px solid var(--k-line-soft); }
    .dw-table th, .dw-table td { display: block; padding: 0; border: 0; }
    .dw-table tbody th { grid-column: 1 / -1; margin-bottom: .2rem; }
    .dw-table td::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--k-ink-3); }
}

.dw-how { margin-top: 2rem; max-width: 52rem; }
.dw-how ul { padding-inline-start: 1.1rem; color: var(--k-ink-2); line-height: 1.85; }

/* staff-only test flag on the report form */
.dw-staff-test { display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 1.25rem; padding: .85rem 1rem; border: 1px dashed var(--k-ochre); border-radius: 10px; background: var(--k-paper); line-height: 1.7; }
.dw-staff-test .form-check-input { flex: none; margin-top: .35rem; }
