/* ==================================================================
   Mise en page du Comptoir Ardent
   ================================================================== */

.app { position: relative; z-index: 1; display: flex; flex-direction: column; min-height: 100vh; }

.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }

/* --- En-tête --------------------------------------------------------- */

.site-header {
  background: linear-gradient(180deg, rgba(19, 16, 23, 0.97), rgba(8, 6, 10, 0.93));
  border-bottom: 2px solid var(--border);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 0;
}

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.brand:hover { text-decoration: none; }

/* L'emblème porte lui-même son cadre : le conteneur ne fait que le dimensionner
   et entretenir la lueur de braise autour. */
.brand__crest {
  width: 54px;
  height: 54px;
  display: block;
  flex: none;
  animation: crest-pulse 3.6s ease-in-out infinite;
}

/* Un logo pas tout à fait carré remplit quand même le cadre, sans être déformé. */
.brand__crest img,
.login-card__crest img { display: block; width: 100%; height: 100%; object-fit: cover; }

@keyframes crest-pulse {
  0%, 100% { box-shadow: 0 0 13px rgba(255, 122, 24, 0.28); }
  50%      { box-shadow: 0 0 26px rgba(255, 122, 24, 0.5); }
}

.brand__name { font-family: var(--font-pixel); font-size: 1.28rem; line-height: 1.15; margin: 0; }
.brand__tag {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin: 2px 0 0;
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-header__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.cart-btn { position: relative; }
.cart-btn__count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  background: var(--ember-400);
  color: #1a0d02;
  font-family: var(--font-pixel);
  font-size: 0.68rem;
  border: 2px solid var(--edge-dark);
  border-radius: 11px;
}

/* --- Navigation ------------------------------------------------------ */

.site-nav { background: rgba(8, 6, 10, 0.85); border-bottom: 2px solid var(--border); position: sticky; top: 0; z-index: 35; }
.site-nav__inner { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; }

.nav-link {
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  color: var(--text-soft);
  padding: 13px 15px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.nav-link:hover { color: var(--ember-200); background: rgba(255, 122, 24, 0.08); text-decoration: none; }
.nav-link.is-active { color: var(--ember-200); border-bottom-color: var(--ember-400); background: rgba(255, 122, 24, 0.1); }
.nav-link__pill {
  background: var(--ember-500);
  color: #1a0d02;
  border-radius: 9px;
  padding: 0 6px;
  font-size: 0.66rem;
  min-width: 18px;
  text-align: center;
}

/* --- Contenu --------------------------------------------------------- */

.site-main { flex: 1; padding: 26px 0 56px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1, .page-head h2 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-soft); font-size: 0.9rem; }

.section { margin-bottom: 26px; }

/* --- Bannière d'accueil ---------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 30px;
  margin-bottom: 24px;
  border: 2px solid var(--ember-600);
  background:
    radial-gradient(ellipse 70% 130% at 15% 110%, rgba(239, 90, 9, 0.4), transparent 60%),
    radial-gradient(ellipse 60% 120% at 88% 115%, rgba(160, 35, 5, 0.35), transparent 60%),
    linear-gradient(150deg, var(--ash-800), var(--ash-850));
  box-shadow: inset 2px 2px 0 rgba(255, 160, 40, 0.2), inset -2px -2px 0 var(--edge-dark), var(--shadow-panel);
}

.hero h1 { margin-bottom: 8px; }
.hero__motd { color: var(--text-soft); max-width: 74ch; margin: 0; }

/* --- Filtres --------------------------------------------------------- */

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .mc-field { min-width: 180px; }
.filters .mc-field--grow { flex: 1 1 260px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }

.chip {
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  padding: 6px 12px;
  background: var(--ash-750);
  border: 2px solid var(--border);
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.12s ease;
}

.chip:hover { border-color: var(--ember-500); color: var(--ember-200); }
.chip.is-active { background: linear-gradient(180deg, var(--ember-400), var(--ember-600)); border-color: var(--ember-600); color: #1a0d02; }

/* --- Grille boutique -------------------------------------------------- */

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); gap: 15px; }

.card {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 15px;
  background: linear-gradient(170deg, var(--ash-750), var(--ash-850));
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.06), inset -2px -2px 0 var(--edge-dark);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  position: relative;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--ember-500);
  box-shadow: inset 2px 2px 0 rgba(255, 160, 40, 0.18), inset -2px -2px 0 var(--edge-dark), 0 8px 26px rgba(255, 122, 24, 0.2);
}

