/* ================================================================
   ANALJ Survey — Modern UI
   ================================================================ */

:root {
    /* Palette ANALJ */
    --green:        #0b6e4f;
    --green-dark:   #084d38;
    --green-light:  #14a06e;
    --green-soft:   #e6f3ee;
    --green-glow:   rgba(11, 110, 79, .12);
    --red:          #c1272d;

    /* Neutres */
    --bg:           #f0f4f2;
    --card:         #ffffff;
    --text:         #1a2420;
    --muted:        #6b7d76;
    --border:       #dce5e1;
    --border-light: #eaf0ec;

    /* Rayons & ombres */
    --radius:       20px;
    --radius-md:    14px;
    --radius-sm:    10px;
    --shadow-xs:    0 1px 2px rgba(15,40,30,.04);
    --shadow-sm:    0 2px 8px rgba(15,40,30,.06);
    --shadow-md:    0 8px 30px rgba(15,40,30,.08);
    --shadow-lg:    0 16px 48px rgba(15,40,30,.10);

    /* Couleurs par rôle */
    --c-director:     #0b6e4f;  --c-director-bg: #e6f3ee;
    --c-finance:      #b8860b;  --c-finance-bg:  #fdf3dc;
    --c-animator:     #1d6fa5;  --c-animator-bg: #e2f0fa;
    --c-psychologist: #7a3ba8;  --c-psychologist-bg: #f0e6f8;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Cairo', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== HEADER ===== */
.topbar {
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 50%, var(--green-light) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 24px rgba(8,77,56,.25);
}
.topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-badge {
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(6px);
    color: #fff;
    font-weight: 800;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    letter-spacing: .8px;
    border: 1px solid rgba(255,255,255,.18);
}
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-text strong { font-size: 1.05rem; font-weight: 700; }
.brand-text span { font-size: .8rem; opacity: .85; }

/* ===== LAYOUT ===== */
.page { max-width: 960px; margin: 0 auto; padding: 32px 20px 56px; }
.footer {
    text-align: center;
    color: var(--muted);
    font-size: .78rem;
    padding: 28px 16px 20px;
    letter-spacing: .3px;
}

/* ===== HERO — Index ===== */
.hero {
    text-align: center;
    padding: 20px 10px 4px;
}
.hero h1 {
    font-size: 1.85rem;
    margin: 0 0 8px;
    font-weight: 800;
    color: var(--green-dark);
}
.hero p {
    color: var(--muted);
    font-size: .95rem;
    max-width: 500px;
    margin: 0 auto;
}

/* ===== ROLE GRID — Index ===== */
.role-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-top: 32px;
}
@media (max-width: 700px) {
    .role-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (max-width: 480px) {
    .role-grid { grid-template-columns: 1fr; }
}
.role-card {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 18px 12px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .25s ease, border-color .2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}
.role-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    opacity: 0;
    transition: opacity .25s ease;
}
.role-card[data-role="director"]::before    { background: var(--c-director); }
.role-card[data-role="finance"]::before     { background: var(--c-finance); }
.role-card[data-role="animator"]::before    { background: var(--c-animator); }
.role-card[data-role="psychologist"]::before { background: var(--c-psychologist); }

.role-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}
.role-card:hover::before { opacity: 1; }

.role-name { font-weight: 700; font-size: .88rem; }
.role-cta {
    color: var(--green);
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .3px;
    transition: color .15s ease;
}
.role-card:hover .role-cta { color: var(--green-dark); }

/* ===== ICON CIRCLES ===== */
.role-icon-circle {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .2s ease;
}
.role-card:hover .role-icon-circle { transform: scale(1.06); }
.role-icon-circle svg { width: 22px; height: 22px; }
.role-icon-circle-sm { width: 42px; height: 42px; }
.role-icon-circle-sm svg { width: 22px; height: 22px; }

.role-accent-director      { background: var(--c-director-bg);      color: var(--c-director); }
.role-accent-finance       { background: var(--c-finance-bg);       color: var(--c-finance); }
.role-accent-animator      { background: var(--c-animator-bg);      color: var(--c-animator); }
.role-accent-psychologist  { background: var(--c-psychologist-bg);  color: var(--c-psychologist); }

/* ===== FORM — Survey page ===== */
.form-wrap {
    background: var(--card);
    border-radius: var(--radius);
    padding: 30px 26px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}
