/* Composants d'interface d'Educatii (formulaires, fenêtres, notifications, dépôt de fichiers) : champs larges et
   lisibles, retours immédiats, animations courtes (désactivées si l'utilisateur réduit les animations). */

/* ------------------------------------------------------------ champs */
.ux-form { display: grid; gap: 18px; }
.ux-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 2.4vw, 24px); display: grid; gap: 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.ux-card__head { display: flex; align-items: center; gap: 12px; }
.ux-card__head h2, .ux-card__head h3 { margin: 0; font-size: 1.05rem; }
.ux-card__head p { margin: 2px 0 0; color: var(--ink-3); font-size: .85rem; }
.ux-step { flex: none; width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 800; font-size: 1.05rem; }
.ux-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.ux-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .ux-grid, .ux-grid--3 { grid-template-columns: 1fr; } }
.ux-span { grid-column: 1 / -1; }
.ux-field { display: grid; gap: 6px; min-width: 0; }
.ux-field > label, .ux-label { font-weight: 700; font-size: .86rem; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }
.ux-field > label small { font-weight: 500; color: var(--ink-3); }
.ux-input { width: 100%; min-height: 50px; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg-2); color: var(--ink); font: 500 1rem var(--font-body); transition: border-color .15s, box-shadow .15s, background .15s; -webkit-appearance: none; appearance: none; }
textarea.ux-input { min-height: 140px; resize: vertical; line-height: 1.55; }
select.ux-input { 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='%23667085' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 42px; }
.ux-input::placeholder { color: var(--ink-3); opacity: .8; }
.ux-input:hover { border-color: color-mix(in oklab, var(--brand) 30%, var(--line)); }
.ux-input:focus { outline: 0; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in oklab, var(--brand) 16%, transparent); }
.ux-input[aria-invalid="true"], .ux-field.is-invalid .ux-input { border-color: #dc2626; box-shadow: 0 0 0 4px rgba(220, 38, 38, .12); }
.ux-help { color: var(--ink-3); font-size: .8rem; margin: 0; }
.ux-err { color: #b91c1c; font-size: .82rem; font-weight: 600; margin: 0; }
.ux-err:empty { display: none; }
.ux-count { font-weight: 500; color: var(--ink-3); font-size: .78rem; }
.ux-count.is-near { color: #c2410c; }
.ux-affix { position: relative; }
.ux-affix .ux-input { padding-right: 70px; }
.ux-affix > span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 700; font-size: .85rem; pointer-events: none; }
.ux-affix > button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 8px; border-radius: 10px; font-size: 1rem; }
.ux-affix > button:hover { background: var(--line); }

/* choix en tuiles (radio ou cases) */
.ux-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; border: 0; padding: 0; margin: 0; }
.ux-tile { position: relative; cursor: pointer; }
.ux-tile input { position: absolute; opacity: 0; pointer-events: none; }
.ux-tile > span { display: grid; gap: 4px; height: 100%; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); transition: border-color .15s, background .15s, transform .15s, box-shadow .15s; }
.ux-tile i { font-style: normal; font-size: 1.5rem; line-height: 1; }
.ux-tile b { font-size: .95rem; }
.ux-tile small { color: var(--ink-3); font-size: .8rem; line-height: 1.35; }
.ux-tile:hover > span { border-color: color-mix(in oklab, var(--brand) 40%, var(--line)); transform: translateY(-1px); }
.ux-tile input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand) inset; }
.ux-tile input:checked + span::after { content: "✓"; position: absolute; top: 10px; right: 12px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: .75rem; font-weight: 800; }
.ux-tile input:focus-visible + span { outline: 3px solid color-mix(in oklab, var(--brand) 45%, #fff); outline-offset: 2px; }

/* pastilles à cocher */
.ux-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ux-chip { position: relative; cursor: pointer; }
.ux-chip input { position: absolute; opacity: 0; pointer-events: none; }
.ux-chip > span { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: .88rem; color: var(--ink-2); transition: .15s; user-select: none; }
.ux-chip:hover > span { border-color: color-mix(in oklab, var(--brand) 45%, var(--line)); }
.ux-chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.ux-chip input:checked + span::before { content: "✓"; font-weight: 800; }
.ux-chip input:focus-visible + span { outline: 3px solid color-mix(in oklab, var(--brand) 45%, #fff); outline-offset: 2px; }

/* commande segmentée */
.ux-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.ux-seg label { position: relative; cursor: pointer; }
.ux-seg input { position: absolute; opacity: 0; pointer-events: none; }
.ux-seg span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: .88rem; color: var(--ink-2); transition: .15s; }
.ux-seg input:checked + span { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.ux-seg input:focus-visible + span { outline: 2px solid var(--brand); }

/* ------------------------------------------------------------ dépôt de fichiers */
.ux-drop { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 16px; padding: 18px; border: 2px dashed color-mix(in oklab, var(--brand) 35%, var(--line)); border-radius: 18px; background: color-mix(in oklab, var(--brand-soft) 45%, var(--surface)); cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.ux-drop:hover, .ux-drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.ux-drop.is-over { transform: scale(1.01); }
.ux-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.ux-drop__thumb { width: 84px; height: 84px; border-radius: 16px; background: var(--surface) center / cover no-repeat; display: grid; place-items: center; font-size: 2rem; box-shadow: 0 2px 8px rgba(16, 24, 40, .08); }
.ux-drop__txt { display: grid; gap: 3px; min-width: 0; }
.ux-drop__txt b { font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ux-drop__txt small { color: var(--ink-3); }
.ux-drop.has-file { border-style: solid; border-color: #10b981; background: #f0fdf4; }
.ux-drop__clear { position: relative; z-index: 2; justify-self: end; grid-column: 2; border: 0; background: var(--surface); border-radius: 999px; padding: 6px 12px; font: 600 .8rem var(--font-body); color: var(--ink-2); cursor: pointer; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.ux-drop__clear[hidden] { display: none; }

/* ------------------------------------------------------------ boutons occupés, actions collées */
.hz-btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.hz-btn.is-busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: ux-spin .7s linear infinite; }
.hz-btn--outline.is-busy::after { border-color: var(--line); border-top-color: var(--brand); }
@keyframes ux-spin { to { transform: rotate(360deg); } }
.ux-actions { position: sticky; bottom: calc(var(--tabs-h, 0px) + 10px); z-index: 5; display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 12px; border-radius: 18px; background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(16, 24, 40, .1); }
.ux-actions .ux-help { margin-right: auto; }

/* ------------------------------------------------------------ fenêtres (dialog) : centrées, en feuille sur téléphone */
dialog.ux-dialog { border: 0; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: min(86vh, 860px); border-radius: 24px; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(10, 6, 30, .35); overflow: hidden; }
dialog.ux-dialog[open] { display: flex; flex-direction: column; animation: ux-pop .22s cubic-bezier(.2, .9, .3, 1.2) both; }
dialog.ux-dialog::backdrop { background: rgba(10, 6, 30, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes ux-pop { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.ux-dialog__head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; }
.ux-dialog__head h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.ux-dialog__body { padding: 0 20px 16px; overflow-y: auto; display: grid; gap: 14px; }
.ux-dialog__foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg-2); }
.ux-x { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg-2); color: var(--ink); cursor: pointer; font-size: 1rem; flex: none; }
.ux-x:hover { background: var(--line); }
@media (max-width: 640px) {
  dialog.ux-dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92vh; }
  dialog.ux-dialog[open] { animation: ux-sheet .25s cubic-bezier(.2, .9, .3, 1) both; }
  .ux-dialog__head::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
  .ux-dialog__head { padding-top: 24px; position: relative; }
}
@keyframes ux-sheet { from { transform: translateY(100%); } to { transform: none; } }

/* choix d'une durée (publication) */
.ux-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.ux-option { position: relative; cursor: pointer; }
.ux-option input { position: absolute; opacity: 0; }
.ux-option > span { display: grid; gap: 2px; padding: 14px; border-radius: 16px; border: 1.5px solid var(--line); text-align: center; transition: .15s; }
.ux-option b { font: 800 1.15rem var(--font-head); }
.ux-option small { color: var(--ink-3); font-weight: 600; }
.ux-option em { font-style: normal; font-size: .72rem; font-weight: 800; color: #047857; }
.ux-option input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand) inset; }
.ux-option input:focus-visible + span { outline: 3px solid color-mix(in oklab, var(--brand) 45%, #fff); }
.ux-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-radius: 16px; background: var(--bg-2); font-weight: 700; }
.ux-total b { font: 800 1.4rem var(--font-head); color: var(--ink); }

/* ------------------------------------------------------------ notifications */
.ux-toasts { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); top: calc(var(--bar-h, 62px) + 12px); display: grid; gap: 8px; width: min(460px, calc(100vw - 24px)); pointer-events: none; }
.ux-toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 12px 16px; border-radius: 16px; background: #111827; color: #fff; box-shadow: 0 16px 40px rgba(10, 6, 30, .3); animation: ux-toast-in .3s cubic-bezier(.2, .9, .3, 1.2) both; font-size: .92rem; line-height: 1.4; }
.ux-toast p { margin: 0; flex: 1; }
.ux-toast button { border: 0; background: rgba(255, 255, 255, .15); color: #fff; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; flex: none; }
.ux-toast.is-out { animation: ux-toast-out .25s ease both; }
.ux-toast--error { background: #991b1b; }
@keyframes ux-toast-in { from { opacity: 0; transform: translateY(-10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ux-toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ------------------------------------------------------------ aperçu en direct */
.ux-preview { position: sticky; top: calc(var(--bar-h, 62px) + 16px); display: grid; gap: 10px; align-content: start; }
.ux-preview > small { color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: .72rem; }
.ux-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
@media (max-width: 960px) { .ux-layout { grid-template-columns: 1fr; } .ux-preview { position: static; order: -1; max-width: 300px; } }

@media (prefers-reduced-motion: reduce) {
  dialog.ux-dialog[open], .ux-toast, .ux-tile > span, .ux-drop { animation: none !important; transition: none !important; }
}
.mk-card__media.has-img { background-size: cover !important; background-position: center !important; }
.mk-card__media.has-img > span[aria-hidden] { display: none; }
