/*-----------------------------------------------------------------------------
 * Project : Ergane - Athena AI Hub
 * File    : public/css/components.css
 * Stylesheet : panels, shutters, tabs, chips, empty states, spinner, card grid, live region
 * Author  : Johann Sievering
 * AI Support : Claude AI
 * Date    : 2026-09-30 Start of the implementation
 * Rev     : patterns of prompt-atelier v2.4.6 components (.panel, .chip, .empty)
 * Rev     : 2026-09-30 Owner's review: Matériel AV's collapsible card head
 *           (triangle on the left), tabs with count badges, uppercase labels
 * Rev     : 2026-10-01 Owner's batch: icon row actions
 * Rev     : 2026-10-01 Icon buttons, password checklist, inline confirmation (owner's last list)
 * Rev     : 2026-10-01 The typeahead picker (owner's evening list)
 * Rev     : 2026-10-02 The tiles-or-list control
 * Rev     : 2026-10-03 The compact shutter, the search filter, the panel head with a button
 * Rev     : 2026-10-04 The daily limit and its renewal code (increment 25, D-51)
 * Rev     : 2026-10-05 Increment 29: microphones and the ✨ assistant beside every text field, the token tiles, the tabs and the menu, the privacy contact (D-54)
 * Rev     : 2026-10-07 The inline variant of the quota renewal: the text link and the form block under a row (owner's request)
 * Version : 0.43.0
 *-----------------------------------------------------------------------------
 * The small reusable blocks of chapter 14 §14.3 that exist in increment 2.
 * Tables (DataTable) live in table.css; the stepper and the radar arrive
 * with their modules.
 *---------------------------------------------------------------------------*/

.panel {
    padding: var(--space-5); margin-bottom: var(--space-5);
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

/* Collapsible card: a button head with the triangle on the left, the body hidden when closed. */
.shutter { padding: 0; }
.shutter__title { margin: 0; }
.shutter__head {
    display: flex; align-items: center; gap: var(--space-3); width: 100%;
    padding: var(--space-4) var(--space-5); font: inherit; font-weight: 600; font-size: var(--font-size-lg);
    color: var(--text); background: none; border: 0; border-radius: var(--radius-lg); cursor: pointer; text-align: left;
}
.shutter__head::before { content: '▼'; font-size: 0.75em; color: var(--text-light); }
.shutter__head[aria-expanded="false"]::before { content: '▶'; }
.shutter__head:hover { background: var(--gray-50); }
.shutter__body { padding: 0 var(--space-5) var(--space-5); border-top: 1px solid var(--border); }
.shutter__body > :first-child { margin-top: var(--space-4); }
.shutter__body[hidden] { display: none; }

/* Tabs with a count badge (Matériel AV's users tabs). */
.tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0 0 var(--space-4); padding: 0; list-style: none; border-bottom: 2px solid var(--border); }
.tab {
    display: inline-flex; align-items: center; gap: var(--space-2);
    min-height: 2.75rem; padding: var(--space-2) var(--space-4); margin-bottom: -2px;
    font: inherit; font-weight: 600; font-size: var(--font-size-md); color: var(--text-light);
    background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 1.75rem; padding: 0 var(--space-2); border-radius: var(--radius-pill);
    font-size: var(--font-size-xs); font-weight: 700; color: var(--text-light); background: var(--gray-50);
}
.tab[aria-selected="true"] .badge { color: #fff; background: var(--primary); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: var(--space-4); }
.card-grid .panel { margin: 0; }

.chip {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: 0.125rem var(--space-2); border-radius: var(--radius-pill);
    font-size: var(--font-size-xs); font-weight: 600;
    color: var(--primary-dark); background: var(--primary-soft);
}
.chip--accent { color: var(--accent-dark); background: var(--accent-soft); }
.chip--slate  { color: var(--olive-900); background: var(--olive-50); }
.chip--ok     { color: var(--success); background: var(--success-soft); }
.chip--warn   { color: var(--warning); background: var(--warning-soft); }
.chip--error  { color: var(--error); background: var(--error-soft); }

.swatch { display: inline-block; width: 0.9em; height: 0.9em; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); vertical-align: -0.1em; }

