/* ===================================================================
   SEHOUN SHOP V3 — feuille de style unique.
   Remplace assets/style.css et assets/css/style.css, qui se contredisaient.
   =================================================================== */

:root {
  --ink:        #17202a;
  --ink-soft:   #5a6674;
  --line:       #dfe4ea;
  --bg:         #f4f6f8;
  --surface:    #ffffff;
  --brand:      #17202a;
  --gold:       #d7a83b;
  --primary:    #1f6feb;
  --primary-dk: #1a5ec4;
  --success:    #1a7f52;
  --success-bg: #e8f6ee;
  --danger:     #b3261e;
  --danger-bg:  #fdecea;
  --warning:    #8a6100;
  --warning-bg: #fff6e0;
  --radius:     10px;
  --shadow:     0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

/* Colonne pleine hauteur : le pied de page reste en bas même sur une page
   courte, sans jamais chevaucher le contenu. */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 14px/1.5 "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------ en-tête --- */

.top {
  background: var(--brand);
  color: #fff;
  padding: 12px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.top .brand { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.top .brand b { color: var(--gold); }
.top .who { font-size: 13px; color: #c7cdd6; display: flex; align-items: center; gap: 10px; }
.top .who .role {
  background: rgba(255, 255, 255, .12);
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.top .who a { color: #fff; border-bottom: 1px solid rgba(255, 255, 255, .4); }

/* Menu vertical : dix-huit entrées tiennent en colonne sans repli, là où une
   barre horizontale se cassait sur deux ou trois lignes selon le rôle. */
.shell {
  display: flex;
  align-items: flex-start;
  flex: 1 0 auto;
  width: 100%;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
  width: 212px;
  padding: 14px 10px 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  /* Collante et défilante pour elle-même : une page longue ne doit pas
     obliger à remonter pour changer de module. */
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}
.nav a:hover { background: #eef2f6; color: var(--ink); }
.nav a.active { background: var(--brand); color: #fff; }

.nav-icon {
  flex: none;
  width: 20px;
  text-align: center;
  font-size: 14px;
  line-height: 1;
  /* Les glyphes colorés resteraient illisibles sur l'entrée active, qui est
     sombre : les désaturer les laisse suivre la couleur du texte. */
  filter: grayscale(1);
  opacity: .85;
}
.nav a.active .nav-icon { opacity: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* -------------------------------------------------------- repli du menu --- */

/* Caché tant que JavaScript n'a pas posé « nav-js » : un bouton sans effet
   vaut moins que pas de bouton. */
.nav-toggle { display: none; }
.nav-js .nav-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.nav-js .nav-toggle:hover { background: #eef2f6; color: var(--ink); }
.nav-toggle-icon { flex: none; width: 20px; text-align: center; font-size: 15px; line-height: 1; }

/* Replié : la colonne se réduit aux icônes. Le libellé n'est pas simplement
   masqué, il cesse d'occuper de la place, sinon la colonne garderait sa
   largeur. L'attribut title prend le relais au survol. */
.nav-collapsed .nav { width: 58px; padding-left: 8px; padding-right: 8px; }
.nav-collapsed .nav a { justify-content: center; gap: 0; padding: 9px 0; }
.nav-collapsed .nav-label,
.nav-collapsed .nav-toggle-text { display: none; }
.nav-collapsed .nav-toggle { justify-content: center; gap: 0; padding: 7px 0; }

/* La transition porte sur la largeur seule : animer le contenu ferait
   trembler le texte à chaque bascule. */
.nav { transition: width .15s ease; }
@media (prefers-reduced-motion: reduce) {
  .nav { transition: none; }
}

.wrap {
  max-width: 1280px;
  margin: 22px auto 40px;
  padding: 0 22px;
  width: 100%;
  /* min-width:0 : sans lui, un tableau large pousse la colonne et déborde. */
  min-width: 0;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }

/* -------------------------------------------------------------- cartes --- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card > h2:first-child { margin-top: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.grid .card { margin-bottom: 0; }

.kpi { font-size: 25px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--ink-soft); }
.kpi.ok   { color: var(--success); }
.kpi.bad  { color: var(--danger); }
.kpi.warn { color: var(--warning); }

/* ----------------------------------------------------------- formulaires --- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 13px;
}

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); }

input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, .12);
}
input[type="checkbox"] { width: auto; margin-right: 6px; }
label.inline { display: flex; align-items: center; gap: 4px; margin-top: 22px; }
label.inline.small { margin-top: 8px; font-weight: 500; }

/* Champ occupant toute la largeur de la grille : description, photo. */
.form-grid .wide { grid-column: 1 / -1; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
textarea { resize: vertical; min-height: 44px; }

/* ---------------------------------------------------- photos de produits --- */

.image-row { display: flex; gap: 14px; align-items: flex-start; margin-top: 7px; flex-wrap: wrap; }
.image-controls { flex: 1 1 260px; }
.image-controls input[type="file"] { padding: 7px 9px; background: #fff; cursor: pointer; }
.image-controls .small { margin: 6px 0 0; }

/* Vignette : cadre fixe, image entière visible, jamais déformée. */
.thumb {
  width: 38px;
  height: 38px;
  flex: none;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.thumb.lg { width: 104px; height: 104px; object-fit: contain; padding: 3px; }
.thumb.empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(-45deg, #f2f4f7 0 6px, #eaeef3 6px 12px);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}
.product-cell { display: flex; align-items: center; gap: 10px; }

button, .btn {
  display: inline-block;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover, .btn:hover { background: #f2f5f8; }
button.primary, .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
button.primary:hover, .btn.primary:hover { background: var(--primary-dk); }
button.danger, .btn.danger {
  background: #fff;
  border-color: #e7c3c0;
  color: var(--danger);
}
button.danger:hover { background: var(--danger-bg); }
button.small, .btn.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* Barre des rapports : onglets à gauche, exports à droite. */
.report-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.btn.download {
  border-color: #bcd6c8;
  background: var(--success-bg);
  color: var(--success);
}
.btn.download:hover { background: #dcf0e5; }
.btn.download::before { content: "\2193"; margin-right: 6px; font-weight: 700; }
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar label { flex: 1 1 180px; }

/* --------------------------------------------------------------- tables --- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-soft);
  background: #f8fafb;
  white-space: nowrap;
}
tbody tr:hover { background: #f8fafb; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.low td { background: var(--warning-bg); }
tr.off td { opacity: .55; }
.empty { padding: 26px; text-align: center; color: var(--ink-soft); }

/* Sous-formulaire encadré : un bloc de champs qui ne sert que dans un cas. */
.subform {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 16px;
  margin: 16px 0 0;
  background: #fbfcfd;
}
.subform legend {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-soft);
  padding: 0 6px;
}
.subform > .small { margin: 0 0 10px; }
.subform[hidden] { display: none; }

/* --------------------------------------------------------------- bilans --- */

/* Titre de section : sépare les blocs du tableau de bord sans ajouter de carte. */
h2.section {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  margin: 28px 0 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.section-note { margin: 0 0 16px; }

/* Unité accolée à un indicateur : « 42 j » sans casser la taille du chiffre. */
.kpi .unit { font-size: 15px; font-weight: 600; margin-left: 2px; color: var(--ink-soft); }
.kpi.muted { color: var(--ink-soft); }

/* Ligne de total : reprise du fond d'en-tête, lisible sans gras partout. */
tfoot td, tfoot th {
  background: #f8fafb;
  font-weight: 700;
  border-top: 2px solid var(--line);
  border-bottom: none;
}
tfoot th { text-transform: none; font-size: 13px; color: var(--ink); letter-spacing: 0; }
tbody th[scope="row"] {
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  background: none;
  font-weight: 600;
  white-space: normal;
}
tbody tr.sub th[scope="row"] { font-weight: 400; padding-top: 0; }
tbody tr.sub td, tbody tr.sub th { border-bottom: none; padding-top: 0; }
tbody tr.total td, tbody tr.total th { border-top: 1px solid var(--line); font-weight: 700; }
tbody tr.current td { background: #f3f7fd; font-weight: 600; }
tbody tr.current:hover td { background: #eaf1fb; }
td.ok, td .ok   { color: var(--success); }
td.bad, td .bad { color: var(--danger); }
td.warn, b.warn { color: var(--warning); }

/* Variation : le signe porte déjà l'information, la couleur la confirme. */
td.delta { font-weight: 600; }
td.delta.up   { color: var(--success); }
td.delta.down { color: var(--danger); }

/* Barre de proportion : pas d'image, pas de script, imprimable. */
td.share { min-width: 120px; white-space: nowrap; }
td.share .small { margin-left: 8px; }
.bar {
  display: inline-block;
  vertical-align: middle;
  width: 74px;
  height: 7px;
  border-radius: 4px;
  background: #e8ecf1;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--primary);
  border-radius: 4px;
}

/* --------------------------------------------------------------- badges --- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.paid      { background: var(--success-bg); color: var(--success); }
.badge.partial   { background: var(--warning-bg); color: var(--warning); }
.badge.credit    { background: #eaf0fb; color: var(--primary-dk); }
.badge.cancelled { background: var(--danger-bg);  color: var(--danger); }
.badge.open      { background: var(--success-bg); color: var(--success); }
.badge.closed    { background: #eef1f4; color: var(--ink-soft); }
.badge.draft     { background: var(--warning-bg); color: var(--warning); }
.badge.validated { background: var(--success-bg); color: var(--success); }
.badge.received  { background: var(--success-bg); color: var(--success); }

/* ---------------------------------------------------------------- flash --- */

.flash {
  padding: 12px 15px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  border: 1px solid;
  font-weight: 500;
}
.flash.success { background: var(--success-bg); border-color: #b6e0c8; color: var(--success); }
.flash.error   { background: var(--danger-bg);  border-color: #edc3c0; color: var(--danger); }
.flash.warning { background: var(--warning-bg); border-color: #ecd9a5; color: var(--warning); }

/* ---------------------------------------------------------- pied de page --- */

.app-footer {
  margin-top: auto;
  background: var(--brand);
  color: #a9b2bf;
  padding: 18px 22px;
  font-size: 12.5px;
}

.app-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px 26px;
  flex-wrap: wrap;
}

.app-footer .credit { margin: 0; }
.app-footer .credit b { color: var(--gold); letter-spacing: .4px; }

.app-footer .contact {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: 8px 22px;
  flex-wrap: wrap;
}

.app-footer .contact li { display: flex; align-items: center; gap: 7px; }

.app-footer .contact .label {
  color: #737d8b;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: .8px;
}

.app-footer .contact .sep { color: #5d6672; }

.app-footer a {
  color: #dfe4ea;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
}
.app-footer a:hover { color: #fff; border-bottom-color: var(--gold); }

/* Sur la page de connexion, le fond sombre rend la barre inutile. */
.login-page .app-footer { background: transparent; padding: 22px; }

/* ---------------------------------------------------------------- login --- */

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(140deg, #17202a 0%, #243447 100%);
  padding: 20px 20px 0;
}
.login {
  width: 100%;
  max-width: 390px;
  /* margin auto : centre la carte dans l'espace laissé par le pied de page. */
  margin: auto;
  padding: 34px 30px;
}
.login h1 { text-align: center; margin-bottom: 2px; letter-spacing: 1px; }
.login h1 b { color: var(--gold); }
.login .muted { text-align: center; margin: 0 0 24px; }
.login label { margin-bottom: 14px; }
.login button { width: 100%; padding: 11px; margin-top: 6px; }
.login .hint { text-align: center; margin: 18px 0 0; font-size: 12px; }

/* -------------------------------------------------------------- facture --- */

.invoice { max-width: 760px; margin: 0 auto; }
.invoice .head { text-align: center; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 16px; }
.invoice .head h1 { margin-bottom: 4px; }
.invoice .totals { margin-top: 16px; border-top: 2px solid var(--ink); padding-top: 12px; }
.invoice .totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.invoice .totals .grand { font-size: 19px; font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.invoice .foot { text-align: center; margin-top: 22px; color: var(--ink-soft); }

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

/* Sous 900 px, la colonne mangerait la moitié de l'écran : le menu repasse
   au-dessus du contenu, sur une bande défilante horizontalement. */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  /* En bande horizontale, le repli n'a plus de sens : la largeur n'est plus
     la ressource rare. Le bouton disparaît et l'état replié est ignoré. */
  .nav,
  .nav-collapsed .nav {
    flex-direction: row;
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 12px;
    gap: 4px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    z-index: 10;
    transition: none;
  }
  .nav a,
  .nav-collapsed .nav a { flex: none; justify-content: flex-start; gap: 10px; padding: 7px 11px; }
  .nav-collapsed .nav-label { display: inline; }
  .nav-js .nav-toggle { display: none; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 12px; }
  .app-footer { padding: 16px; font-size: 12px; }
  .app-footer-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .app-footer .contact { flex-direction: column; gap: 6px; }
  .nav { padding: 8px 10px; gap: 3px; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .top { padding: 11px 14px; }
  .card { padding: 14px; }
  .kpi { font-size: 21px; }
  h1 { font-size: 19px; }
}

@media print {
  /* Le pied applicatif est masqué à l'impression : sur une facture remise au
     client, les coordonnées de l'éditeur brouilleraient celles de la boutique.
     Retirer .app-footer de cette liste pour l'imprimer malgré tout. */
  .top, .nav, .flash, .no-print, button, .app-footer { display: none !important; }
  body { background: #fff; display: block; }
  /* Le menu masqué ne doit pas laisser sa colonne vide sur le papier. */
  .shell { display: block; }
  .wrap { margin: 0; max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
}
