/* ==========================================================================
   etablissement.ma — Institutional Design System · Core
   Tokens · base · layout · shared components
   Loaded by every surface (public site, platform, admin, super admin).
   All spacing uses logical properties so the same rules work in RTL and LTR.
   ========================================================================== */

/* -------------------------------------------------------------------------
   1. Tokens
   ------------------------------------------------------------------------- */
:root {
    /* Brand — institutional green */
    --brand-950: #052A24;
    --brand-900: #083F35;
    --brand-800: #0B5A4A;
    --brand-700: #0F7560;
    --brand-600: #159077;
    --brand-200: #BCDFD3;
    --brand-100: #DCEFE8;
    --brand-50:  #EFF8F4;

    /* Accent — saffron, for markers and highlights only */
    --accent-700: #8F5400;
    --accent-600: #C27803;
    --accent-500: #E39B12;
    --accent-300: #F6CF7A;
    --accent-100: #FDF3DC;

    /* Neutrals (cool slate) */
    --ink:      #121826;
    --gray-700: #374151;
    --gray-600: #4B5563;
    --gray-500: #6B7280;
    --gray-400: #9CA3AF;
    --gray-300: #D1D5DB;
    --gray-200: #E5E7EB;
    --gray-100: #F1F3F6;
    --gray-50:  #F8F9FB;
    --paper:    #F5F8F7;
    --white:    #FFFFFF;

    /* Status */
    --success: #1E7146; --success-bg: #E7F3EC;
    --warning: #8F5A0B; --warning-bg: #FBF1DE;
    --danger:  #A8261B; --danger-bg:  #FBEAE8;
    --info:    #1D5A8E; --info-bg:    #E6EFF7;

    /* Semantic */
    --color-primary:       var(--brand-800);
    --color-primary-hover: var(--brand-900);
    --color-link:          var(--brand-700);
    --color-accent:        var(--accent-600);
    --color-text:          var(--ink);
    --color-text-muted:    var(--gray-600);
    --color-text-subtle:   #5B6472;   /* 5.9:1 on white, AA for small meta text */
    --color-border:        var(--gray-200);
    --color-border-strong: var(--gray-300);
    --color-surface:       var(--white);
    --color-surface-alt:   var(--gray-50);
    --color-bg:            var(--paper);
    --focus-ring:          0 0 0 3px rgba(21, 144, 119, .35);
    --focus-color:         var(--brand-600);   /* 3.9:1 on white: meets non-text contrast */

    /* Typography */
    --font-ar:       'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif;
    --font-fr:       'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
    --font-fr-head:  'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, sans-serif;
    --font-body:     var(--font-ar);
    --font-head:     var(--font-ar);
    --font-mono:     ui-monospace, 'SFMono-Regular', Consolas, monospace;

    --text-xs:   .75rem;
    --text-sm:   .875rem;
    --text-base: 1rem;
    --text-md:   1.0625rem;
    --text-lg:   1.1875rem;
    --text-xl:   1.375rem;
    --text-2xl:  1.75rem;
    --text-3xl:  clamp(1.75rem, 1.2rem + 1.8vw, 2.375rem);
    --text-title: clamp(1.25rem, 1.08rem + .6vw, 1.5rem);   /* section titles */

    --leading-tight: 1.3;
    --leading-head:  1.45;   /* Arabic headings need room for ascenders/descenders */
    --leading-base:  1.7;
    --leading-loose: 1.9;

    /* Spacing (4px base) */
    --space-1: .25rem;  --space-2: .5rem;  --space-3: .75rem; --space-4: 1rem;
    --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;   --space-10: 2.5rem;
    --space-12: 3rem;   --space-16: 4rem;

    /* Section rhythm: one value for every block on a page */
    --section-y:       clamp(2.25rem, 1.6rem + 2.4vw, 3.5rem);
    --section-y-tight: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem);

    /* Shape */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 999px;

    /* Elevation: layered, tinted with the brand ink so shadows read as depth, not grey haze */
    --shadow-xs: 0 1px 2px rgba(5, 42, 36, .06);
    --shadow-sm: 0 1px 2px rgba(5, 42, 36, .05), 0 2px 6px -1px rgba(5, 42, 36, .06);
    --shadow-md: 0 1px 2px rgba(5, 42, 36, .04), 0 10px 24px -10px rgba(5, 42, 36, .18);
    --shadow-lg: 0 2px 6px rgba(5, 42, 36, .06), 0 24px 56px -16px rgba(5, 42, 36, .30);

    /* Icon wells (feature icons, contact lines, menu icons) */
    --icon-well: 40px;
    --icon-well-radius: 12px;

    /* Interactive surfaces (cards, tiles): hover lift */
    --lift: translateY(-2px);

    /* Layout */
    --container:   1200px;
    --reading:     72ch;
    --gutter:      clamp(1rem, .6rem + 1.6vw, 2rem);

    /* Motion */
    --ease: cubic-bezier(.2, .6, .2, 1);
    --dur:  160ms;

    /* Signature pattern (8-point star, very faint) */
    --pattern-star-brand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%230F7560' stroke-opacity='.09' stroke-width='1'%3E%3Cpath d='M28 8l6 14 14 6-14 6-6 14-6-14-14-6 14-6z'/%3E%3Crect x='18' y='18' width='20' height='20' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
    --pattern-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23FFFFFF' stroke-width='1'%3E%3Cpath d='M28 8l6 14 14 6-14 6-6 14-6-14-14-6 14-6z'/%3E%3Crect x='18' y='18' width='20' height='20' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
}

