/* DevisVocal : vitrine, espace connecté, documents et impression */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #5f6368;
  --border: #e3e3df;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --ok: #1e7d4f;
  --beta: #a15c00;
  --soon: #6b6b6b;
  --danger: #c0392b;
  --warn-bg: #fff4e0;
  --warn-border: #f0b95c;
  --radius: 14px;
  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1b1b1f;
    --text: #ececef;
    --muted: #a0a0a8;
    --border: #2c2c32;
    --accent: #6f8fff;
    --accent-text: #0d0d10;
    --ok: #4cc38a;
    --beta: #f0a64a;
    --soon: #9a9aa2;
    --danger: #ff6b5e;
    --warn-bg: #2e2410;
    --warn-border: #8a6420;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
}
a { color: var(--accent); }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.2; margin: 0 0 16px; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- En-tête ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 16px; min-height: 64px; padding-top: 8px; padding-bottom: 8px;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.nav a, .nav .link { color: var(--muted); text-decoration: none; font-size: .95rem; }
.nav a:hover, .nav .link:hover { color: var(--text); }
.nav .nav-cta { color: var(--accent); font-weight: 600; }
.inline { display: inline; margin: 0; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.banner { background: var(--warn-bg); border-bottom: 1px solid var(--warn-border); text-align: center; padding: 8px 16px; font-size: .92rem; }

/* ---------- Vitrine ---------- */
.hero { padding: 64px 16px 40px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -0.02em; }
.hero p { font-size: 1.12rem; color: var(--muted); max-width: 680px; margin: 0 0 24px; }
section { padding: 40px 0; }
section h2 { font-size: 1.5rem; margin-bottom: 20px; }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-text);
  padding: 12px 20px; border-radius: 10px; text-decoration: none; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; font-size: 1rem; font-family: inherit;
  margin: 4px 4px 4px 0;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-sm { padding: 7px 12px; font-size: .9rem; }
.btn.danger, .btn-ghost.danger { color: var(--danger); }
.btn.recording { background: var(--danger); color: #fff; border-color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .75; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.grid.pricing { grid-template-columns: minmax(0, 420px); }
.grid.plans { grid-template-columns: repeat(auto-fit, minmax(260px, 380px)); margin-top: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 8px;
}
.card h3 { margin: 0; font-size: 1.12rem; }
.card p { margin: 0; color: var(--muted); }
.card ul { margin: 0 0 8px; padding-left: 20px; color: var(--muted); }
.card .icon { font-size: 1.7rem; line-height: 1; }
.card.featured { border: 2px solid var(--accent); }
.card.narrow { max-width: 420px; }
.price { font-size: 2rem; font-weight: 700; }
.price small { font-size: 1rem; color: var(--muted); font-weight: 400; }

.badge {
  display: inline-block; align-self: flex-start; font-size: .75rem; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle;
}
.badge.ok { color: var(--ok); }
.badge.beta { color: var(--beta); }
.badge.soon { color: var(--soon); }
.badge.danger { color: var(--danger); }

details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; }
summary { cursor: pointer; font-weight: 600; }
details p { color: var(--muted); margin: 10px 0 0; }
.cta-band { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 36px 20px; text-align: center; }
.cta-band p { color: var(--muted); }

