/* =====================================================================
   Administration — feuille de style
   Interface volontairement neutre et claire : la couleur est réservée au
   contenu du site, que l'on prévisualise ici.
   ===================================================================== */

:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --line: #e3e5e9;
  --ink: #16181d;
  --muted: #6b7280;
  --accent: #16181d;
  --danger: #a11020;

  /* Palette du site, pour les aperçus */
  --cherry: #86010e;
  --cherry-dark: #4d0008;
  --pink: #eaa2b1;
  --cream: #f7f0df;
  --paper: #fffaf0;

  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: #eceef1;
  font-size: 0.85em;
}

.muted {
  color: var(--muted);
}

/* ---------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: 234px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-head {
  display: grid;
  gap: 0.15rem;
  padding: 1.5rem 1.4rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-head strong {
  font-size: 1.05rem;
}

.sidebar-head span {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  display: grid;
  padding: 0.6rem 0;
}

.sidebar-nav a {
  padding: 0.7rem 1.4rem;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: #f8f9fa;
}

.sidebar-nav a.is-active {
  border-left-color: var(--accent);
  background: #f1f2f4;
  font-weight: 600;
}

.sidebar-foot {
  display: grid;
  gap: 0.4rem;
  margin-top: auto;
  padding: 1.2rem 1.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.sidebar-foot a {
  color: var(--muted);
  text-decoration: none;
}

.sidebar-foot a:hover {
  color: var(--ink);
}

.content {
  min-width: 0;
  padding: 1.6rem 2rem 4rem;
}

.content-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.content-head h1 {
  margin: 0;
  font-size: 1.6rem;
}

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

/* --------------------------------------------------------------- pièces */