/* Row actions: small outlined icon buttons (Matériel AV's .dt-action). */
.dt__actions { display: inline-flex; gap: 0.25rem; align-items: center; }
.dt-action {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.9rem; height: 1.9rem; padding: 0;
    border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-light);
    text-decoration: none; cursor: pointer;
}
.dt-action:hover { background: var(--primary-soft); border-color: #B9D4EF; color: var(--primary); }
.dt-action--disabled, .dt-action:disabled { opacity: 0.4; cursor: default; }
.dt-action .icon, .icon { width: 1rem; height: 1rem; }

/* A square outlined icon button the height of an input (the eye of a password field). */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    width: 2.75rem; height: 2.75rem; padding: 0;
    color: var(--text-light); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
.icon-btn:hover, .icon-btn[aria-pressed="true"] { color: var(--primary); background: var(--primary-soft); border-color: #B9D4EF; }
.icon-btn .icon { width: 1.15rem; height: 1.15rem; }
/* The tiles-or-list control: two discreet icon buttons, the pressed one tinted (owner's request of 2 October). */
.view-toggle { display: inline-flex; gap: 2px; }
.view-toggle__btn { width: 2.25rem; height: 2.25rem; }
.view-toggle__btn .icon { width: 1rem; height: 1rem; }

/* The live password checklist (spec chapter 3 §3.7, shown under every password field). */
.pw-meter { margin-top: var(--space-2); }
.pw-meter__bar { height: 0.4rem; border-radius: var(--radius-pill); background: var(--gray-50); overflow: hidden; }
.pw-meter__bar span { display: block; height: 100%; width: 0; background: var(--error); transition: width 0.2s; }
.pw-meter__bar[data-level="medium"] span { background: var(--warning); }
.pw-meter__bar[data-level="ok"] span { background: var(--success); }
.pw-meter__bar[data-level="strong"] span { background: var(--primary); }
.pw-meter__label { margin: var(--space-1) 0; font-size: var(--font-size-xs); color: var(--text-light); }
.pw-meter__rules { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin: 0; padding: 0; list-style: none; font-size: var(--font-size-xs); }
.pw-meter__rules li { display: inline-flex; align-items: center; gap: 0.2rem; color: var(--text-light); }
.pw-meter__rules li.is-ok { color: var(--success); }
.pw-meter__rules .icon { width: 0.85rem; height: 0.85rem; }

/* The typeahead picker: an input and its option list, matches highlighted. */
.combobox { position: relative; flex: 1; min-width: 0; }
.combobox__list {
    position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: var(--z-menu);
    max-height: 16rem; overflow: auto; margin: 0; padding: var(--space-1) 0; list-style: none;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.combobox__list[hidden] { display: none; }
.combobox__option { padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--font-size-sm); }
.combobox__option:hover, .combobox__option.is-active { background: var(--primary-soft); }
.combobox__option.is-current { font-weight: 600; }
.combobox__option mark { background: #FFF1A8; color: inherit; padding: 0 1px; border-radius: 2px; }
.combobox__hint { color: var(--text-light); }
.combobox__empty { padding: var(--space-2) var(--space-3); color: var(--text-light); font-size: var(--font-size-sm); }

/* An in-page confirmation (never a browser dialog). */
/* The compact shutter: one line per previous version of a journal entry (owner's request of 3 October). */
.shutter--line { margin: 0; box-shadow: none; border: 1px solid var(--border); }
.shutter--line .shutter__head { padding: var(--space-2) var(--space-3); font-size: var(--font-size-sm); font-weight: 500; }
.shutter--line .shutter__body { padding: 0 var(--space-3) var(--space-3); }
.history-lines { display: grid; gap: var(--space-1); margin-top: var(--space-2); }
/* The search filter of the lists that are not a DataTable: the field, the RegEx box, the reset. */
.search-filter { margin: 0 0 var(--space-3); }
.search-filter__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.search-filter input[type="search"] { flex: 1 1 14rem; min-width: 0; }
.search-filter__regex { display: inline-flex; align-items: center; gap: 0.3rem; font-size: var(--font-size-sm); font-weight: 600; }
.search-filter__error { margin: var(--space-1) 0 0; font-size: var(--font-size-sm); color: var(--error); }
/* A panel title with a button at its right (« Effacer tout » beside « Construire »). */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.panel-head h2 { margin: 0; }
.inline-confirm .form-banner { margin: var(--space-2) 0; }
.inline-confirm .form-banner p { margin: 0 0 var(--space-2); font-weight: 600; }
.inline-confirm .actions { margin-top: 0; }

/* Empty state: one sentence + the next action (chapter 4 §4.0). */
.empty { padding: var(--space-5); text-align: center; color: var(--text-light); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .btn { margin-top: var(--space-3); }

.spinner {
    width: 1em; height: 1em; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin 0.8s linear infinite; vertical-align: -0.15em;
}
@keyframes spin { to { transform: rotate(360deg); } }

.definition { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-4); margin: 0; }
.definition dt { font-weight: 600; color: var(--text-light); }
.definition dd { margin: 0; }

.live-region { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 48rem) {
    .shutter__head { padding: var(--space-3) var(--space-4); font-size: var(--font-size-md); }
    .shutter__body { padding: 0 var(--space-4) var(--space-4); }
    .tab { padding: var(--space-2) var(--space-3); font-size: var(--font-size-sm); }
}

/* The renewal of a daily quota with the teachers' code (D-51): a discreet button, an inline form under the bar. */
.quota-renew { margin-top: var(--space-2); }
.quota-renew__form { margin-top: var(--space-2); display: grid; gap: var(--space-1); }
.quota-renew__row { display: flex; gap: var(--space-1); align-items: center; }
.quota-renew__row input { flex: 1; min-width: 0; }
.quota-renew__actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
/* The inline variant: a text link in a row of controls; its form opens in the block the page places under the row. */
.quota-renew--inline { margin-top: 0; display: inline-flex; }
.quota-renew__link { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: var(--font-size-sm); text-decoration: underline; cursor: pointer; }
.quota-renew__link:hover, .quota-renew__link:focus-visible { color: var(--primary-dark); }
.run-row__renew:not(:empty) { max-width: 28rem; padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); background: var(--gray-50); border-radius: var(--radius); }

/* ── The tool corner of a text field (D-54): the field wrapped, the microphone and the ✨ at its top right, the text padded away from them. ── */
.field-wrap { position: relative; display: block; }
.field-tools { position: absolute; top: 0.3rem; right: 0.35rem; display: flex; gap: 0.25rem; }
.field-wrap--line .field-tools { top: 50%; transform: translateY(-50%); }
.field-wrap--area > textarea, .field-wrap--line > input { padding-right: 2.9rem; }
.field-wrap--2.field-wrap--area > textarea, .field-wrap--2.field-wrap--line > input { padding-right: 5.3rem; }
.field-tools .icon-btn { width: 2rem; height: 2rem; margin: 0; background: var(--bg-card); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.field-tools .icon-btn .icon { width: 1.05rem; height: 1.05rem; }
.field-wrap--disabled .field-tools { display: none; }
/* Active states (owner's request of 5 October): the microphone pulses red while it listens, the ✨ glows and turns while the AI works. */
.dictation-btn.is-listening { color: #fff; background: var(--error); border-color: var(--error); animation: ergane-pulse 1.2s ease-out infinite; }
@keyframes ergane-pulse { 0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.55); } 70% { box-shadow: 0 0 0 0.6rem rgba(192, 57, 43, 0); } 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); } }
.assist-btn .icon { color: var(--orange); }
.assist-btn:hover { border-color: var(--orange); }
.assist-btn.is-busy { border-color: var(--orange); animation: ergane-glow 0.9s ease-in-out infinite alternate; }
.assist-btn.is-busy .icon { animation: ergane-spin 1.4s linear infinite; }
@keyframes ergane-glow { from { box-shadow: 0 0 0 0 rgba(133, 79, 11, 0); } to { box-shadow: 0 0 0 0.35rem rgba(133, 79, 11, 0.35); } }
@keyframes ergane-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dictation-btn.is-listening, .assist-btn.is-busy, .assist-btn.is-busy .icon { animation: none; } }
/* The suggestion box of the ✨ under a field (shared by the studio and every other page). */
.assist-box { margin: var(--space-2) 0; padding: var(--space-3); border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-card); font-size: var(--font-size-sm); }
.assist-box--suggest { border-color: var(--studio-purple, var(--primary)); background: var(--studio-purple-50, var(--primary-soft)); }
.assist-box--error { border-color: var(--error); background: var(--error-soft); }
.assist-box__lead { margin: 0 0 var(--space-1); font-weight: 700; color: var(--studio-purple, var(--primary)); }
.assist-box__text { margin: 0 0 var(--space-2); white-space: pre-wrap; }
.assist-box p:last-child { margin-bottom: 0; }

