/* Darsi — feuille de style unique (FR / AR, clair, mobile d'abord)
   Les propriétés logiques (inline-start/end) font fonctionner la mise en page en RTL. */

:root {
  --ink: #12261f;
  --ink-2: #3c5249;
  --muted: #6d7f77;
  --line: #dfe5df;
  --paper: #f7f5ee;
  --card: #ffffff;
  --brand: #0e5a43;
  --brand-2: #0a4533;
  --brand-soft: #e3efe8;
  --gold: #e0a526;
  --gold-soft: #fbf0d6;
  --danger: #b4321f;
  --danger-soft: #fbe6e2;
  --ok: #1f7a4d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 38, 31, .06), 0 6px 24px rgba(18, 38, 31, .06);
  --font-body: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Readex Pro', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: 16px;
}
[dir="rtl"] body { font-size: 17px; }
img, video { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 520px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---------- En-tête ---------- */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .container { display: flex; align-items: center; gap: 1rem; min-height: 64px; }
.logo { display: flex; align-items: center; gap: .55rem; font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; color: var(--ink); }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--gold);
  display: grid; place-items: center; font-size: 1.1rem;
}
.nav { display: flex; align-items: center; gap: .25rem; margin-inline-start: auto; }
.nav a, .nav button.linklike {
  color: var(--ink-2); padding: .5rem .75rem; border-radius: 10px; font-weight: 500; font-size: .95rem;
}
.nav a:hover, .nav button.linklike:hover { background: var(--brand-soft); color: var(--brand-2); text-decoration: none; }
.nav a.active { color: var(--brand); background: var(--brand-soft); }
.nav form { margin: 0; }
.nav-toggle { display: none; margin-inline-start: auto; background: none; border: 1px solid var(--line); border-radius: 10px; padding: .45rem .65rem; font-size: 1.1rem; cursor: pointer; color: var(--ink); }
.lang-link { font-weight: 600 !important; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; top: 64px; inset-inline: 0; background: var(--card);
    flex-direction: column; align-items: stretch; padding: .5rem 16px 1rem; border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a, .nav button.linklike { padding: .75rem; text-align: start; width: 100%; }
}