.card {
  margin-bottom: 1.2rem;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.card h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.card h3 {
  margin: 1.4rem 0 0.6rem;
  font-size: 0.95rem;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.card-head h2 {
  margin: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.stat-card {
  display: grid;
  gap: 0.2rem;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.stat-card strong {
  font-size: 1.9rem;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
}

.tile {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 150ms ease, transform 150ms ease;
}

.tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.btn {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

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

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
}

.tag {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #eceef1;
  color: var(--muted);
  font-size: 0.7rem;
}

.flash {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid #b9d5b4;
  border-radius: 7px;
  background: #eef7ec;
  font-size: 0.88rem;
}

.flash-error {
  border-color: #e2b4ba;
  background: #fdeff1;
}

.notice {
  padding: 0.6rem 0.9rem;
  border-radius: 7px;
  background: #fff8e6;
  font-size: 0.88rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.9rem;
  align-items: end;
  margin-bottom: 1rem;
}

.form-grid .span-2 {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
}

label.checkbox {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-weight: 400;
}

input,
select,
textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 400;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(22, 24, 29, 0.12);
}

textarea {
  resize: vertical;
}

.inline-form,
.note-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.note-form {
  margin-top: 0.5rem;
  align-items: flex-end;
}

.inline-create {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.7rem;
}

.inline-create input {
  min-width: 240px;
}

/* Bouton « + » entre deux éléments : discret, mais toujours atteignable. */
.insert-row {
  text-align: center;
}

.insert-row td {
  border-bottom: 0 !important;
  padding: 0.15rem 0 !important;
}

.insert-plus {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0.2rem auto;
  border: 1px dashed #c3c7ce;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  list-style: none;
}

.insert-plus::-webkit-details-marker {
  display: none;
}

.insert-plus:hover {
  border-color: var(--accent);
  border-style: solid;
  color: var(--ink);
}

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

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-card {
  display: grid;
  gap: 0.9rem;
  width: min(360px, calc(100% - 2rem));
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.login-card h1 {
  margin: 0;
  font-size: 1.3rem;
}

.login-sub {
  margin: -0.6rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.login-card button {
  margin-top: 0.4rem;
  padding: 0.65rem;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.login-error {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid #e2b4ba;
  border-radius: 7px;
  background: #fdeff1;
  font-size: 0.85rem;
}

/* ------------------------------------------- éditeur de textes */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1.2rem;
  align-items: start;
}

.split-preview {
  position: sticky;
  top: 1.6rem;
}

.text-field {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
  gap: 0.35rem;
}

.text-field:last-of-type {
  border-bottom: 0;
}

.text-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.text-label code {
  font-weight: 400;
}

/* Un champ touché mais non enregistré doit se voir : l'enregistrement est
   explicite, donc l'écart entre l'écran et le site doit être signalé. */
.text-field.is-dirty {
  background: #fffbe9;
  box-shadow: inset 3px 0 0 #e4b322;
}

.text-field.is-dirty .text-label::after {
  content: "non enregistré";
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #e4b322;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.preview-card {
  margin-bottom: 0;
}

.preview-tools {
  display: flex;
  gap: 0.4rem;
}

.preview-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 4 / 3;
  background: #fff;
}

.preview-shell iframe {
  width: 200%;
  height: 200%;
  border: 0;
  transform: scale(0.5);
  transform-origin: top left;
}

.preview-note {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
}

/* ------------------------------------------ éditeur de bandes */

.band-form {
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.band-canvas-title {
  margin-top: 1.2rem;
}

/* La zone reprend les fonds du site pour que la disposition soit jugée
   dans les vraies couleurs. */
.band-canvas {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 16 / 7;
  background: var(--cream);
}

.band-canvas.accent-pink {
  background: var(--pink);
}

.band-canvas.accent-cherry {
  background: var(--cherry);
}

.band-canvas.accent-cherry-dark {
  background: var(--cherry-dark);
}

.band-canvas.accent-paper {
  background: var(--paper);
}

.canvas-item {
  position: absolute;
  cursor: grab;
  transform: rotate(var(--rot, 0deg));
  user-select: none;
}

.canvas-item.is-dragging {
  cursor: grabbing;
  opacity: 0.85;
}

.canvas-item.is-selected {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}

.canvas-bubble {
  display: grid;
  gap: 0.2rem;
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(77, 0, 8, 0.15);
  font-size: 0.72rem;
}

.canvas-bubble small {
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  opacity: 0.7;
  text-transform: uppercase;
}

.canvas-bubble strong {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.canvas-bubble p {
  margin: 0.15rem 0 0;
  font-size: 0.62rem;
  line-height: 1.35;
  opacity: 0.8;
}

.canvas-bubble.color-pink {
  background: var(--pink);
  color: var(--cherry-dark);
}

.canvas-bubble.color-cream {
  background: var(--cream);
  color: var(--cherry-dark);
}

.canvas-bubble.color-paper {
  background: var(--paper);
  color: var(--cherry-dark);
}

.canvas-bubble.color-cherry {
  background: var(--cherry);
  color: var(--cream);
}

.canvas-bubble.color-cherry-dark {
  background: var(--cherry-dark);
  color: var(--cream);
}

.canvas-arrow {
  aspect-ratio: 1;
  color: var(--cherry);
  transform: rotate(var(--rot, 0deg)) scale(var(--flip-x, 1), var(--flip-y, 1));
}

.canvas-arrow.color-cherry-dark {
  color: var(--cherry-dark);
}

.canvas-arrow.color-pink {
  color: var(--pink);
}

.canvas-arrow.color-cream {
  color: var(--cream);
}

.canvas-arrow svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.canvas-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.7rem;
}

.canvas-tools form {
  display: inline;
}

.canvas-hint {
  font-size: 0.76rem;
}

.canvas-status {
  margin-left: auto;
  color: #15803d;
  font-size: 0.76rem;
}

/* ------------------------------------------------------- CRM */

.message-list {
  display: grid;
  gap: 0.8rem;
}

.message {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message.is-unread {
  border-color: #c9d8f2;
  background: #f6f9ff;
}

.message header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.message header > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
}

.message-subject {
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.message-body {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  white-space: pre-wrap;
}

.message footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.attachment {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 0.78rem;
  text-decoration: none;
}

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

.note {
  margin: 0.4rem 0;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: #f6f7f9;
  font-size: 0.8rem;
}

@media (max-width: 1100px) {
  .split {
    grid-template-columns: 1fr;
  }

  .split-preview {
    position: static;
  }
}

@media (max-width: 780px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
  }

  .sidebar-nav a {
    border-bottom: 3px solid transparent;
    border-left: 0;
    white-space: nowrap;
  }

  .sidebar-nav a.is-active {
    border-bottom-color: var(--accent);
    border-left-color: transparent;
  }

  .content {
    padding: 1.2rem 1rem 3rem;
  }
}
