/* ==========================================================================
   imprimerie.ma — Interface d'administration
   ========================================================================== */

:root {
  --a-bg:     #F1F6FC;
  --a-panel:  #FFFFFF;
  --a-ink:    #16294F;
  --a-ink-2:  #3B5893;
  --a-ink-3:  #7288A9;
  --a-line:   #DFE7F1;
  --a-accent: #1E90D2;
  --a-accent-l:#E9F5FD;
  --a-ok:     #1F7A4D;
  --a-warn:   #B37A10;
  --a-danger: #C4372E;
  --a-radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body.admin {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.55;
  color: var(--a-ink-2); background: var(--a-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--a-ink); margin: 0 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
p  { margin: 0 0 .8em; }
a  { color: var(--a-accent); text-decoration: none; }

/* ---------------------------------------------------- Connexion */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(150deg, #16242F, #2C414F);
}
.login__card {
  background: #fff; border-radius: 16px; padding: 34px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.login__logo { height: 56px; width: auto; display: block; margin-bottom: 16px; }

/* ---------------------------------------------------- Structure */
.layout { display: grid; grid-template-columns: 246px 1fr; min-height: 100vh; }

.side {
  background: var(--a-ink); color: #AFBFCA; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side__brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side__mark { height: 36px; width: auto; display: block; flex: none; }
.side__brand b { color: #fff; font-size: .98rem; display: block; }
.side__brand span { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: #7D91A0; }
.side__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: #AFBFCA;
  font-weight: 600; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; font-family: inherit; font-size: .9rem;
}
.side__link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side__link.is-active { background: var(--a-accent); color: #fff; }
.side__sep { margin: 14px 8px 6px; font-size: .68rem; letter-spacing: .14em;
  text-transform: uppercase; color: #5D7484; }
.side__foot { margin-top: auto; padding-top: 16px; font-size: .78rem; color: #5D7484; }

.main { padding: 26px 30px 60px; min-width: 0; }

.topline {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 22px;
}
.topline__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------- Composants */
.panel {
  background: var(--a-panel); border: 1px solid var(--a-line);
  border-radius: var(--a-radius); padding: 20px; margin-bottom: 18px;
}
.panel--tight { padding: 14px 18px; }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel__head h2, .panel__head h3 { margin: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: #fff; border: 1px solid var(--a-line); border-radius: var(--a-radius); padding: 16px 18px;
}
.stat b { display: block; font-size: 1.9rem; font-weight: 800; color: var(--a-ink); line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--a-ink-3); }
.stat--accent b { color: var(--a-accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 8px; border: 1.5px solid transparent;
  font-family: inherit; font-size: .87rem; font-weight: 650; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.btn--primary { background: var(--a-accent); color: #fff; }
.btn--primary:hover { background: #A64A1A; }
.btn--dark { background: var(--a-ink); color: #fff; }
.btn--dark:hover { background: #2C414F; }
.btn--ghost { background: #fff; color: var(--a-ink); border-color: var(--a-line); }
.btn--ghost:hover { border-color: var(--a-accent); color: var(--a-accent); }
.btn--danger { background: #fff; color: var(--a-danger); border-color: #F0C9C5; }
.btn--danger:hover { background: var(--a-danger); color: #fff; }
.btn--sm { padding: 6px 11px; font-size: .8rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.field { margin-bottom: 13px; }
.field > label { display: block; font-size: .78rem; font-weight: 700; color: var(--a-ink); margin-bottom: 5px; }
.field .help { font-size: .75rem; color: var(--a-ink-3); margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 8px 11px; font-family: inherit; font-size: .88rem;
  color: var(--a-ink); background: #fff;
  border: 1.5px solid var(--a-line); border-radius: 7px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--a-accent); box-shadow: 0 0 0 3px var(--a-accent-l);
}
textarea { min-height: 84px; resize: vertical; font-size: .85rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.row--3 { grid-template-columns: repeat(3, 1fr); }
.row--2 { grid-template-columns: repeat(2, 1fr); }

table.t { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.t th, table.t td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--a-line); vertical-align: middle; }
table.t th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--a-ink-3); font-weight: 700; }
table.t tbody tr:hover { background: #FAFBFC; }
table.t td input, table.t td select { padding: 6px 8px; font-size: .84rem; }
.t__num { text-align: right; font-variant-numeric: tabular-nums; }
.t__actions { text-align: right; white-space: nowrap; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 100px;
  font-size: .7rem; font-weight: 700; background: #EEF2F5; color: var(--a-ink-2);
}
.tag--accent { background: var(--a-accent-l); color: var(--a-accent); }
.tag--off { background: #F3E7E6; color: var(--a-danger); }

.note {
  border-left: 4px solid var(--a-accent); background: var(--a-accent-l);
  padding: 12px 15px; border-radius: 0 8px 8px 0; font-size: .85rem; color: #7E3815;
  margin-bottom: 16px;
}
.note--ok { border-color: var(--a-ok); background: #EAF5EF; color: #14563A; }
.note--warn { border-color: var(--a-warn); background: #FBF2E2; color: #6E4711; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=text] { max-width: 260px; }
.toolbar select { max-width: 220px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--a-ink); color: #fff; padding: 11px 20px; border-radius: 100px;
  font-size: .86rem; font-weight: 600; box-shadow: 0 12px 30px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 200;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--ok { background: var(--a-ok); }
.toast--err { background: var(--a-danger); }

/* ---------------------------------------------------- Éditeur produit */
.editor { display: grid; grid-template-columns: 1fr 330px; gap: 18px; align-items: start; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.checkgrid label {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border: 1px solid var(--a-line); border-radius: 7px; font-size: .82rem; cursor: pointer;
  background: #fff;
}
.checkgrid label:hover { border-color: var(--a-accent); }
.checkgrid input { accent-color: var(--a-accent); }
.checkgrid label.is-on { background: var(--a-accent-l); border-color: var(--a-accent); color: #7E3815; }

.preview { position: sticky; top: 18px; }
.preview__price { font-size: 2rem; font-weight: 800; color: var(--a-ink); line-height: 1; }
.preview__old { color: var(--a-ink-3); text-decoration: line-through; font-size: .95rem; }
.preview ul { list-style: none; padding: 0; margin: 12px 0 0; font-size: .82rem; }
.preview li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }

.gridrow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 6px; align-items: center; }

.back { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 650;
  color: var(--a-ink-2); background: none; border: 0; cursor: pointer; padding: 0; margin-bottom: 12px; }
.back:hover { color: var(--a-accent); }

.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side__brand { padding: 0 10px 0 0; }
  .side__sep { display: none; }
  .side__link { width: auto; }
  .side__foot { display: none; }
  .editor { grid-template-columns: 1fr; }
  .preview { position: static; }
  .main { padding: 20px 16px 50px; }
}

/* ---------------------------------------------------- Devis & commandes */
.tag--ok { background: #E6F4EC; color: #1F7A4D; }

.timeline { list-style: none; padding: 0; margin: 0; font-size: .84rem; }
.timeline li {
  display: grid; grid-template-columns: 130px 1fr auto; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--a-line);
}
.timeline li:last-child { border-bottom: 0; }
.timeline__date { color: var(--a-ink-3); white-space: nowrap; }
.timeline__who { color: var(--a-ink-3); }

pre { margin: 0; }

@media (max-width: 720px) {
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
}

.linelist { list-style: none; padding: 0; margin: 0; font-size: .83rem; }
.linelist li { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; }
.linelist li.is-sep { border-top: 1px solid var(--a-line); margin-top: 6px; padding-top: 7px; }

/* ---------------------------------------------------- Photos des produits */

.photogrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-top: 4px;
}
.photo {
  margin: 0; border: 1px solid var(--a-line); border-radius: var(--a-radius);
  overflow: hidden; background: #fff; position: relative;
}
.photo--main { border-color: var(--a-accent); box-shadow: 0 0 0 2px var(--a-accent-l); }
.photo img {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  background: #F1F6FC;
}
.photo__flag {
  position: absolute; top: 8px; left: 8px;
  background: var(--a-accent); color: #fff;
  font-size: .66rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; padding: 3px 8px; border-radius: 100px;
}
.photo figcaption { padding: 10px 11px 11px; display: grid; gap: 7px; }
.photo figcaption input { font-size: .82rem; padding: 7px 9px; }
.photo__meta { font-size: .72rem; color: var(--a-ink-3); }
.photo__acts { display: flex; gap: 5px; flex-wrap: wrap; }
.photo__acts .btn { padding: 5px 9px; font-size: .76rem; }

.upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload input[type=file] { position: absolute; left: -9999px; }
.upload label {
  display: inline-flex; align-items: center; padding: 10px 16px; cursor: pointer;
  border: 1.5px dashed var(--a-ink-3); border-radius: var(--a-radius);
  font-size: .87rem; font-weight: 650; color: var(--a-ink-2);
}
.upload label:hover { border-color: var(--a-accent); color: var(--a-accent); }
.upload__state { font-size: .82rem; color: var(--a-ink-3); }
