/*
 * Les écrans de l'application, redessinés en HTML : fenêtre, barre latérale, cartes,
 * tableaux, pastilles, téléphone. Mesures et teintes relevées sur l'app en production
 * (AppShell : barre de 16 rem, liens de 36 px, en-têtes de 56 px ; cartes Obra).
 * Tout est réduit d'un cran pour tenir dans une page de vente : c'est une maquette
 * fidèle, pas une capture.
 */

/* ----- Fenêtre ----- */

.fenetre {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--background);
  box-shadow: var(--shadow-fenetre);
  overflow: hidden;
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: left;
  container-type: inline-size;
}

.fenetre__barre {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 2.375rem;
  padding: 0 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar);
}

.fenetre__points {
  display: flex;
  gap: 0.375rem;
}

.fenetre__points span {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 999px;
  background: var(--border-strong);
}

.fenetre__adresse {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-inline: auto;
  padding: 0.1875rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.fenetre__adresse .icone {
  width: 0.6875rem;
  height: 0.6875rem;
}

/* ----- Coque de l'app : barre latérale + contenu ----- */

.app {
  display: grid;
  grid-template-columns: 12.5rem minmax(0, 1fr);
  min-height: 0;
}

.app--sans-barre {
  grid-template-columns: minmax(0, 1fr);
}

.app__barre {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  padding-bottom: 0.5rem;
}

.app__marque {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 3.25rem;
  padding: 0 0.875rem;
  border-bottom: 1px solid var(--border);
}

.app__initiale {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.75rem;
  font-weight: 600;
}

.app__marque strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.app__marque small {
  display: block;
  font-size: 0.625rem;
  color: var(--muted-foreground);
}

.app__nav {
  padding: 0 0.375rem;
}

.app__groupe {
  padding: 0.75rem 0.5rem 0.25rem;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.app__lien {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 1.75rem;
  padding: 0 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.71875rem;
  color: var(--sidebar-foreground);
}

.app__lien .icone {
  width: 0.8125rem;
  height: 0.8125rem;
}

.app__lien[aria-current] {
  background: var(--secondary);
  color: var(--foreground);
  font-weight: 500;
}

.app__pied {
  margin-top: auto;
  padding: 0.5rem 0.375rem 0;
  border-top: 1px solid var(--border);
}

.app__contenu {
  min-width: 0;
  padding: 1.125rem 1.25rem 1.375rem;
  background: var(--background);
}

.app__entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.app__titre {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.app__sous-titre {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

/* Boutons de l'app (36 px dans le produit) */
.app-bouton {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.875rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
}

.app-bouton .icone {
  width: 0.75rem;
  height: 0.75rem;
}

.app-bouton--plein {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

button.app-bouton {
  transition:
    background-color var(--duree-rapide) linear,
    transform var(--duree-normale) var(--courbe-sortie);
}

button.app-bouton:hover {
  background: var(--muted);
}

button.app-bouton:active {
  transform: scale(0.96);
}

/* ----- Cartes ----- */

.carte {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  padding: 0.875rem 1rem;
}

.carte__libelle {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
}

.carte__titre {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.carte__valeur {
  margin-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.carte__note {
  margin-top: 0.25rem;
  font-size: 0.625rem;
  color: var(--muted-foreground);
}

.carte--marge {
  padding: 1rem 1.125rem 1.125rem;
}

.carte--marge .carte__valeur {
  font-size: clamp(1.75rem, 1rem + 4.5cqi, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.tuiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem;
  margin-top: 0.625rem;
}

/* ----- Couleurs d'état (la marge, comme dans « Mes deals ») ----- */

.positif {
  color: var(--success-muted-foreground);
}

.moyen {
  color: var(--warning-muted-foreground);
}

.negatif {
  color: var(--destructive-muted-foreground);
}

/* ----- Mes deals ----- */

.deals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.625rem;
}

.deal {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  padding: 0.75rem 0.875rem;
}

.deal__nom {
  font-size: 0.71875rem;
  font-weight: 600;
  line-height: 1.25;
  text-transform: uppercase;
}

.deal__date {
  margin-top: 0.125rem;
  font-size: 0.625rem;
  color: var(--muted-foreground);
}

.deal__poche {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.deal__marge {
  font-size: 0.625rem;
}

.deal__ca {
  font-size: 0.625rem;
  color: var(--muted-foreground);
}

.bloc {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  padding: 0.875rem 1rem;
}

.bloc__entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
}

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

.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.6875rem;
}

.tableau th {
  padding: 0.4375rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  text-align: left;
  color: var(--foreground);
  white-space: nowrap;
}

.tableau td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tableau tr:last-child td {
  border-bottom: 0;
}

.tableau .num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tableau .gras {
  font-weight: 600;
}

.tableau__sous {
  display: block;
  font-size: 0.5625rem;
  color: var(--muted-foreground);
}

.tableau tfoot td {
  border-top: 1px solid var(--foreground);
  border-bottom: 0;
  font-weight: 600;
}

/* ----- Pastilles et étiquettes ----- */

.etiquette {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.0625rem 0.4375rem;
  border-radius: var(--radius-sm);
  font-size: 0.5625rem;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  background: var(--secondary);
  color: var(--foreground);
}

.etiquette--succes {
  background: var(--success-muted);
  color: var(--success-muted-foreground);
}

.etiquette--attention {
  background: var(--warning-muted);
  color: var(--warning-muted-foreground);
}

.etiquette--danger {
  background: var(--destructive-muted);
  color: var(--destructive-muted-foreground);
}

.etiquette--info {
  background: var(--info-muted);
  color: var(--info-muted-foreground);
}

.etiquette--live::before {
  content: '';
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  background: var(--success);
}

.pastille {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.625rem;
  font-weight: 500;
  white-space: nowrap;
}

.pastille::before {
  content: '';
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 999px;
  background: currentColor;
}

.pastille--emise {
  color: var(--facture-emise);
}

.pastille--saisie {
  color: var(--facture-saisie);
}

.pastille--auto {
  color: var(--facture-auto);
}

/* ----- Remplissage (Perf. Shotgun) ----- */

.remplissage {
  display: grid;
  gap: 0.25rem;
  min-width: 5.5rem;
}

.remplissage__barre {
  height: 0.25rem;
  border-radius: 999px;
  background: var(--secondary);
  overflow: hidden;
}

.remplissage__barre span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sidebar-foreground);
}

/* ----- Choix segmenté (Club / Co-organisation) ----- */

.segments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.segment {
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.segment strong {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.segment small {
  display: block;
  font-size: 0.5625rem;
  color: var(--muted-foreground);
}

.segment[aria-pressed='true'],
.segment--actif {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.segment[aria-pressed='true'] small,
.segment--actif small {
  color: color-mix(in srgb, var(--primary-foreground) 70%, transparent);
}

.coche {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  margin-top: 0.4375rem;
  font-size: 0.6875rem;
}

.coche::before {
  content: '';
  width: 0.75rem;
  height: 0.75rem;
  flex: none;
  border-radius: 3px;
  background: var(--info) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 70% no-repeat;
}

.champ-app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: 1.875rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  font-size: 0.6875rem;
}

.champ-app__libelle {
  display: block;
  margin: 0.625rem 0 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
}

/* ----- Graphique en barres (Évolution mensuelle, Rapports) ----- */

.barres {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: end;
  gap: 0.375rem;
  height: 6.5rem;
  padding-top: 0.5rem;
}

.barres__col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  text-align: center;
}

/* Hauteur rapportée à la colonne, étiquette du mois comprise : 80 % au plus pour la pile */
.barres__col span {
  display: block;
  width: 64%;
  margin-inline: auto;
  height: calc(var(--h, 40%) * 0.8);
  border-radius: 4px 4px 0 0;
  background: var(--chart-2);
  transform-origin: bottom;
}

.barres__col span.barres__presta {
  border-radius: 0;
  background: var(--chart-1);
}

.barres__col small {
  margin-top: 0.25rem;
  font-size: 0.5625rem;
  color: var(--muted-foreground);
}

/* ----- Téléphone ----- */

/* Proportions d'un téléphone actuel (écran 9 : 19,5, coins de 55 px rapportés à 390 px),
   cadre noir de 4 px, îlot dans la barre d'état, barre d'accueil en bas. */
.telephone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 15.5rem;
  aspect-ratio: 9 / 19.5;
  border: 4px solid #0a0a0a;
  border-radius: 2.4rem;
  background: var(--background);
  box-shadow: var(--shadow-fenetre), 0 0 0 1px #404040;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 1.4;
}

.telephone__etat {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 2.25rem;
  padding: 0 1.4rem 0 1.6rem;
  flex: none;
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.telephone__etat-icones {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.telephone__etat-icones i {
  display: block;
  background: currentColor;
  border-radius: 1px;
}

.telephone__reseau {
  width: 0.875rem;
  height: 0.5rem;
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}

.telephone__batterie {
  width: 1.125rem;
  height: 0.5rem;
  border-radius: 2px !important;
}

.telephone__ilot {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  width: 4.75rem;
  height: 1.3rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #0a0a0a;
}

.telephone__ecran {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.375rem 0.875rem 0.75rem;
}

.telephone__entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.telephone__entete strong {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.telephone__oeil {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.telephone__oeil .icone {
  width: 0.8125rem;
  height: 0.8125rem;
}

.carrousel {
  display: flex;
  gap: 0.5rem;
  margin-inline: -0.875rem;
  padding-inline: 0.875rem;
  overflow: hidden;
}

.carrousel .carte {
  flex: 0 0 82%;
  padding: 0.75rem 0.875rem;
}

.carrousel .carte + .carte {
  transform: scale(0.92);
  opacity: 0.5;
  transform-origin: left center;
}

.carrousel .carte--marge .carte__valeur {
  font-size: 1.5rem;
}

.telephone__liste {
  display: grid;
  gap: 0.375rem;
  margin-top: 0.75rem;
}

.telephone__ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.6875rem;
}

.telephone__ligne small {
  display: block;
  font-size: 0.5625rem;
  color: var(--muted-foreground);
}

.barre-mobile {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--background);
  padding: 0.375rem 0.25rem 1.25rem;
}

/* La barre d'accueil du système */
.barre-mobile::after {
  content: '';
  position: absolute;
  bottom: 0.4rem;
  left: 50%;
  width: 6rem;
  height: 0.25rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--foreground);
}

.barre-mobile span {
  display: grid;
  justify-items: center;
  gap: 0.125rem;
  font-size: 0.5625rem;
  color: var(--muted-foreground);
}

.barre-mobile span[aria-current] {
  color: var(--foreground);
  font-weight: 500;
}

.barre-mobile .icone {
  width: 0.9375rem;
  height: 0.9375rem;
}

/* ----- Montants masqués ----- */

[data-montant] {
  white-space: nowrap;
}

/* ----- Petits écrans : la fenêtre perd sa barre latérale, comme l'app sous 900 px ----- */

@container (max-width: 40rem) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .app__barre {
    display: none;
  }

  .app__contenu {
    padding: 0.875rem;
  }

  .tuiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deals > :nth-child(n + 3) {
    display: none;
  }

  .masquer-etroit {
    display: none;
  }
}

@container (max-width: 26rem) {
  .tuiles > :nth-child(n + 3) {
    display: none;
  }

  .app-bouton__texte {
    display: none;
  }
}