.card.is-out { opacity: 0.62; }
.card.is-out::after {
  content: 'RUPTURE';
  position: absolute;
  top: 12px;
  right: -30px;
  transform: rotate(38deg);
  background: var(--danger-600);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.62rem;
  padding: 3px 34px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.card__top { display: flex; gap: 12px; align-items: flex-start; }
.card__name { font-family: var(--font-pixel); font-size: 0.94rem; margin: 0 0 4px; line-height: 1.35; }
.card__cat { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.card__desc { font-size: 0.83rem; color: var(--text-soft); margin: 0; flex: 1; }

.card__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price { font-family: var(--font-pixel); font-size: 1.14rem; color: var(--ember-200); text-shadow: 0 0 12px rgba(255, 160, 40, 0.35); white-space: nowrap; }
.price small { font-size: 0.62rem; color: var(--text-dim); display: block; text-shadow: none; }

.stock-line { display: flex; align-items: center; justify-content: space-between; font-size: 0.78rem; color: var(--text-soft); }
.card__buy { display: flex; gap: 8px; align-items: center; }
.card__buy .mc-input { width: 74px; text-align: center; }

/* --- Panier (tiroir latéral) ------------------------------------------ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(3px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 100%);
  background: var(--ash-850);
  border-left: 2px solid var(--ember-600);
  box-shadow: -14px 0 40px rgba(0, 0, 0, 0.65);
  z-index: 61;
  transform: translateX(102%);
  transition: transform 0.24s ease;
  display: flex;
  flex-direction: column;
}

.drawer.is-open { transform: translateX(0); }
.drawer__head { padding: 16px; border-bottom: 2px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--ash-700); }
.drawer__head h2 { margin: 0; font-size: 1.05rem; }
.drawer__body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.drawer__foot { padding: 16px; border-top: 2px solid var(--border); background: var(--ash-800); display: flex; flex-direction: column; gap: 11px; }

.cart-line { display: flex; align-items: center; gap: 11px; padding: 9px; background: var(--ash-800); border: 1px solid var(--border); }
.cart-line__body { flex: 1; min-width: 0; }
.cart-line__name { font-size: 0.86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line__sub { font-size: 0.74rem; color: var(--text-dim); }
.cart-line__qty { display: flex; align-items: center; gap: 5px; }
.cart-line__qty .mc-input { width: 58px; text-align: center; padding: 5px; }

.total-row { display: flex; align-items: baseline; justify-content: space-between; font-family: var(--font-pixel); }
.total-row--big { font-size: 1.28rem; color: var(--ember-200); }

/* --- Modale ----------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(4px);
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
}

.modal {
  width: min(660px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--ash-800);
  border: 2px solid var(--ember-600);
  box-shadow: inset 2px 2px 0 rgba(255, 160, 40, 0.22), inset -2px -2px 0 var(--edge-dark), 0 22px 60px rgba(0, 0, 0, 0.7);
  animation: modal-in 0.16s ease-out;
}

.modal--wide { width: min(880px, 100%); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.modal__head { padding: 14px 18px; background: linear-gradient(180deg, var(--ash-700), var(--ash-750)); border-bottom: 2px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 2; }
.modal__head h2 { margin: 0; font-size: 1.02rem; }
.modal__body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal__foot { padding: 14px 18px; border-top: 2px solid var(--border); background: var(--ash-850); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; }

.icon-close { background: none; border: none; color: var(--text-soft); font-size: 1.4rem; cursor: pointer; line-height: 1; padding: 4px 8px; }
.icon-close:hover { color: var(--ember-300); }

/* --- Grilles de formulaire -------------------------------------------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.form-grid--2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.span-all { grid-column: 1 / -1; }

/* --- Sélecteur d'icône ------------------------------------------------- */

.icon-picker { display: flex; gap: 12px; align-items: flex-start; }
.icon-picker__preview { flex: none; }
.icon-picker__grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 5px;
  max-height: 172px;
  overflow-y: auto;
  padding: 7px;
  background: var(--ash-900);
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.55);
}

.icon-opt { background: var(--ash-750); border: 2px solid transparent; padding: 5px; cursor: pointer; display: grid; place-items: center; }
.icon-opt:hover { border-color: var(--ember-500); }
.icon-opt.is-active { border-color: var(--ember-300); background: rgba(255, 122, 24, 0.2); }