/* ---------- Boutons & formulaires ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .7rem 1.2rem; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff;
  transition: background .15s, transform .05s; text-decoration: none !important; line-height: 1.2;
}
.btn:hover { background: var(--brand-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.gold:hover { background: #cf951b; }
.btn.ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { background: transparent; color: var(--danger); border-color: #efc6bf; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .4rem .7rem; font-size: .85rem; border-radius: 9px; }
.btn.block { width: 100%; }
button.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.field .err { font-size: .85rem; color: var(--danger); margin-top: .25rem; }
input[type=text], input[type=tel], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 11px; padding: .7rem .85rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=tel] { direction: ltr; text-align: start; }
[dir="rtl"] input[type=tel] { text-align: right; }
textarea { min-height: 110px; resize: vertical; }
input[type=file] { font: inherit; width: 100%; padding: .55rem; border: 1px dashed #b8c6be; border-radius: 11px; background: #fbfcfa; }
.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }

/* ---------- Cartes / sections ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.section { padding: 2.5rem 0; }
.page { padding-top: 1.75rem; padding-bottom: 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }

.flash { padding: .8rem 1rem; border-radius: 12px; margin: 1rem 0 0; font-weight: 500; }
.flash.success { background: var(--brand-soft); color: var(--brand-2); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.notice { background: var(--gold-soft); border: 1px solid #f0d99a; padding: .9rem 1rem; border-radius: 12px; color: #6b4d08; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand-2); white-space: nowrap; }
.badge.gold { background: var(--gold-soft); color: #7a5509; }
.badge.grey { background: #eef0ee; color: var(--muted); }
.badge.red { background: var(--danger-soft); color: var(--danger); }

/* ---------- Accueil ---------- */
.hero { background: var(--brand); color: #f1f5ef; position: relative; overflow: hidden; }
.hero::after {
  content: ''; position: absolute; inset-inline-end: -120px; top: -80px; width: 420px; height: 420px;
  border-radius: 50%; border: 60px solid rgba(224, 165, 38, .16);
}
.hero .container { position: relative; z-index: 1; padding-top: 3.5rem; padding-bottom: 3.5rem; }
.hero h1 { color: #fff; font-size: clamp(1.9rem, 5vw, 3rem); max-width: 16ch; }
.hero h1 em { font-style: normal; color: var(--gold); }
.hero p { font-size: 1.1rem; max-width: 52ch; color: #cfe0d6; }
.hero .row { margin-top: 1.5rem; }
.hero .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.hero .btn.ghost:hover { background: rgba(255, 255, 255, .08); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; counter-reset: s; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; position: relative; }
.step::before {
  counter-increment: s; content: counter(s); font-family: var(--font-head); font-weight: 700;
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--gold-soft); color: #7a5509; margin-bottom: .75rem;
}
.step h3 { margin-bottom: .25rem; }
.step p { margin: 0; color: var(--muted); font-size: .95rem; }

.band { background: var(--ink); color: #e9efe9; border-radius: 20px; padding: 2rem; display: flex; gap: 1.5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.band h2 { color: #fff; margin: 0 0 .25rem; }
.band p { margin: 0; color: #b9c7bf; }

/* ---------- Grille de modules ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem; }
.mcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; color: inherit; transition: transform .15s, box-shadow .15s; }
.mcard:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.cover { aspect-ratio: 16 / 9; background: var(--brand-soft); position: relative; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { width: 100%; height: 100%; display: grid; place-items: center; font-family: var(--font-head); font-size: 2.6rem; font-weight: 700; color: var(--brand); background: repeating-linear-gradient(135deg, #e3efe8 0 14px, #dcebe2 14px 28px); }
.mcard .body { padding: 1rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.mcard h3 { margin: 0; font-size: 1.05rem; }
.mcard .meta { font-size: .85rem; color: var(--muted); }
.mcard .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: .6rem; }
.price { font-family: var(--font-head); font-weight: 700; color: var(--ink); white-space: nowrap; }
.price small { font-weight: 500; color: var(--muted); font-size: .8em; }
.counts { display: flex; gap: .6rem; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }

.searchbar { display: grid; grid-template-columns: 1fr 220px auto; gap: .6rem; margin-bottom: 1.5rem; }
@media (max-width: 640px) { .searchbar { grid-template-columns: 1fr; } }

/* ---------- Page module ---------- */
.module-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .module-layout { grid-template-columns: 1fr; } }
.buybox { position: sticky; top: 84px; }
.buybox .price { font-size: 1.8rem; display: block; margin-bottom: .75rem; }
.clist { list-style: none; margin: 0; padding: 0; }
.clist li { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.clist li:first-child { border-top: 0; }
.ctype { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 1rem; background: var(--brand-soft); }
.ctype.document { background: #e6eefb; }
.ctype.summary { background: var(--gold-soft); }
.clist .title { flex: 1; min-width: 0; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Lecteur ---------- */
.learn-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .learn-layout { grid-template-columns: 1fr; } .learn-side { order: 2; } }
.player { background: #0b1511; border-radius: var(--radius); overflow: hidden; }
.player video { width: 100%; max-height: 72vh; background: #000; }
.doc-frame { width: 100%; height: 78vh; border: 0; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); }
.learn-side .clist a { color: inherit; display: flex; align-items: center; gap: .65rem; width: 100%; padding: .2rem .4rem; border-radius: 10px; }
.learn-side .clist a:hover { background: var(--brand-soft); text-decoration: none; }
.learn-side .clist a.current { background: var(--brand-soft); font-weight: 600; }
.learn-side .clist .locked { opacity: .5; display: flex; gap: .65rem; align-items: center; padding: .2rem .4rem; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: .75rem .9rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbf8; font-weight: 600; }
[dir="rtl"] th { text-transform: none; letter-spacing: 0; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }
td .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
td form { margin: 0; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; direction: ltr; unicode-bidi: embed; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .k { font-size: .82rem; color: var(--muted); }
.stat .v { font-family: var(--font-head); font-weight: 700; font-size: 1.6rem; line-height: 1.2; margin-top: .2rem; }
.stat.hl { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat.hl .k { color: #bcd6c8; }
a.stat { color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--brand); }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .6rem .9rem; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--brand); }

/* Paiement */
.paybox { display: grid; gap: .6rem; margin: .75rem 0 0; }
.payop { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfa; }
.payop strong { font-family: var(--font-head); }
.payop .num { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; direction: ltr; unicode-bidi: embed; }
.amount-big { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; color: var(--brand); }

/* Upload */
.progress { height: 10px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; margin-top: .75rem; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.upload-status { font-size: .9rem; margin-top: .4rem; color: var(--muted); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--card); }

/* ---------- Pied de page ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--muted); font-size: .9rem; margin-top: 2rem; }
.site-footer .container { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.auth-wrap { padding-top: 2.5rem; padding-bottom: 3rem; }
.auth-wrap .card { padding: 1.75rem; }
.wa { color: #128c4b; font-weight: 600; }

/* Filtres (abonnements) */
.filters { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr 1fr auto; gap: .75rem; align-items: end; }
.filters label { font-size: .82rem; }
input[type=date] { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: .6rem .7rem; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .filters { grid-template-columns: 1fr; } }
tfoot td { border-top: 2px solid var(--line); border-bottom: 0; }

/* Conditions d'un professeur (admin) */
.terms { display: flex; gap: .4rem; align-items: flex-end; flex-wrap: nowrap; }
.terms label { display: flex; flex-direction: column; gap: .15rem; font-size: .72rem; font-weight: 600; color: var(--muted); margin: 0; }
.terms input { width: 78px; padding: .35rem .5rem; }