/* Breakpoints (reference): sm 640 · md 768 · lg 1024 · xl 1280 */

:root[lang="fr"] {
    --font-body: var(--font-fr);
    --font-head: var(--font-fr-head);
}

/* -------------------------------------------------------------------------
   2. Base
   ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-base);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}
img, svg, video, iframe { max-width: 100%; display: block; }
img { height: auto; }
h1, h2, h3, h4, h5 { font-family: var(--font-head); line-height: var(--leading-head); margin: 0; color: var(--ink); font-weight: 700; }
:root[lang="fr"] h1, :root[lang="fr"] h2, :root[lang="fr"] h3 { line-height: var(--leading-tight); }
:root[lang="fr"] h1, :root[lang="fr"] h2 { letter-spacing: -.015em; }
p { margin: 0; }
a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus-color); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: var(--accent-300); color: var(--ink); }
[hidden], .is-hidden { display: none !important; }
.sr-only {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* -------------------------------------------------------------------------
   3. Layout
   ------------------------------------------------------------------------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.container--narrow { max-width: 880px; }
.reading { max-width: var(--reading); }
.stack > * + * { margin-block-start: var(--stack, var(--space-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster, var(--space-3)); }
.grid { display: grid; gap: var(--grid-gap, var(--space-6)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.split { display: grid; gap: var(--space-8); }
@media (min-width: 1024px) {
    .split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-10); }
}
.section { padding-block: var(--section-y); }
.section--tight { padding-block: var(--section-y-tight); }
.section--alt { background: var(--color-surface); border-block: 1px solid var(--color-border); }

/* Section heading — title with gold rule on the start side */
.section-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
    margin-block-end: var(--space-6); flex-wrap: wrap;
}
.section-head__title {
    font-size: var(--text-title); letter-spacing: -.005em;
    display: flex; align-items: center; gap: var(--space-3);
}
/* Marker: a small saffron lozenge, echoing the eight-pointed star of the logo */
.section-head__title::before {
    content: ''; flex-shrink: 0; width: 9px; height: 9px; border-radius: 2px;
    background: var(--accent-500); transform: rotate(45deg);
}
.section-head__sub { color: var(--color-text-muted); font-size: var(--text-sm); margin-block-start: var(--space-1); padding-inline-start: calc(9px + var(--space-3)); }
.section-head__link {
    font-weight: 600; font-size: var(--text-sm); display: inline-flex; align-items: center; gap: var(--space-2);
    min-height: 34px; padding: 0 var(--space-3); border-radius: var(--radius-full);
    color: var(--brand-800); background: var(--brand-50); text-decoration: none !important;
    transition: background var(--dur) var(--ease);
}
.section-head__link:hover { background: var(--brand-100); }
.section-head__link i { font-size: .75em; }

.eyebrow {
    font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--accent-700);
}
:root[lang="ar"] .eyebrow { letter-spacing: 0; text-transform: none; font-size: var(--text-sm); }
.muted { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); font-size: var(--text-sm); }

/* -------------------------------------------------------------------------
   4. Buttons
   ------------------------------------------------------------------------- */