.form-title { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.form-title h1 { font-size: 1.35rem; margin: 0; font-weight: 800; color: var(--green-dark); }
.subtitle { color: var(--muted); font-size: .88rem; margin-bottom: 24px; }

/* Fieldsets */
.block {
    border: none;
    border-radius: var(--radius-md);
    padding: 22px 20px 20px;
    margin-bottom: 20px;
    background: var(--bg);
}
.block legend {
    font-weight: 700;
    color: var(--green-dark);
    padding: 0 8px;
    font-size: .95rem;
    letter-spacing: .2px;
}
.block-subtitle {
    font-size: .88rem;
    color: #111;
    margin: -8px 0 14px;
    padding: 0 10px;
    font-weight: 700;
    text-align: center;
}

/* Fields */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: .88rem;
    color: var(--text);
}
.field input[type=text],
.field input[type=date],
.field select,
.field textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .9rem;
    background: #fff;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input[type=text]:focus,
.field input[type=date]:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--muted); opacity: .7; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

.req { color: var(--red); font-weight: 700; }

/* ===== CENTERS — Centre + dates par ligne, bouton sous le centre ===== */
.centers-list {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px 12px;
    align-items: end;
    margin-bottom: 14px;
}
.center-row { display: contents; }
.centers-list .field { margin-bottom: 0; }
.centers-list .field input[type=text] { font-size: .82rem; padding: 9px 12px; }
.centers-list .field input[type=date] { font-size: .82rem; padding: 9px 10px; }
.centers-list .field label { font-size: .78rem; margin-bottom: 4px; }
@media (max-width: 700px) {
    .centers-list { grid-template-columns: 1fr 1fr auto; }
    .centers-list .center-row .field:first-child { grid-column: 1 / -1; }
    .btn-remove-period { width: 38px; height: 38px; }
}
.btn-remove-period {
    width: 42px; height: 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--red);
    font-size: .9rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
    flex-shrink: 0;
}
.btn-remove-period:hover { border-color: var(--red); background: #fdf2f2; }
.btn-remove-period[hidden] {
    display: inline-block;
    visibility: hidden;
    pointer-events: none;
}
.btn-add-period {
    justify-self: start;
    align-self: end;
    background: transparent;
    color: var(--green);
    border: 1.5px dashed var(--green);
    border-radius: 999px;
    padding: 8px 20px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    white-space: nowrap;
}
.btn-add-period:hover { background: var(--green); color: #fff; border-style: solid; }

/* ===== LIKERT TABLE ===== */
.likert-table { display: flex; flex-direction: column; gap: 3px; }
.likert-head, .likert-row {
    display: grid;
    grid-template-columns: 2fr repeat(5, .6fr);
    align-items: center;
    gap: 6px;
}
.likert-head {
    padding: 8px 10px;
    font-size: .88rem;
    color: var(--green-dark);
    font-weight: 800;
    text-align: center;
    letter-spacing: .2px;
}
.likert-head-label { text-align: right; }
.likert-head-col { font-weight: 800; }
.likert-head-col small { display: block; font-weight: 700; font-size: .78rem; text-transform: none; letter-spacing: 0; }
.likert-row {
    padding: 12px 10px;
    border-radius: var(--radius-sm);
    transition: background .12s ease;
}
.likert-row:nth-child(even) { background: rgba(11,110,79,.04); }
.likert-row:hover { background: rgba(11,110,79,.07); }
.likert-row-label { font-size: .88rem; font-weight: 700; }
.likert-radio { display: flex; justify-content: center; }
.likert-radio input {
    width: 26px; height: 26px;
    accent-color: var(--green);
    cursor: pointer;
}

@media (max-width: 700px) {
    .likert-head-label, .likert-row-label { font-size: .78rem; }
    .likert-head, .likert-row { grid-template-columns: 1.5fr repeat(5, 1fr); gap: 4px; }
    .likert-head-col small { font-size: .7rem; }
}

/* ===== CHOICE PILLS ===== */
.choice-options { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: .85rem;
    background: #fff;
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
    user-select: none;
}
.choice-pill:hover { border-color: var(--green); background: var(--green-soft); }
.choice-pill:has(input:checked) {
    border-color: var(--green);
    background: var(--green);
    color: #fff;
    font-weight: 700;
}
.choice-pill:has(input:checked) input[type=radio] { filter: brightness(0) invert(1); }
.choice-pill input[type=radio] {
    accent-color: var(--green);
    width: 18px; height: 18px;
    margin: 0;
}
/* Cacher les rondelles radio dans les pills extra — le pill lui-même indique la sélection */
.block-extra .choice-pill input[type=radio] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.choice-pill-other { flex-wrap: wrap; padding: 8px 14px; }
.other-input {
    border: none;
    border-bottom: 1.5px solid var(--border);
    padding: 3px 8px;
    font-family: inherit;
    font-size: .85rem;
    min-width: 130px;
    max-width: 220px;
    color: var(--text);
}
.other-input:focus { outline: none; border-color: var(--green); }
.other-input:disabled { background: transparent; color: var(--muted); }

/* Block extra: champs texte plus courts */
.block-extra input[type=text] { max-width: 420px; }

/* ===== SUBMIT BUTTON ===== */
.submit-row { text-align: center; margin-top: 20px; }
.btn-submit {
    display: inline-block;
    background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
    color: #fff;
    border: none;
    padding: 14px 44px;
    border-radius: 999px;
    font-size: .95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 24px rgba(11,110,79,.28);
    transition: transform .15s ease, box-shadow .2s ease;
    letter-spacing: .3px;
}
.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(11,110,79,.35);
}
.btn-submit:active { transform: translateY(0); }

/* ===== ERRORS / THANKS ===== */
.error-list { color: var(--red); text-align: right; max-width: 520px; margin: 0 auto; font-size: .88rem; line-height: 1.9; }
.error-list li { margin-bottom: 4px; }

.thanks { padding: 48px 10px; }
.check-mark {
    width: 64px; height: 64px; line-height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--green-light));
    color: #fff;
    font-size: 1.8rem;
    margin: 0 auto 16px;
    box-shadow: 0 8px 30px rgba(11,110,79,.25);
    animation: scaleIn .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes scaleIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ===== STATS ===== */
