/*
 * Mise en page basique de WasteWizz — base de travail pour le développement
 * (voir docs/UI_CONVENTIONS.md). Refonte UX complète prévue en Tranche 6.
 */

:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #26282b;
  --color-text-muted: #6b7076;
  --color-border: #d8dade;
  --color-accent: #2c5aa0;
  --color-accent-contrast: #ffffff;
  --color-error: #b3261e;
  --color-error-bg: #fdecea;
  --color-success: #1e7e34;
  --color-success-bg: #eaf6ec;
  --page-max-width: 1000px;
}

/* -- Reset minimal ---------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
h4,
p,
ul,
ol,
dl,
dd,
fieldset {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

/* -- Typographie -------------------------------------------------------- */

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin-bottom: 0.5em;
}

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

/* -- Structure de page ---------------------------------------------------- */

.site-main,
.site-header__inner,
.site-footer p {
  max-width: var(--page-max-width);
  margin-left: auto;
  margin-right: auto;
}

.site-main {
  padding: 1.5rem 1rem 3rem;
}

/* -- En-tête et navigation ----------------------------------------------- */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
}

.site-header__brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.25rem;
  flex: 1;
}

.site-nav__link {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav__link:hover {
  color: var(--color-text);
}

.site-nav__link.is-active {
  color: var(--color-text);
  font-weight: 600;
  border-bottom-color: var(--color-accent);
}

.site-header__account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.site-header__logout {
  display: inline;
}

/* -- Pied de page ------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* -- Alertes et erreurs --------------------------------------------------- */

.alert,
.messages .message {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.alert--error,
.messages .message--error {
  color: var(--color-error);
  background: var(--color-error-bg);
  border-color: var(--color-error);
}

.alert--success,
.messages .message--success {
  color: var(--color-success);
  background: var(--color-success-bg);
  border-color: var(--color-success);
}

/* -- Sections de formulaire ------------------------------------------------ */

.form-section {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background: var(--color-surface);
}

.form-section > legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

.form-section__note {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.form-section--line {
  border-style: dashed;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.form-section--line:last-child {
  margin-bottom: 0;
}

/* -- Champs de formulaire -------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field__required {
  color: var(--color-error);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  color: inherit;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  background: var(--color-surface);
  max-width: 100%;
}

.field textarea {
  min-height: 5rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled,
.field input:read-only,
.field textarea:read-only {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.field__help {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.field__errors {
  color: var(--color-error);
  font-size: 0.85rem;
}

/* -- Listes de définition -------------------------------------------------- */

dl {
  display: grid;
  grid-template-columns: minmax(10rem, max-content) 1fr;
  gap: 0.4rem 1rem;
  margin-bottom: 1rem;
}

dt {
  font-weight: 600;
  color: var(--color-text-muted);
}

dd {
  margin: 0;
}

.plain-list {
  margin-bottom: 1rem;
}

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

.plain-list li:last-child {
  border-bottom: none;
}

/* -- Tableaux ------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background: var(--color-surface);
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  background: var(--color-bg);
}

tbody tr:nth-child(even) {
  background: var(--color-bg);
}

/* -- Boutons -------------------------------------------------------------- */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.btn--danger {
  background: var(--color-surface);
  color: var(--color-error);
  border-color: var(--color-error);
}

.btn--link {
  background: none;
  border: none;
  color: var(--color-accent);
  font-weight: 400;
  padding: 0;
  text-decoration: underline;
}

/* -- Utilitaires ------------------------------------------------------------ */

.page-title {
  margin-bottom: 1rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.filters .field {
  margin-bottom: 0;
}
