/* Mobile-first, hand-written (deliberate fallback from the Tailwind v4
   standalone-CLI option the plan allows — see the task report: cross-
   platform binary + CI wiring is pure tooling risk for a scaffold whose
   DoD never touches styling; a small stylesheet gets the actual brief
   "mobile-first, single column, large tap targets, simple bottom nav,
   status badges" without it). Single column always; nothing here assumes
   JS. */

:root {
  --color-bg: #fbfaf7;
  --color-text: #1a1a1a;
  --color-muted: #6b6b6b;
  --color-border: #ddd6c8;
  --color-brand: #836732;
  --color-brand-dark: #5f4a22;
  --color-danger: #b3261e;
  --status-nouvelle: #6b7280;
  --status-en-cours: #b45309;
  --status-done: #15803d;
  --status-cancelled: #b91c1c;
  --tap-target: 44px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0 0 72px 0; /* leave room for the fixed bottom nav */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.5rem;
  color: var(--color-brand-dark);
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

a {
  color: var(--color-brand);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.95rem;
}

input,
textarea,
select {
  min-height: var(--tap-target);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--color-text);
}

textarea {
  min-height: calc(var(--tap-target) * 2);
  resize: vertical;
}

button,
.btn {
  min-height: var(--tap-target);
  padding: 0.5rem 1.25rem;
  font-size: 1rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--color-brand);
  color: #fff;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

button:hover,
.btn:hover {
  background: var(--color-brand-dark);
}

button.secondary,
.btn.secondary {
  background: #fff;
  color: var(--color-brand);
  border: 1px solid var(--color-brand);
}

[role="alert"] {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #fdecea;
  color: var(--color-danger);
  border: 1px solid #f3c6c2;
}

[role="status"] {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: #eef6ec;
  color: var(--status-done);
  border: 1px solid #cfe8c9;
}

/* Badges — one class per DB value: a demande's type de travaux, its
   closure, the intake and devis states. */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.badge-assurance {
  background: var(--status-en-cours);
}
.badge-entretien {
  background: var(--status-nouvelle);
}
.badge-closed {
  background: var(--status-done);
}
.badge-pending {
  background: var(--status-nouvelle);
}
.badge-converted {
  background: var(--status-done);
}
.badge-rejected {
  background: var(--status-cancelled);
}
/* A tenant's state in the opérateur back-office. */
.badge-tenant-active {
  background: var(--status-done);
}
.badge-tenant-deactivated {
  background: var(--status-cancelled);
}
/* A member's administrator status, and an invitation past its expiry
   (a resend renews it), in the opérateur back-office. */
.badge-administrator {
  background: var(--status-nouvelle);
}
.badge-invitation-expired {
  background: var(--status-en-cours);
}
/* Parse-anomaly indicator on an otherwise-pending intake row — amber,
   deliberately distinct from the red `.badge-rejected` status badge: this
   is a warning to look closer, not a terminal state. */
.badge-warning {
  background: var(--status-en-cours);
}

/* Intake review queue's raw email body and a demande's free text,
   whitespace preserved but wrapped
   (mobile-first — never let a long line force horizontal scroll). */
.intake-body,
.free-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-family: inherit;
}

.intake-attachments {
  list-style: none;
  margin: 0;
  padding: 0;
}
.intake-attachments li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}
.intake-attachments li:last-child {
  border-bottom: none;
}

.card {
  display: block;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: #fff;
  text-decoration: none;
  color: inherit;
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.card-meta {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

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

.section {
  margin-top: 1.5rem;
}

.section-meta {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 0.25rem 0 0.75rem;
}

/* Dashboard status-count chips — same border/background as `.card`, just a
   compact inline shape (mobile-first: wraps, never forces a horizontal
   scroll). */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1.25rem;
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: #fff;
  font-size: 0.85rem;
}

.stat-count {
  font-weight: 700;
  color: var(--color-brand-dark);
}

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

/* Activity-history block (audit_events) on the demande/OS/intake detail
   pages. */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}

.history-item:last-child {
  border-bottom: none;
}

.history-detail {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

/* Space header: the link back to the chooser, for a compte holding
   several profiles. */
.space-header {
  display: flex;
  justify-content: flex-end;
  padding: 0 1rem;
  border-bottom: 1px solid var(--color-border);
  background: #fff;
}

.space-header a {
  min-height: var(--tap-target);
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-text);
}

.space-choices {
  list-style: none;
  padding: 0;
}

.space-choices li {
  margin-bottom: 0.75rem;
}

.space-current {
  margin-left: 0.5rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}

/* Fixed bottom nav — three large tap targets, always reachable on mobile. */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  border-top: 1px solid var(--color-border);
  background: #fff;
  /* S5-12: a space with many entries scrolls its bar sideways on a phone
     instead of pushing items off screen. */
  overflow-x: auto;
}

.bottom-nav a {
  flex: 1 0 auto;
  min-height: var(--tap-target);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.85rem;
  text-align: center;
}

.bottom-nav a:hover {
  background: var(--color-bg);
}

.bottom-nav form {
  flex: 1 0 auto;
  margin: 0;
}

.bottom-nav button {
  width: 100%;
  height: 100%;
  min-height: var(--tap-target);
  border-radius: 0;
  background: none;
  color: var(--color-text);
  font-size: 0.85rem;
}

.bottom-nav button:hover {
  background: var(--color-bg);
}

/* A radio choice on one line (the type de travaux of a demande). */
label.inline-choice {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

/* The filled fields of a demande, label above value. */
.demande-fields dt {
  font-weight: 600;
  margin-top: 0.5rem;
}
.demande-fields dd {
  margin: 0;
  word-wrap: break-word;
}

/* Eligibility: the criteria of the selection grid, the failed ones
   highlighted; shown to the opérateur and to the artisan alike. */
.eligibility-criteria {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
}
.eligibility-criterion {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: #fff;
}
.eligibility-criterion.eligibility-failed {
  border-color: var(--status-cancelled);
  background: #fdf1f0;
}
.eligibility-code {
  font-weight: 700;
}
.eligibility-message {
  flex-basis: 100%;
  color: var(--color-muted);
}
.eligibility-failed .eligibility-message,
.card-meta.eligibility-failed {
  color: var(--color-danger);
}
.eligibility-summary.eligibility-eligible {
  color: var(--status-done);
}
.eligibility-summary.eligibility-ineligible {
  color: var(--color-danger);
}
.badge-eligible {
  background: var(--status-done);
}
.badge-ineligible {
  background: var(--status-cancelled);
}

/* The list's filters, one control per line on a phone. */
.filters {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* The page footer, above the fixed bottom nav's room. */
.site-footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.85rem;
}

/* S5-10: the copro manager's kanban (one column per stage, scrolled
   sideways on a phone) and the clôture warning. */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  flex: 0 0 240px;
}

.kanban-column h3 {
  font-size: 1rem;
  margin: 0 0 8px 0;
}

.warning {
  border-left: 4px solid var(--status-en-cours);
  padding: 8px 12px;
  margin: 8px 0;
  background: #fff7ed;
}

/* S5-12: a table wider than a phone scrolls inside itself, never the page. */
table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

/* S5-12: a long status line wraps inside its card on a phone. */
.badge {
  white-space: normal;
  max-width: 100%;
}
