/* LoloShopping : interface (téléphone d'abord). Aucune règle de style en ligne : CSP style-src 'self'. */

@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree.woff") format("woff");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --bg: #F4F2EE;
  --surface: #FFFFFF;
  --border: #E4E0D8;
  --border-strong: #DDD8CF;
  --divider: #EEEAE3;
  --text: #1C1B19;
  --text-2: #3D3A35;
  --muted: #57534B;
  --faint: #8F897F;
  --segment: #EAE7E1;
  --accent: #F6C453;
  --accent-border: #E3A92B;
  --on-accent: #2A1E05;
  --chip-on: #1C1B19;
  --chip-on-text: #FFFFFF;
  --link: #2F5D8A;
  --danger: #A8321F;
  --ok: #2E7D4F;
  --warn: #B7791F;
  --warn-bg: #FBF0D9;
  --warn-border: #EBCF94;
  --warn-text: #6B4A0E;
  --scrim: rgba(28, 27, 25, 0.45);
  --shadow: 0 10px 24px rgba(28, 27, 25, 0.18);
  --focus: #2F5D8A;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315;
    --surface: #1C1D20;
    --border: #2B2D31;
    --border-strong: #3A3C41;
    --divider: #2B2D31;
    --text: #ECEBE8;
    --text-2: #D3D0CA;
    --muted: #A6A29A;
    --faint: #8A867F;
    --segment: #26282C;
    --accent: #F6C453;
    --accent-border: #F6C453;
    --on-accent: #2A1E05;
    --chip-on: #ECEBE8;
    --chip-on-text: #121315;
    --link: #8DB6E0;
    --danger: #F08A78;
    --ok: #5CC28A;
    --warn: #F6C453;
    --warn-bg: #2E2614;
    --warn-border: #5A4A22;
    --warn-text: #F3DDA8;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
    --focus: #8DB6E0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, p { margin: 0; }
.icon { display: inline-flex; }

.screen { min-height: 100vh; min-height: 100dvh; max-width: 640px; margin: 0 auto; }

/* ----------------------------------------------------------- boutons */

