@font-face {
  font-family: "Amiri";
  src: url("../fonts/Amiri-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f2320;
  --muted: #6b7280;
  --accent: #8a6a3b;
  --accent-dark: #6d5330;
  --border: #ddd8ce;
  --error: #b3261e;
  --ok: #1b6e3c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Amiri", "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.7;
}

.topbar {
  background: var(--accent);
  color: #fff;
  padding: 20px 16px;
  text-align: center;
}

.topbar h1 { margin: 0 0 6px; font-size: 26px; }
.topbar .sub { margin: 0; font-size: 16px; opacity: .95; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 12px; font-size: 21px; color: var(--accent-dark); }

.doc-pages { display: grid; gap: 12px; }

.doc-page {
  position: relative;
  overflow: auto;
  cursor: zoom-in;
}

.doc-page.zoomed { cursor: zoom-out; }

.doc-pages img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.doc-page.zoomed img { width: 200%; max-width: none; }

/* Filigrane : décourage la réutilisation d'une capture d'écran. */
.doc-page::after {
  content: "نسخة للقراءة فقط — لا تُنسخ";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 5vw, 40px);
  color: rgba(138, 106, 59, .16);
  transform: rotate(-24deg);
  pointer-events: none;
  white-space: nowrap;
}

/* Le texte de la page n'est pas sélectionnable (sauf les champs du formulaire). */
body.protected {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.protected input, body.protected textarea { -webkit-user-select: text; user-select: text; }

/* Masque le contenu quand la page n'est plus au premier plan ou à l'impression. */
body.screen-guard main, body.screen-guard header, body.screen-guard footer {
  filter: blur(18px);
  opacity: .25;
}

@media print {
  body.protected * { visibility: hidden !important; }
  body.protected::before {
    content: "طبع هذه الوثيقة غير مسموح.";
    visibility: visible;
    display: block;
    text-align: center;
    padding: 40px;
    font-size: 22px;
  }
}

label {
  display: block;
  margin: 14px 0 4px;
  font-weight: 700;
}

input[type="text"], input[type="tel"], input[type="password"] {
  width: 100%;
  padding: 12px;
  font-size: 18px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fcfbf9;
}

input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

#cin { direction: ltr; text-align: left; text-transform: uppercase; }

.req { color: var(--error); }
.hint, .muted { color: var(--muted); font-size: 15px; }
.hint { margin: 4px 0 8px; }

.pad-wrap { position: relative; }

#pad, #admin-pad {
  width: 100%;
  height: 200px;
  touch-action: none;
  background: #fffef9;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  display: block;
}

.pad-line {
  position: absolute;
  inset-inline: 24px;
  bottom: 42px;
  border-bottom: 1px solid #cfc7b8;
  pointer-events: none;
}

.pad-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
  margin-top: 18px;
}

.check input { margin-top: 8px; width: 20px; height: 20px; flex: none; }

.btn {
  font-family: inherit;
  font-size: 18px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  cursor: pointer;
  background: #fff;
  color: var(--accent-dark);
}

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; margin-top: 16px; width: 100%; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost:hover { background: #f2ede4; }
.btn:disabled { opacity: .6; cursor: progress; }

.error { color: var(--error); font-weight: 700; }
.success h3 { color: var(--ok); margin-top: 0; }
.link { color: var(--accent-dark); }
.count { font-size: 24px; font-weight: 700; margin: 0; }

.foot { text-align: center; padding: 16px; }

table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

table.list th, table.list td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}

table.list th { background: #f2ede4; }
table.list img { height: 46px; width: auto; max-width: 220px; }
.cin-cell { direction: ltr; font-family: monospace; }

.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.table-scroll { overflow-x: auto; }