.back-link { color: var(--green); font-size: .82rem; text-decoration: none; font-weight: 600; }
.back-link:hover { color: var(--green-dark); }

.stats-summary { margin: 26px auto 10px; max-width: 520px; }
.stat-card {
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}
.stat-card-total { text-align: center; align-items: center; }
.stat-card-total .stat-value { font-size: 2.4rem; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 700; }
.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--green-dark);
    line-height: 1.2;
    margin-top: 6px;
}
.stat-unit { font-size: .85rem; color: var(--muted); font-weight: 600; }
.stat-sub { font-size: .76rem; color: var(--muted); margin-top: 4px; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 4px 0 20px;
}
.stat-role-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-top: 26px;
}
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
    .stats-grid, .stat-role-grid { grid-template-columns: 1fr; }
}
.stat-role-card .stat-role-count { font-weight: 800; font-size: 1.15rem; }
.stat-role-card .stat-role-avg { font-size: .85rem; color: var(--muted); }
.stat-role-card .stat-role-centers { font-size: .78rem; color: var(--muted); }
.stat-role-card[data-role="director"]     .stat-role-count { color: var(--c-director); }
.stat-role-card[data-role="finance"]      .stat-role-count { color: var(--c-finance); }
.stat-role-card[data-role="animator"]     .stat-role-count { color: var(--c-animator); }
.stat-role-card[data-role="psychologist"] .stat-role-count { color: var(--c-psychologist); }

/* Barres */
.bar-row {
    display: grid;
    grid-template-columns: 1.25fr 2fr 56px;
    align-items: center;
    gap: 12px;
    padding: 7px 0;
}
@media (max-width: 620px) {
    .bar-row { grid-template-columns: 1fr; gap: 4px; padding: 10px 0; }
}
.bar-label { font-size: .85rem; font-weight: 600; }
.bar-n { color: var(--muted); font-weight: 400; font-size: .72rem; }
.bar-track {
    height: 10px;
    border-radius: 999px;
    background: #e6edea;
    overflow: hidden;
}
.bar-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--green);
    transition: width .4s ease;
}
.bar-fill.score-high { background: linear-gradient(90deg, var(--green), var(--green-light)); }
.bar-fill.score-mid  { background: #d99a1b; }
.bar-fill.score-low  { background: var(--red); }
.bar-value { text-align: center; font-weight: 700; font-size: .82rem; }

/* Questions à choix */
.choice-stat { margin-bottom: 18px; }
.choice-stat:last-child { margin-bottom: 0; }
.choice-stat-title { font-size: .9rem; font-weight: 700; color: var(--green-dark); margin: 0 0 6px; }

/* Réponses ouvertes */
.stat-answers { list-style: none; margin: 0; padding: 0; }
.stat-answers li {
    padding: 9px 2px;
    border-bottom: 1px solid var(--border-light);
    font-size: .86rem;
}
.stat-answers li:last-child { border-bottom: none; }
.ans-center { display: block; color: var(--muted); font-size: .74rem; margin-top: 2px; }

/* Tableaux */
.stat-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.stat-table th, .stat-table td {
    padding: 9px 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
}
.stat-table th { color: var(--muted); font-weight: 700; font-size: .76rem; }
.stat-table tbody tr:hover { background: var(--green-soft); }

.empty-state { color: var(--muted); font-size: .88rem; text-align: center; padding: 22px 10px; }

/* Footer nav */
.footer-nav { margin-bottom: 10px; }
.footer-nav a {
    color: var(--green);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 600;
}
.footer-nav a:hover { color: var(--green-dark); }
