/* EmmaLLM — Feature Flags admin. Usa i token canonici di app.css (:root premium).
 * Colori semantici locali (i token globali --error/--info ecc. sono il fix CSS futuro). */
:root {
  --ff-error: #c0392b;
  --ff-be: #2b6cb0;     /* backend */
  --ff-fe: #7c4dff;     /* frontend */
  --ff-fs: var(--brand);/* fullstack = brand */
}

.ff-body {
    min-height: 100dvh;
    /* Override di app.css (`body { overflow: hidden }`, regola della chat) e di
       `html, body { height: 100% }`: questa pagina deve scrollare come la dashboard
       (fix: "la pagina feature flags non scrolla", 2026-06-12). */
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
}

.ff-panel, .ff-login { max-width: 880px; margin: 0 auto; padding: 24px 18px 64px; }

/* --- Header --- */
.ff-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ff-header__title h1 { font-size: 24px; font-weight: 800; letter-spacing: -.035em; color: var(--ink); margin: 0; }
.ff-header__counts { color: var(--text-2); font-size: 13px; margin: 4px 0 0; }
.ff-header__actions { display: flex; align-items: center; gap: 12px; }

.ff-conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-2); padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.ff-conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); transition: background .22s var(--ease-premium); }
.ff-conn[data-state="connected"] .ff-conn__dot { background: var(--brand); }
.ff-conn[data-state="polling"] .ff-conn__dot { background: #c98a14; }
.ff-conn[data-state="offline"] .ff-conn__dot { background: var(--ff-error); }

/* --- Bottoni --- */
.ff-btn { font: inherit; font-weight: 700; border-radius: var(--radius-sm); padding: 9px 16px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text); cursor: pointer; transition: transform .15s var(--ease-premium), box-shadow .15s var(--ease-premium), background .15s var(--ease-premium); }
.ff-btn:hover { transform: translateY(-1px); }
.ff-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(11,146,133,.16); }
.ff-btn--primary { background: var(--brand); color: #fff; border-color: transparent; box-shadow: 0 12px 28px rgba(11,146,133,.20); }
.ff-btn--primary:hover { background: var(--brand-dark); }
.ff-btn--ghost { background: transparent; }
.ff-btn--danger { background: var(--ff-error); color: #fff; border-color: transparent; }

/* --- Toolbar / search --- */
.ff-toolbar { margin-bottom: 16px; }
.ff-search { width: 100%; font: inherit; padding: 10px 14px; border-radius: var(--radius-sm); border: 2px solid var(--brand-20); background: var(--surface-solid); caret-color: var(--brand); }
.ff-search:focus-visible { outline: none; border-color: var(--brand-40); box-shadow: 0 0 0 4px rgba(11,146,133,.11); }

/* --- Sezioni --- */
.ff-section { margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-soft); }
.ff-section__head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: none; border: 0; cursor: pointer; font: inherit; }
.ff-section__name { font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.ff-section__count { font-size: 12px; color: var(--text-3); font-weight: 700; }
.ff-section__body { padding: 0 16px 8px; }
.ff-section[aria-expanded="false"] .ff-section__body { display: none; }

/* --- Card flag --- */
.ff-card { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.ff-card:first-child { border-top: 0; }
.ff-card__main { flex: 1; min-width: 0; }
.ff-card__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ff-card__key { font-family: var(--font-mono, monospace); font-size: 13px; color: var(--brand-dark); }
.ff-card__name { font-weight: 700; color: var(--text); }
.ff-card__desc { font-size: 13px; color: var(--text-2); margin: 3px 0 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ff-card__iter { font-size: 11px; color: var(--text-3); }
.ff-card__actions { display: flex; align-items: center; gap: 12px; }

.ff-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; color: #fff; }
.ff-badge--backend { background: var(--ff-be); }
.ff-badge--frontend { background: var(--ff-fe); }
.ff-badge--fullstack { background: var(--ff-fs); }

/* --- Switch --- */
.ff-switch { position: relative; width: 46px; height: 26px; flex: none; cursor: pointer; }
.ff-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.ff-switch__track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .22s var(--ease-premium); }
.ff-switch__thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(7,33,30,.25); transition: transform .22s var(--ease-premium); }
.ff-switch input:checked ~ .ff-switch__track { background: var(--brand); }
.ff-switch input:checked ~ .ff-switch__thumb { transform: translateX(20px); }
.ff-switch input:focus-visible ~ .ff-switch__track { box-shadow: 0 0 0 4px rgba(11,146,133,.16); }
.ff-delete { background: none; border: 0; cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 8px; }
.ff-delete:hover { color: var(--ff-error); background: rgba(192,57,43,.06); }

.ff-empty { text-align: center; color: var(--text-2); padding: 40px 0; }

/* --- Modali --- */
.ff-modal-backdrop { position: fixed; inset: 0; background: rgba(5,18,17,.26); backdrop-filter: blur(10px) saturate(1.08); z-index: 94; }
.ff-modal { position: fixed; z-index: 95; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(560px, 94vw); max-height: 90vh; overflow: auto; background: linear-gradient(180deg, #fff, rgba(247,252,251,.96)); border-radius: 30px; box-shadow: var(--shadow-strong); padding: 24px; }
.ff-modal--sm { width: min(420px, 94vw); }
.ff-modal__title { font-size: 18.5px; font-weight: 800; letter-spacing: -.035em; color: var(--ink); margin: 0 0 16px; }
.ff-confirm__text { color: var(--text-2); font-size: 14px; }

/* --- Form --- */
.ff-form, .ff-login__card { display: flex; flex-direction: column; gap: 12px; }
.ff-field { display: flex; flex-direction: column; gap: 5px; }
.ff-field > span { font-size: 12px; font-weight: 700; color: var(--text-2); }
.ff-field input, .ff-field select, .ff-field textarea { font: inherit; padding: 9px 12px; border-radius: var(--radius-sm); border: 2px solid var(--brand-20); background: var(--surface-solid); caret-color: var(--brand); }
.ff-field input:focus-visible, .ff-field select:focus-visible, .ff-field textarea:focus-visible { outline: none; border-color: var(--brand-40); box-shadow: 0 0 0 4px rgba(11,146,133,.11); }
.ff-field__help { font-size: 11px; color: var(--text-3); }
.ff-form__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* --- Login gate --- */
.ff-login { display: flex; align-items: center; justify-content: center; min-height: 80dvh; }
.ff-login__card { width: min(380px, 92vw); background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.ff-login__title { font-size: 22px; font-weight: 800; letter-spacing: -.035em; color: var(--ink); margin: 0; }
.ff-login__hint { color: var(--text-2); font-size: 13px; margin: 6px 0 14px; }
.ff-login__submit { margin-top: 8px; }
.ff-login__error { color: var(--ff-error); font-size: 13px; margin: 0; }

/* --- Toast --- */
.ff-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow-strong); z-index: 99; font-size: 14px; }

@media (max-width: 639px) {
  .ff-header { flex-direction: column; }
  .ff-card { flex-wrap: wrap; }
}

/* Sezione Developer (RF-11) */
.ff-devs { margin-top: 32px; padding-top: 24px; border-top: 1px solid rgba(0,0,0,.08); }
.ff-devs__head { margin-bottom: 14px; }
.ff-devs__title { margin: 0 0 4px; font-size: 18px; }
.ff-devs__hint { margin: 0; font-size: 13px; color: #667; }
.ff-devs__list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.ff-dev { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border: 1px solid rgba(0,0,0,.08); border-radius: 12px; background: #fff; }
.ff-dev__info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.ff-dev__email { font-weight: 650; word-break: break-all; }
.ff-dev__tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(11,146,133,.12); color: var(--brand-dark, #06695f); }
.ff-dev__tag--boot { background: rgba(120,120,120,.15); color: #555; }
.ff-dev__revoke { padding: 6px 12px; font-size: 13px; }
.ff-dev__revoke:disabled { opacity: .45; cursor: not-allowed; }
.ff-devs__forms { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ff-devs__form { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid rgba(0,0,0,.08); border-radius: 14px; background: rgba(0,0,0,.015); }
.ff-devs__form-title { margin: 0 0 4px; font-size: 14px; }
.ff-devs__form input { padding: 9px 12px; border: 1px solid rgba(0,0,0,.15); border-radius: 10px; font: inherit; }
.ff-devs__form .ff-btn { align-self: flex-start; }
@media (max-width: 639px) { .ff-devs__forms { grid-template-columns: 1fr; } }

/* Indicatore campo obbligatorio: asterisco sui campi con [required] (UX, iter. 08) */
.ff-field:has(input[required], select[required]) > span::after {
    content: " *";
    color: #c72a2a;
    font-weight: 700;
}
.ff-back { text-decoration: none; }