/* ── The post-its of the notifications (chapter 4 §4.19, D-60): in the page flow above the content, one per notification to confirm ── */
.notices { display: grid; gap: var(--space-3); margin: var(--space-3) 0; }
.notices:empty { display: none; }
.notice { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-left: 0.4rem solid var(--primary); border-radius: var(--radius); background: var(--primary-soft); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.06)); }
.notice--info { border-left-color: var(--primary); background: var(--primary-soft); }
.notice--demande { border-left-color: var(--accent); background: var(--accent-soft); }
.notice--alerte { border-left-color: var(--error); background: var(--error-soft); }
.notice--rappel { border-left-color: var(--warning); background: var(--warning-soft); }
.notice--preview { outline: 2px dashed var(--warning); outline-offset: 2px; }
.notice__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.notice__title { margin: 0; font-size: 1.1rem; flex: 1 1 auto; }
.notice__title:focus { outline: none; }
.notice__pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: #fff; background: var(--primary); }
.notice__pill--info { background: var(--primary); }
.notice__pill--demande { background: var(--accent-dark, var(--accent)); }
.notice__pill--alerte { background: var(--error); }
.notice__pill--rappel { background: var(--warning); }
.notice__meta { margin: 0.2rem 0 var(--space-2); font-size: 0.9rem; color: var(--text-light); }
.notice__body { color: var(--text); }
.notice__body > :first-child { margin-top: 0; }
.notice__body > :last-child { margin-bottom: 0; }
.notice__body a { text-decoration: underline; }
.notice__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); padding-top: var(--space-2); border-top: 1px dashed var(--border); }
.notice__ack { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; font-weight: 600; }
@media (max-width: 47.9rem) { .notices { margin: var(--space-3) var(--space-3) 0; } }