.site-footer { border-top: 1px solid var(--border); padding: 28px 0; margin-top: 40px; color: var(--muted); font-size: .9rem; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.site-footer a { color: var(--muted); }

/* ---------- Formulaires ---------- */
.auth { max-width: 440px; padding-top: 48px; padding-bottom: 48px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form.wide { max-width: 760px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: .95rem; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
label.check input { margin-top: 5px; width: auto; }
input, textarea, select {
  font: inherit; font-size: 16px; /* 16px évite le zoom automatique sur iPhone */
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; background: var(--surface); }
legend { font-weight: 700; padding: 0 6px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.flash { padding: 12px 16px; border-radius: 10px; margin: 12px 0; border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-color: var(--ok); }
.flash.error { border-color: var(--danger); color: var(--danger); }
.flash.warn { background: var(--warn-bg); border-color: var(--warn-border); }

/* ---------- Espace connecté ---------- */
.app-main { padding-top: 24px; padding-bottom: 24px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.panel p { margin: 0 0 10px; }
.empty { color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .9rem; }
.two-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.two-cols section { padding: 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row-link {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none;
}
.row-link:hover { border-color: var(--accent); }
.row-side { text-align: right; white-space: nowrap; }

/* Catalogue */
.cat-row, .cat-head { display: grid; grid-template-columns: 1fr 90px 120px auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.cat-new { grid-template-columns: 1fr 90px 120px auto; margin-bottom: 24px; }
.cat-head { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.cat-row input { padding: 8px 10px; }
@media (max-width: 700px) {
  .cat-row, .cat-new { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  .cat-row input[name="designation"], .cat-new input[name="designation"] { grid-column: 1 / -1; }
  .cat-head { display: none; }
}

/* Éditeur */
.dictee textarea { margin-bottom: 8px; }
.ligne { border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ligne + .ligne { margin-top: 8px; }
.ligne.a-completer { border-color: var(--warn-border); background: var(--warn-bg); }
.ligne-details { display: grid; grid-template-columns: 90px 90px 130px 100px 1fr auto; gap: 8px; align-items: end; }
.ligne-details label { font-size: .8rem; color: var(--muted); font-weight: 400; }
.ligne-details input, .ligne-details select { padding: 8px; }
.l-total { font-weight: 700; text-align: right; padding-bottom: 8px; }
.a-completer .l-total { color: var(--beta); font-weight: 600; }
.l-suppr { width: auto; margin: 0 0 2px; }
@media (max-width: 700px) {
  .ligne-details { grid-template-columns: 1fr 1fr; }
  .l-total { text-align: left; }
}
.totaux { margin-left: auto; min-width: 260px; display: flex; flex-direction: column; gap: 4px; }
.totaux div { display: flex; justify-content: space-between; gap: 24px; }
.totaux .grand { font-size: 1.15rem; border-top: 1px solid var(--border); padding-top: 6px; }

.share { display: flex; gap: 8px; margin-bottom: 8px; }
.share input { flex: 1; font-size: .9rem; }
.danger-zone { margin-top: 20px; display: flex; gap: 8px; }
.sign-panel { max-width: 720px; }
.sig-label { font-size: .95rem; }
.sig-pad {
  width: 100%; max-width: 600px; aspect-ratio: 3 / 1; border: 2px dashed var(--border);
  border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair;
}
.refuse { margin-top: 12px; }

/* ---------- Document (toujours sur fond « papier ») ---------- */
.doc {
  background: #fff; color: #1a1a1a; border: 1px solid var(--border); border-radius: 8px;
  padding: clamp(16px, 4vw, 40px); max-width: 900px; margin: 0 auto 20px; font-size: .95rem;
}
.doc-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.doc-company { font-size: 1.25rem; font-weight: 700; }
.doc-meta { text-align: right; }
.doc-kind { font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; color: #2f5bea; }
.doc-to { display: flex; flex-wrap: wrap; gap: 20px 60px; margin-bottom: 20px; }
.doc-to > div { background: #f5f6f8; border-radius: 8px; padding: 12px 16px; min-width: 240px; }
.doc-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: #666; margin-bottom: 2px; }
.doc-title { font-size: 1.1rem; margin: 0 0 12px; }
.table-wrap { overflow-x: auto; }
.doc-lines { width: 100%; border-collapse: collapse; min-width: 560px; }
.doc-lines th { text-align: left; font-size: .8rem; text-transform: uppercase; color: #555; border-bottom: 2px solid #1a1a1a; padding: 8px 6px; }
.doc-lines td { border-bottom: 1px solid #e5e5e5; padding: 8px 6px; vertical-align: top; }
.doc-lines .designation { width: 50%; }
.num { text-align: right; white-space: nowrap; }
.doc-totals { margin: 16px 0 16px auto; border-collapse: collapse; min-width: 280px; }
.doc-totals td { padding: 4px 6px; }
.doc-totals .grand td { font-weight: 800; font-size: 1.1rem; border-top: 2px solid #1a1a1a; padding-top: 8px; }
.doc-notes { background: #f5f6f8; border-radius: 8px; padding: 12px 16px; margin: 12px 0; }
.doc-mentions { font-size: .8rem; color: #555; margin-top: 20px; }
.doc-mentions p { margin: 0 0 4px; }
.doc-signature { margin-top: 24px; border-top: 1px solid #e5e5e5; padding-top: 12px; font-size: .9rem; }
.signature-box { height: 90px; border: 1px dashed #bbb; border-radius: 8px; margin-top: 8px; max-width: 320px; }
.doc-signature.signed img { max-width: 280px; display: block; margin-top: 8px; }

@media print {
  body { background: #fff; }
  .site-header, .site-footer, .banner, .no-print, .flash { display: none !important; }
  .app-main { padding: 0; }
  .doc { border: 0; padding: 0; max-width: none; margin: 0; font-size: 10.5pt; }
  .doc-lines { min-width: 0; }
  .doc-lines tr, .doc-totals, .doc-signature { break-inside: avoid; }
  @page { margin: 15mm; }
}
