/* =============================================================
   components.css — Les éléments de l'interface
   -------------------------------------------------------------
   Barre du haut, boutons, cartes, choix, écrans.
   Toutes les zones cliquables font au moins 44 px de haut.
   ============================================================= */

/* ---------- Barre du haut ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  /* Avec un très grand texte, le bouton Réglages passe sous le nom. */
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: max(0.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding-inline: 0.25rem;
  border-radius: 0.5rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  /* Le nom « Omni-Agenda » n'est jamais coupé en deux. */
  white-space: nowrap;
}

.brand img {
  width: 2.25rem;
  height: 2.25rem;
  filter: var(--logo-glow);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Zone principale ---------- */
.app-main {
  width: 100%;
  max-width: 64rem;
  margin-inline: auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
}

.app-main:focus {
  outline: none;
}

.screen-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.screen-header h1 {
  margin: 0;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: max(44px, 2.75rem);
  min-width: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 0.65rem;
  background: var(--color-surface-2);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--color-accent);
}

/* Bouton principal : couleur d'accent (avec halo dans le thème Omni-système). */
.btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
  box-shadow: var(--glow);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

/* Bouton discret : sans fond ni bordure. */
.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-accent-soft);
  border-color: transparent;
}

/* Bouton d'action destructrice (supprimer, abandonner). */
.btn-danger {
  background: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}

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

/* Bouton carré qui ne contient qu'une icône (ex. : Fermer). */
.btn-icon {
  width: max(44px, 2.75rem);
  padding: 0;
}

.btn-small {
  align-self: flex-start;
  padding-inline: 0.75rem;
  font-size: 0.95rem;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Cartes (blocs de réglages) ---------- */
.card {
  margin: 0 0 1rem;
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  background: var(--color-surface);
}

fieldset {
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}

fieldset:last-child {
  margin-bottom: 0;
}

legend {
  margin-bottom: 0.5rem;
  padding: 0;
  font-weight: 600;
}

/* ---------- Choix sous forme de cartes (thème, taille du texte…) ---------- */
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.75rem;
}

.choices-compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
}

/* Dans les petites cartes, le texte reste à côté du bouton rond. */
.choices-compact .choice-text {
  flex-basis: 5rem;
}

.choice-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.75rem;
  border: 2px solid var(--color-border);
  border-radius: 0.8rem;
  background: var(--color-surface-2);
  cursor: pointer;
}

.choice-card:hover {
  border-color: var(--color-border-strong);
}

.choice-card:has(input:checked) {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  box-shadow: var(--glow);
}

.choice-card:has(input:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.choice-card input {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--color-accent);
}

/* Le bouton radio garde son propre contour via la carte. */
.choice-card input:focus-visible {
  outline: none;
}

.choice-text {
  display: flex;
  flex-direction: column;
  /* S'il reste moins de 9 rem de large, le texte passe sous l'aperçu. */
  flex: 1 1 9rem;
  gap: 0.15rem;
  min-width: 0;
  /* Un mot trop long passe à la ligne au lieu de dépasser de la carte. */
  overflow-wrap: break-word;
}

.choice-title {
  font-weight: 600;
}

.choice-desc {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Aperçu miniature d'un thème : deux petites pages et un trait d'accent.
   L'aperçu porte lui-même l'attribut data-theme, il prend donc les couleurs
   du thème qu'il représente. */
.theme-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  flex-shrink: 0;
  width: 3.5rem;
  height: 2.6rem;
  padding: 5px;
  border: 1px solid var(--color-border-strong);
  border-radius: 0.5rem;
  background: var(--color-bg);
}

.theme-preview-page {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 4px;
  border-radius: 3px;
  background: var(--color-paper);
}

.theme-preview-line {
  height: 3px;
  border-radius: 2px;
  background: var(--color-text-muted);
}

.theme-preview-line.is-accent {
  background: var(--color-accent);
  box-shadow: var(--glow);
}

/* Exemple « Aa » dans le choix de taille du texte. */
.size-sample {
  font-weight: 600;
  line-height: 1;
}

/* ---------- Bandeau et messages ---------- */
.banner {
  margin: 0;
  padding: 0.75rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--color-border-strong);
  background: var(--color-surface-2);
  text-align: center;
}

.notice {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border-strong);
  border-radius: 0.75rem;
  background: var(--color-surface-2);
  /* Un long nom de fichier passe à la ligne au lieu de dépasser. */
  overflow-wrap: anywhere;
}

/* Un message en plusieurs paragraphes. */
.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 0.5rem;
}

/* ---------- Rangée de boutons (ex. : Exporter / Importer) ---------- */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ---------- Sous-parties d'une carte (ex. : « Installation », « Stockage ») ---------- */
.card h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
}

.card h3:first-child {
  margin-top: 0.25rem;
}

/* Ligne d'état avec une coche : « ✓ Les rappels sont autorisés. » */
.status-line {
  margin: 0.5rem 0;
}

.status-ok {
  color: var(--color-accent);
  font-weight: 700;
}

.install-steps {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.install-steps li + li {
  margin-top: 0.4rem;
}

/* Bouton dans le bandeau (« Mettre à jour »). */
.banner .btn {
  margin: 0.25rem 0 0.25rem 0.5rem;
}

/* ---------- Écran d'accueil ---------- */
.welcome {
  max-width: 36rem;
  margin: 1.5rem auto;
  padding: 2.5rem 1.5rem;
  border: 1px solid var(--color-paper-edge);
  border-radius: 1rem;
  background: var(--color-paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.welcome-logo {
  width: 6rem;
  height: 6rem;
  margin: 0 auto 1rem;
  filter: var(--logo-glow);
}

/* ---------- Petit message de confirmation, en bas de l'écran ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100% - 2rem);
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--color-accent);
  border-radius: 0.75rem;
  background: var(--color-surface-2);
  box-shadow: var(--shadow);
  color: var(--color-text);
  font-weight: 600;
  transform: translateX(-50%);
}

.toast:empty {
  display: none;
}

/* ---------- Page « À propos » ---------- */
.about {
  max-width: 40rem;
  margin-inline: auto;
  text-align: center;
}

.about-logo {
  width: 5.5rem;
  height: 5.5rem;
  margin: 0.5rem auto 1rem;
  filter: var(--logo-glow);
}

.about-facts {
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0 1.5rem;
  padding: 0;
  list-style: none;
  text-align: left;
}

.about-facts li::before {
  content: "✓";
  margin-right: 0.5rem;
  color: var(--color-accent);
  font-weight: 700;
}

.about .btn-primary {
  margin-bottom: 0.5rem;
}

/* Adresse e-mail de la section « À propos » : un long mot sans espace,
   qu'on autorise à passer à la ligne pour ne pas déborder sur un petit écran. */
.adresse-mail { overflow-wrap: anywhere; }