.btn {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary { background: var(--accent); border-color: var(--accent-border); color: var(--on-accent); font-weight: 700; }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-link { border-color: transparent; background: transparent; color: var(--muted); min-height: 46px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; }

.square-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.plain-icon-btn {
  width: 48px; height: 48px;
  border: 0; background: none;
  display: flex; align-items: center; justify-content: center;
}

.form-error { color: var(--danger); font-size: 15px; font-weight: 600; }

/* ------------------------------------------------------ clé d'accès */

.screen-key { display: flex; align-items: center; padding: 32px 24px; }
.key-card { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.key-card h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }
.lead { font-size: 17px; line-height: 1.45; color: var(--text-2); margin-bottom: 8px; }
.note { font-size: 14px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > label, .field > legend { font-size: 15px; font-weight: 600; padding: 0; }
.field > legend { margin-bottom: 8px; }
.optional { font-weight: 400; color: var(--muted); }
.field input {
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 18px;
  width: 100%;
}
.field input:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }

/* ------------------------------------------------------------ liste */

.screen-list { display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  padding: calc(16px + env(safe-area-inset-top)) 20px 12px;
  display: flex; flex-direction: column; gap: 14px;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.status { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.dot-live { background: var(--ok); }
.dot-offline { background: var(--warn); }

.segmented {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px;
  padding: 4px; background: var(--segment); border-radius: 12px;
}
.segmented button {
  height: 40px; border: 0; border-radius: 9px; background: transparent;
  font-size: 15px; font-weight: 600; color: var(--muted);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(28, 27, 25, 0.12);
}

.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 12px;
  color: var(--warn-text); font-size: 15px; line-height: 1.4;
}
.banner .icon { margin-top: 1px; flex: none; }

.list { flex: 1; padding: 4px 16px calc(112px + env(safe-area-inset-bottom)); }
.items { display: flex; flex-direction: column; gap: 8px; }
.group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.group-title {
  margin: 4px 4px 0; font-size: 13px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}

.item {
  display: flex; align-items: center;
  min-height: 60px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.item.pending { border-style: dashed; border-color: var(--warn); }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 10px 4px 10px 16px; }
.item-name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.item-detail { font-size: 14px; color: var(--muted); }
.pending-label { color: var(--warn-text); font-weight: 600; }
.row-btn {
  width: 52px; height: 52px; flex: none;
  border: 0; background: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
.row-btn:last-child { margin-right: 2px; }
.row-btn-danger { color: var(--danger); }
.row-btn:active { background: var(--segment); }

.empty { padding: 80px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.empty-title { font-size: 20px; font-weight: 600; color: var(--text); }

.fab {
  position: fixed;
  right: max(20px, calc((100vw - 640px) / 2 + 20px));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 64px; height: 64px;
  border-radius: 20px;
  background: var(--accent); border: 1px solid var(--accent-border); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  z-index: 3;
}

/* ------------------------------------------------------ formulaire */

.screen-form { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.form-header {
  padding: calc(12px + env(safe-area-inset-top)) 12px 8px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.form-header h1, .settings-header h1 { font-size: 24px; font-weight: 700; }
.form-body { flex: 1; overflow-y: auto; padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 22px; }
.qty-row { display: flex; align-items: center; gap: 8px; }
.qty-row input { width: 100px; text-align: center; flex: none; }
.step-btn {
  width: 54px; height: 54px; flex: none;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--border-strong); border-radius: 22px;
  background: var(--surface); font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--chip-on); border-color: var(--chip-on); color: var(--chip-on-text); font-weight: 600; }
.chip-add { border-style: dashed; border-color: var(--faint); background: transparent; color: var(--link); padding: 0 14px; }
.form-footer {
  display: flex; gap: 10px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.form-footer .btn { flex: 1; min-height: 56px; }
.form-footer .btn-primary { flex: 2; }

/* ---------------------------------------------------------- réglages */

.settings-header { padding: calc(12px + env(safe-area-inset-top)) 20px 8px 8px; display: flex; align-items: center; gap: 4px; }
.settings-body { padding: 8px 16px calc(32px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 26px; }
.settings-section { display: flex; flex-direction: column; gap: 8px; }
.section-title {
  margin: 0 4px 2px; font-size: 13px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.section-hint { margin: 0 4px 4px; font-size: 14px; color: var(--muted); }
.card-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  display: flex; flex-direction: column;
}
.card-empty { padding: 16px; color: var(--muted); font-size: 15px; }
.cat-row {
  display: flex; align-items: center; min-height: 54px; padding-left: 6px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  position: relative;
  transition: transform 0.15s ease;
}
.cat-row:last-child { border-bottom: 0; }
.reordering { touch-action: none; }
.cat-row.dragging {
  z-index: 2; transition: none;
  border: 2px solid var(--focus); border-radius: 12px;
  box-shadow: var(--shadow);
}
.grip { width: 36px; height: 48px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--faint); }
.cat-row.dragging .grip { color: var(--focus); }
.cat-name { flex: 1; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.cat-row.dragging .cat-name { font-weight: 600; }
.add-btn {
  min-height: 48px; border: 1px dashed var(--faint); border-radius: 14px; background: transparent;
  font-size: 16px; font-weight: 600; color: var(--link);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.card-row {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 54px; padding: 0 16px; width: 100%;
  border: 0; border-bottom: 1px solid var(--divider); background: none; text-align: left; font-size: 16px;
}
.card-row:last-child { border-bottom: 0; }
.card-row-danger { color: var(--danger); font-weight: 600; }
.settings-status { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); }
.settings-status.status-live { color: var(--ok); }
.settings-status.status-offline { color: var(--warn-text); }

/* ------------------------------------------------- dialogue, message */

.dialog {
  width: min(100vw - 48px, 420px);
  border: 0; border-radius: 20px; padding: 0;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: var(--scrim); }
.dialog-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-title { font-size: 22px; font-weight: 700; }
.dialog-text { font-size: 16px; line-height: 1.45; color: var(--text-2); }
.dialog-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.dup-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--bg); border-radius: 12px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(108px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  .cat-row { transition: none; }
}