.btn {
    --btn-bg: var(--color-surface); --btn-fg: var(--ink); --btn-bd: var(--color-border-strong);
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: 42px; padding: 0 var(--space-5);
    font-weight: 700; font-size: var(--text-sm); line-height: 1; white-space: nowrap;
    color: var(--btn-fg); background: var(--btn-bg); border: 1px solid var(--btn-bd); border-radius: var(--radius);
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
    text-decoration: none !important;
}
.btn:hover { --btn-bg: var(--gray-50); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn--primary { --btn-bg: var(--color-primary); --btn-fg: #fff; --btn-bd: var(--color-primary); }
.btn--primary:hover { --btn-bg: var(--color-primary-hover); --btn-bd: var(--color-primary-hover); }
.btn--accent { --btn-bg: var(--accent-600); --btn-fg: #fff; --btn-bd: var(--accent-600); }
.btn--accent:hover { --btn-bg: var(--accent-700); --btn-bd: var(--accent-700); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--color-link); }
.btn--ghost:hover { --btn-bg: var(--brand-50); }
.btn--danger { --btn-fg: var(--danger); --btn-bd: #E9C1BC; }
.btn--danger:hover { --btn-bg: var(--danger-bg); }
.btn--danger-solid { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn--light { --btn-bg: #fff; --btn-fg: var(--brand-900); --btn-bd: #fff; }
.btn--light:hover { --btn-bg: var(--brand-50); --btn-bd: var(--brand-50); }
.btn--on-dark { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(255,255,255,.35); }
.btn--on-dark:hover { --btn-bg: rgba(255,255,255,.1); }
.btn--sm { min-height: 34px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn--lg { min-height: 50px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 38px; min-height: 38px; }
.btn--icon.btn--sm { width: 32px; min-height: 32px; }

.link-arrow { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; font-size: var(--text-sm); }
.link-arrow i { font-size: .8em; }

/* -------------------------------------------------------------------------
   5. Forms
   ------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.field__label { font-weight: 700; font-size: var(--text-sm); color: var(--gray-700); }
.field__label .req { color: var(--danger); margin-inline-start: 2px; }
.field__hint { font-size: var(--text-xs); color: var(--color-text-subtle); }
.field__msg { font-size: var(--text-xs); font-weight: 700; min-height: 1.2em; display: flex; align-items: center; gap: var(--space-2); }
.field__msg.is-ok { color: var(--success); }
.field__msg.is-error { color: var(--danger); }
.input, .select, .textarea {
    width: 100%; min-height: 44px; padding: var(--space-2) var(--space-3);
    font-size: var(--text-base); color: var(--ink);
    background: var(--white); border: 1px solid var(--color-border-strong); border-radius: var(--radius);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { min-height: 112px; line-height: var(--leading-base); resize: vertical; }
.select { appearance: none; padding-inline-end: var(--space-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2356615C' stroke-width='1.6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right var(--space-3) center; }
[dir="rtl"] .select { background-position: left var(--space-3) center; }
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-700); box-shadow: 0 0 0 3px rgba(21, 144, 119, .16); }
.input[readonly] { background: var(--gray-50); color: var(--gray-600); }
.input-group { display: flex; gap: var(--space-2); }
.input-group > .input { flex: 1; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; inset-inline-start: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.input-icon > .input { padding-inline-start: 2.4rem; }
.form-grid { display: grid; gap: var(--space-5); }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: 1 / -1; } }
.form-actions { display: flex; gap: var(--space-3); justify-content: flex-end; flex-wrap: wrap; }

.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-700); }

.dropzone {
    display: flex; align-items: center; gap: var(--space-4);
    padding: var(--space-4); border: 1px dashed var(--color-border-strong); border-radius: var(--radius);
    background: var(--gray-50);
}
.dropzone__preview { width: 72px; height: 72px; border-radius: var(--radius); object-fit: cover; background: var(--white); border: 1px solid var(--color-border); flex-shrink: 0; }
.dropzone__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }

/* Alerts / notices */
.notice {
    display: flex; gap: var(--space-3); align-items: flex-start;
    padding: var(--space-3) var(--space-4); border-radius: var(--radius);
    border: 1px solid var(--color-border); background: var(--gray-50); font-size: var(--text-sm);
}
.notice > i { margin-block-start: .2em; }
.notice--success { background: var(--success-bg); border-color: #BFDCCB; color: #14512F; }
.notice--error   { background: var(--danger-bg);  border-color: #EDC4BF; color: #7D1B12; }
.notice--warning { background: var(--warning-bg); border-color: #EBD3A6; color: #6A4208; }
.notice--info    { background: var(--info-bg);    border-color: #C3D6E8; color: #163F63; }
.notice a { font-weight: 700; color: inherit; text-decoration: underline; word-break: break-all; }

/* -------------------------------------------------------------------------
   6. Cards & content blocks
   ------------------------------------------------------------------------- */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    overflow: hidden; display: flex; flex-direction: column; min-width: 0;
}
.card__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.card__head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card__head h2, .card__head h3 { font-size: var(--text-md); }
.card__foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--gray-50); }

/* Article card (news) */
.article-card { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); position: relative; }
.article-card:hover { border-color: var(--brand-200); box-shadow: var(--shadow-md); }
.article-card__media { aspect-ratio: 16 / 9; background: var(--gray-100); overflow: hidden; }
.article-card__media img { width: 100%; height: 100%; object-fit: cover; }
.article-card__media--empty { display: grid; place-items: center; color: var(--brand-700); font-size: 1.75rem; background: var(--pattern-star-brand), linear-gradient(135deg, var(--brand-50), var(--brand-100)); }
.article-card__media--empty > i { opacity: .38; }
.article-card__meta { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; font-size: var(--text-xs); color: var(--color-text-subtle); }
.article-card__title { font-size: var(--text-md); line-height: 1.45; }
.article-card__title a { color: var(--ink); }
.article-card__title a::after { content: ''; position: absolute; inset: 0; }
.article-card__title a:hover { text-decoration: none; color: var(--brand-700); }
.article-card__excerpt { color: var(--color-text-muted); font-size: var(--text-sm); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* List rows (announcements, documents, agenda) */
.list { list-style: none; margin: 0; padding: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.list__item { position: relative; display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5); }
.list__item + .list__item { border-top: 1px solid var(--color-border); }
.list__item:hover { background: var(--gray-50); }
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list__title { font-weight: 700; color: var(--ink); line-height: 1.5; }
.list__title a { color: inherit; }
.list__title a::after { content: ''; position: absolute; inset: 0; }
.list__title a:hover { text-decoration: none; color: var(--brand-700); }
.list__meta { font-size: var(--text-xs); color: var(--color-text-subtle); display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.list__end { flex-shrink: 0; color: var(--gray-400); }
.list__end a, .list__end button { position: relative; z-index: 1; }

/* Date block */
.date-block {
    flex-shrink: 0; width: 56px; text-align: center; border: 1px solid var(--color-border);
    border-radius: var(--radius); overflow: hidden; background: var(--white); line-height: 1;
}
.date-block__day { display: block; font-size: 1.35rem; font-weight: 800; padding: var(--space-2) 0 var(--space-1); color: var(--brand-800); font-family: var(--font-ar); }
.date-block__month { display: block; font-size: 11px; font-weight: 700; padding: 4px 0; background: var(--brand-800); color: #fff; }

/* File icon */
.file-icon {
    width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center;
    border-radius: var(--radius); background: var(--accent-100); color: var(--accent-700); font-size: 1.05rem;
}

/* Badges */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; min-height: 22px;
    font-size: 11.5px; font-weight: 700; line-height: 1.4; border-radius: var(--radius-full);
    background: var(--gray-100); color: var(--gray-700); white-space: nowrap;
}
.badge--primary { background: var(--brand-100); color: var(--brand-800); }
.badge--gold    { background: var(--accent-100);  color: var(--accent-700); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--info    { background: var(--info-bg);    color: var(--info); }
.badge--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Figures (stats) */
.figure-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); }
.figure { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }
.figure + .figure { border-inline-start: 1px solid var(--color-border); }
.figure__value { font-size: var(--text-2xl); font-weight: 800; color: var(--brand-800); line-height: 1.1; font-family: var(--font-ar); font-variant-numeric: tabular-nums; }
.figure__label { font-size: var(--text-sm); color: var(--color-text-muted); }
@media (max-width: 560px) {
    .figure-row { grid-template-columns: 1fr 1fr; }
    .figure + .figure { border-inline-start: 0; }
    .figure:nth-child(even) { border-inline-start: 1px solid var(--color-border); }
    .figure:nth-child(n+3) { border-top: 1px solid var(--color-border); }
}

/* Empty state */
.empty {
    grid-column: 1 / -1; text-align: center; padding: var(--space-10) var(--space-6);
    color: var(--color-text-muted); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg); background: var(--color-surface);
}
.empty > i { font-size: 1.6rem; color: var(--gray-300); margin-block-end: var(--space-3); display: block; }
.empty__title { font-weight: 700; color: var(--gray-700); }
.empty__text { font-size: var(--text-sm); margin-block-start: var(--space-1); }
.empty .btn { margin-block-start: var(--space-4); }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%); background-size: 200% 100%; animation: etab-shimmer 1.4s linear infinite; border-radius: var(--radius-sm); }
@keyframes etab-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-card { height: 280px; border-radius: var(--radius-lg); }
.skeleton-row  { height: 64px; }
.skeleton-line { height: 12px; margin-block: 6px; }

.spinner { width: 22px; height: 22px; border: 2px solid var(--gray-200); border-top-color: var(--brand-700); border-radius: 50%; animation: etab-spin .7s linear infinite; display: inline-block; }
@keyframes etab-spin { to { transform: rotate(360deg); } }

/* Prose (rich content from editors) */
.prose { font-size: var(--text-md); line-height: var(--leading-loose); color: var(--gray-700); overflow-wrap: anywhere; }
.prose > * + * { margin-block-start: 1em; }
.prose h2, .prose h3 { margin-block-start: 1.6em; color: var(--ink); }
.prose h2 { font-size: var(--text-xl); } .prose h3 { font-size: var(--text-lg); }
.prose ul, .prose ol { padding-inline-start: 1.5em; }
.prose li + li { margin-block-start: .35em; }
.prose img { border-radius: var(--radius); margin-block: 1.4em; }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose blockquote { margin: 1.4em 0; padding-inline-start: var(--space-5); border-inline-start: 3px solid var(--accent-500); color: var(--gray-600); }
.prose .ql-align-center { text-align: center; } .prose .ql-align-right { text-align: right; } .prose .ql-align-left { text-align: left; } .prose .ql-align-justify { text-align: justify; }
.prose .ql-direction-rtl { direction: rtl; }

/* Tables */
.table-wrap { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: start; font-weight: 700; font-size: var(--text-xs); color: var(--gray-600); background: var(--gray-50); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--gray-50); }
.table .cell-title { font-weight: 700; color: var(--ink); }
.table .cell-sub { font-size: var(--text-xs); color: var(--color-text-subtle); font-weight: 400; }
.table .cell-actions { text-align: end; white-space: nowrap; }
.table .cell-actions .btn + .btn { margin-inline-start: var(--space-1); }
.table tr.is-unread td { background: var(--brand-50); }
.table tr.is-unread .cell-title::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-700); margin-inline-end: 8px; vertical-align: middle; }
.thumb { width: 52px; height: 38px; object-fit: cover; border-radius: var(--radius-sm); background: var(--gray-100); border: 1px solid var(--color-border); }
@media (max-width: 760px) {
    .table--stack thead { display: none; }
    .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
    .table--stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
    .table--stack tbody tr:last-child { border-bottom: 0; }
    .table--stack td { padding: 4px 0; border: 0; display: flex; gap: var(--space-3); justify-content: space-between; align-items: center; }
    .table--stack td[data-label]::before { content: attr(data-label); font-size: var(--text-xs); color: var(--color-text-subtle); font-weight: 700; }
    .table--stack td.cell-main { display: block; }
    .table--stack td.cell-main::before { display: none; }
    .table--stack .cell-actions { justify-content: flex-end; padding-top: var(--space-2); }
    .table--stack .cell-thumb { display: none; }
}

/* Tabs / segmented filters */
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
    min-height: 36px; padding: 0 var(--space-4); border-radius: var(--radius-full);
    border: 1px solid var(--color-border-strong); background: var(--white); color: var(--gray-700);
    font-size: var(--text-sm); font-weight: 700; display: inline-flex; align-items: center; gap: var(--space-2);
}
.chip:hover { border-color: var(--brand-700); color: var(--brand-800); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: var(--space-3) var(--space-4); font-weight: 700; font-size: var(--text-sm); color: var(--gray-600); white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--brand-800); border-bottom-color: var(--brand-800); }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: var(--space-1); flex-wrap: wrap; margin-block-start: var(--space-8); }
.pagination button, .pagination span {
    min-width: 40px; height: 40px; padding: 0 var(--space-2); display: inline-grid; place-items: center;
    border-radius: var(--radius); border: 1px solid var(--color-border); background: var(--white);
    font-weight: 700; font-size: var(--text-sm); color: var(--gray-700); font-family: var(--font-ar);
}
.pagination button:hover:not(:disabled) { border-color: var(--brand-700); color: var(--brand-800); }
.pagination button[aria-current="page"] { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination span { border-color: transparent; background: none; }

/* -------------------------------------------------------------------------
   7. Dialogs & toasts
   ------------------------------------------------------------------------- */
.dialog-backdrop {
    position: fixed; inset: 0; z-index: 200; background: color-mix(in srgb, var(--brand-950) 55%, transparent);
    display: flex; align-items: center; justify-content: center; padding: var(--space-4);
    animation: etab-fade var(--dur) var(--ease);
}
.dialog {
    background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; max-height: calc(100vh - 2rem); display: flex; flex-direction: column;
    animation: etab-rise 200ms var(--ease);
}
.dialog--lg { max-width: 880px; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--color-border); }
.dialog__title { font-size: var(--text-lg); }
.dialog__body { padding: var(--space-6); overflow-y: auto; flex: 1; }
.dialog__foot { display: flex; justify-content: flex-end; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); background: var(--gray-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.dialog__icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.15rem; margin-block-end: var(--space-3); }
.dialog__icon--danger { background: var(--danger-bg); color: var(--danger); }
.dialog__icon--warning { background: var(--warning-bg); color: var(--warning); }
.dialog__icon--info { background: var(--info-bg); color: var(--info); }
.dialog__icon--success { background: var(--success-bg); color: var(--success); }
@media (max-width: 640px) {
    .dialog-backdrop { padding: 0; align-items: flex-end; }
    .dialog { max-height: 94vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .dialog__body { padding: var(--space-5) var(--space-4); }
    .dialog__head, .dialog__foot { padding-inline: var(--space-4); }
    .dialog__foot .btn { flex: 1; }
}
@keyframes etab-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes etab-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.toasts { position: fixed; z-index: 300; inset-block-end: var(--space-5); inset-inline-start: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); max-width: calc(100vw - 2.5rem); }
.toast {
    display: flex; align-items: center; gap: var(--space-3); min-width: 260px; max-width: 420px;
    padding: var(--space-3) var(--space-4); background: var(--ink); color: #fff; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); font-size: var(--text-sm); font-weight: 600;
    animation: etab-rise 200ms var(--ease); transition: opacity 200ms var(--ease);
}
.toast > i { font-size: 1rem; }
.toast--success > i { color: #7FD3A5; }
.toast--error > i { color: #F4A39A; }
.toast--info > i { color: var(--accent-300); }

/* Language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--color-border-strong); border-radius: var(--radius); overflow: hidden; }
.lang-switch button { border: 0; background: transparent; padding: 0 var(--space-3); min-height: 32px; font-size: var(--text-xs); font-weight: 700; color: var(--gray-600); }
.lang-switch button[aria-pressed="true"] { background: var(--brand-800); color: #fff; }
.lang-switch--dark { border-color: rgba(255,255,255,.25); }
.lang-switch--dark button { color: rgba(255,255,255,.8); }
.lang-switch--dark button[aria-pressed="true"] { background: #fff; color: var(--brand-900); }

/* Platform mark (etablissement.ma signature) */
.etab-mark { direction: ltr; display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 800; letter-spacing: -.01em; color: inherit; font-family: var(--font-fr); }
.etab-mark__glyph { width: 30px; height: 30px; flex-shrink: 0; }
.etab-mark__tld { color: var(--accent-500); font-weight: 600; }

@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* Short user-entered labels keep the page alignment even when their own direction differs */
.cell-title[dir="auto"], .list__title[dir="auto"], .article-card__title[dir="auto"], .activity__title[dir="auto"],
.media-tile__foot [dir="auto"], .gallery__caption [dir="auto"], .table td[dir="auto"] { text-align: match-parent; }

/* Platform logo: the PNG has ~15% transparent margin on each side; scale it so the green
   square fills its box. Applied to the brand mark and to institutions without their own logo. */
.etab-logo { object-fit: contain; transform: scale(1.4); }
.etab-mark__glyph.etab-logo { border-radius: 6px; }

/* Section head: title and "view all" stay on one line; a long title wraps inside itself */
.section-head { flex-wrap: nowrap; align-items: center; }
.section-head > :first-child { min-width: 0; }
.section-head__link { flex-shrink: 0; }