/* --- Tableau de bord ---------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 13px; margin-bottom: 22px; }

.stat {
  padding: 14px;
  background: linear-gradient(165deg, var(--ash-750), var(--ash-850));
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.05), inset -2px -2px 0 var(--edge-dark);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat--hot { border-color: var(--ember-600); box-shadow: inset 2px 2px 0 rgba(255, 160, 40, 0.2), inset -2px -2px 0 var(--edge-dark), 0 0 18px rgba(255, 122, 24, 0.18); }
.stat__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); }
.stat__value { font-family: var(--font-pixel); font-size: 1.5rem; color: var(--ember-200); line-height: 1.2; }
.stat__value--sm { font-size: 1.1rem; }
.stat__sub { font-size: 0.74rem; color: var(--text-soft); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

/* --- Mini graphique en barres -------------------------------------------- */

.spark { display: flex; align-items: flex-end; gap: 4px; height: 128px; padding-top: 8px; }
.spark__bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; min-width: 0; }
.spark__fill {
  width: 100%;
  min-height: 3px;
  background: linear-gradient(180deg, var(--ember-200), var(--lava-700));
  border: 1px solid var(--edge-dark);
  transition: height 0.3s ease;
}
.spark__bar:hover .spark__fill { filter: brightness(1.3); }
.spark__label { font-size: 0.6rem; color: var(--text-dim); white-space: nowrap; }

/* --- Listes compactes ----------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 8px; }
.list__row { display: flex; align-items: center; gap: 11px; padding: 9px; background: var(--ash-850); border: 1px solid var(--border); }
.list__body { flex: 1; min-width: 0; }
.list__title { font-size: 0.87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__sub { font-size: 0.73rem; color: var(--text-dim); }
.list__right { text-align: right; white-space: nowrap; font-family: var(--font-pixel); font-size: 0.8rem; }

/* --- États vides ---------------------------------------------------------- */

.empty { text-align: center; padding: 46px 18px; color: var(--text-dim); }
.empty__icon { font-size: 2.6rem; margin-bottom: 10px; opacity: 0.55; }
.empty h3 { color: var(--text-soft); }

/* --- Notifications --------------------------------------------------------- */

.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 9px; max-width: min(400px, calc(100vw - 36px)); }

.toast {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--ash-750);
  border: 2px solid var(--border);
  border-left-width: 5px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.2s ease-out;
  font-size: 0.87rem;
}

.toast--success { border-left-color: var(--ok-400); }
.toast--error   { border-left-color: var(--danger-400); }
.toast--info    { border-left-color: var(--ember-400); }
.toast--warn    { border-left-color: var(--warn-400); }
.toast.is-leaving { animation: toast-out 0.2s ease-in forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* --- Connexion ------------------------------------------------------------- */

.login-shell { display: grid; place-items: center; min-height: 62vh; padding: 18px; }
.login-card { width: min(430px, 100%); text-align: center; }
.login-card .mc-field { text-align: left; }
.login-card__crest {
  width: 78px;
  height: 78px;
  margin: 0 auto 14px;
  display: block;
  box-shadow: 0 0 26px rgba(255, 122, 24, 0.35);
}

/* --- Facture --------------------------------------------------------------- */

.invoice-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.invoice-meta { font-size: 0.86rem; color: var(--text-soft); }
.invoice-meta strong { color: var(--text); }
.invoice-total { margin-top: 14px; margin-left: auto; width: min(320px, 100%); display: flex; flex-direction: column; gap: 6px; }
.invoice-total .total-row { font-size: 0.9rem; }

.stamp {
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  padding: 7px 16px;
  border: 3px solid currentColor;
  transform: rotate(-7deg);
  display: inline-block;
}

.stamp--paid { color: var(--ok-400); }
.stamp--due { color: var(--warn-400); }
.stamp--void { color: var(--danger-400); }

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

.site-footer {
  border-top: 2px solid var(--border);
  background: rgba(8, 6, 10, 0.9);
  padding: 22px 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.site-footer__inner { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; }

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

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--text-dim); }
.soft { color: var(--text-soft); }
.tiny { font-size: 0.76rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.hidden { display: none !important; }
.pos { color: var(--ok-400); }
.neg { color: var(--danger-400); }
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--ember-300);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive ----------------------------------------------------------------- */

@media (max-width: 760px) {
  .wrap { width: calc(100% - 22px); }
  .site-header__inner { padding: 11px 0; }
  .brand__tag { display: none; }
  .brand__crest { width: 44px; height: 44px; }
  .brand__name { font-size: 1.02rem; }
  .hero { padding: 20px; }
  .mc-panel { padding: 14px; }
  .mc-panel__head { margin: -14px -14px 13px; padding: 11px 14px; }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 11px; }
  .card { padding: 11px; }
  .card__desc { display: none; }
  .stat__value { font-size: 1.22rem; }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .mc-btn { width: 100%; }
}
