/* Réglages: its sections, one under the other (Platform §3.3). */

.settings {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.settings-heading {
  font-size: var(--fs-lg);
  font-weight: 650;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
}

.settings-label { font-size: var(--fs-md); }

/* A checkbox and its sentence: the label reads as text, not as base.css's small
   capitalised field label. It wraps beside the box rather than under it. */
.settings-check-row {
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: var(--sp-2);
}

.settings-check-row label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.settings-check {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--accent);
}

.settings-check:disabled + label { color: var(--text-muted); }

/* Said offline, where a section needs the server (Platform §12.3). */
.settings-unavailable { color: var(--text-muted); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 767px) {
  .settings { padding: var(--sp-4) var(--sp-3) calc(var(--sp-4) + env(safe-area-inset-bottom)); }
  .settings-row:not(.settings-check-row) { flex-direction: column; align-items: stretch; }
  /* The whole width, and onto a second line when the words do not fit on one — the
     text sizes at 132 % and 150 % do not on a phone. The 1 px gaps over the border
     colour draw the separators, between lines as between buttons. */
  .settings .segmented { display: flex; flex-wrap: wrap; gap: 1px; background: var(--border); }
  .settings .segmented button { flex: 1 1 auto; padding: 0 var(--sp-2); border-right: 0; }
}

/* ------------------------------------------- Appareils, Codes de secours, Session */

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The name and its marker, the dates under them, Révoquer at the end of the row. */
.device {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-1) var(--sp-3);
}

.device-identity {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.device-name { flex: 1 1 auto; min-width: 0; }
.device-current { flex: none; color: var(--text-muted); font-size: var(--fs-sm); }
.device .hint { grid-column: 1; }
.device .btn { grid-column: 2; grid-row: 1 / span 2; }

.enrolment-code,
.recovery-codes {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.enrolment-code-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: 0.12em;
}

/* Clés d'API: the name field and Créer on one row; the key shown once, whole. */
.api-key-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  max-width: 28rem;
}

.api-key-form .input { flex: 1 1 12rem; min-width: 0; }

/* A key's expiry, red once past; Expiration… and Révoquer side by side at the end of the
   row; the expiry's form under it all (Platform §5.15). */
.hint.api-key-expired { color: var(--danger); }

.api-key-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
  grid-column: 2;
  grid-row: 1 / span 3;
}

.api-key-expiry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  grid-column: 1 / -1;
}

/* On a phone two buttons beside the key would leave its name a column of words: they go
   under it. */
@media (max-width: 767px) {
  .api-key-actions { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; }
}

/* Activité (Platform §5.17): a line per event — what, about what, its object for a link —,
   then when and from where. */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

.activity-what {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--sp-2);
  margin: 0;
}

.activity-title { font-weight: 600; }
.activity-subject { overflow-wrap: anywhere; }
.activity-facts { margin: 0; }

.api-key-value {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.recovery-code-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-1) var(--sp-4);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Code des éléments masqués: two short fields, one under the other. */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: 18rem;
}

/* ------------------------------------------------------------ Étiquettes */

.tag-manager,
.tag-block {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.settings-subheading { font-size: var(--fs-md); font-weight: 650; }
.tag-group-title { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }

.tag-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-category,
.tag-row,
.tag-new {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

.tag-category .input,
.tag-row .input,
.tag-new .input { flex: 1 1 10rem; min-width: 0; }

.tag-row .select,
.tag-new .select { flex: 0 1 10rem; min-width: 0; }

.tag-count { flex: none; }

.tag-colour {
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
}

/* ------------------------------------------------------------ Google (Import §7) */

.google-accounts {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.google-account {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

.google-account p { margin: 0; }

.google-email { font-weight: 600; overflow-wrap: anywhere; }

.google-choices {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.google-choices legend {
  margin-bottom: var(--sp-1);
  padding: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.google-lists {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding-left: var(--sp-4);
}

/* The operational alerts (Platform §20.7): above the sections, a line per condition that
   holds, each a link to the section where it is dealt with. The hub shows the same lines
   (hub.css). */
.alerts-banner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--danger);
  border-radius: var(--radius-lg);
  background: var(--danger-soft);
}

.alerts-line { margin: 0; }

.alerts-banner a {
  color: var(--danger);
  font-weight: 600;
}

/* Corbeille (Platform §6.6): what was deleted in the last 30 days, each with Restaurer
   and Supprimer définitivement, then Vider la corbeille. The fieldset only groups what
   is turned off offline; it draws nothing. */

.trash-controls {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.trash-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.trash-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.trash-icon { flex: 0 0 auto; }

.trash-text {
  display: flex;
  flex: 1 1 12rem;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--sp-2);
  min-width: 0;
}

.trash-title { font-weight: 600; overflow-wrap: anywhere; }

.trash-meta {
  flex-basis: 100%;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.trash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-left: auto;
}

.trash-summary { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
