/**
 * File Name: afm-accordion.css
 * Path: /assets/css/afm-accordion.css
 * Plugin Name: All FAQ Manager
 *
 * Accordion a due livelli: categoria (afm-cat-*) + FAQ (afm-faq-*)
 * Colore primario: personalizzare --afm-color-primary
 */

/* ── Variabili ────────────────────────────────────────────── */

.afm-faq-wrapper {
    --afm-color-primary:    #333;
    --afm-color-hover:      #c0392b;  /* rosso teatro – cambia a piacere */
    --afm-color-border:     #e0e0e0;
    --afm-color-cat-bg:     #f5f5f5;
    --afm-color-cat-active: #e8e8e8;
    --afm-color-faq-bg:     #ffffff;
    --afm-radius:           2px;

    font-family: inherit;
    margin: 2rem 0;

    /* ── Larghezza stabile: il wrapper non si allarga/restringe
          quando i pannelli si aprono o si chiudono ─────────── */
    width: 100%;
    box-sizing: border-box;
}

/* ── Titolo opzionale ─────────────────────────────────────── */

.afm-faq-wrapper .afm-faq-title {
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

/* ── Icona +/- (CSS puro) ────────────────────────────────── */

.afm-icon {
    flex-shrink: 0;
    display: inline-block;
    width: 18px;
    height: 18px;
    position: relative;
    margin-left: auto;
}

.afm-icon::before,
.afm-icon::after {
    content: '';
    position: absolute;
    background: currentColor;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Barra orizzontale */
.afm-icon::before {
    top: 50%; left: 0;
    width: 100%; height: 2px;
    transform: translateY(-50%);
}

/* Barra verticale — sparisce quando aperto */
.afm-icon::after {
    top: 0; left: 50%;
    width: 2px; height: 100%;
    transform: translateX(-50%);
}

[aria-expanded="true"] .afm-icon::after {
    transform: translateX(-50%) rotate(90deg);
    opacity: 0;
}

/* ── Livello 1: Categoria ─────────────────────────────────── */

.afm-cat-accordion {
    background: var(--afm-color-cat-bg);
    border: 1px solid var(--afm-color-border);
    border-radius: var(--afm-radius);
    margin-bottom: 10px;
    /* larghezza fissa: non si adatta al contenuto aperto */
    width: 100%;
    box-sizing: border-box;
}

.afm-cat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 15px 20px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    color: var(--afm-color-primary);
    text-align: left;
    transition: background 0.2s, color 0.2s;
    letter-spacing: 0.04em;
    /* evita che il button stesso cresca oltre il padre */
    min-width: 0;
    overflow: hidden;
}

/* Il testo occupa lo spazio disponibile e va a capo su righe lunghe */
.afm-cat-header > span:first-child,
.afm-faq-header > span:first-child {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.afm-cat-header:hover,
.afm-cat-header:focus-visible {
    background: var(--afm-color-cat-active);
    color: var(--afm-color-hover);
    outline: none;
}

.afm-cat-header[aria-expanded="true"] {
    background: var(--afm-color-cat-active);
}

/* ── Corpo categoria (pannello collassabile) ──────────────── */

.afm-cat-body {
    padding: 12px 15px;
    background: var(--afm-color-faq-bg);
    border-top: 1px solid var(--afm-color-border);
    overflow: hidden;
    /* Evita che il contenuto allarghi il pannello oltre il wrapper */
    width: 100%;
    box-sizing: border-box;
}

.afm-cat-body[hidden] {
    display: none;
}

/* ── Livello 2: FAQ singola ───────────────────────────────── */

.afm-faq-item {
    border: 1px solid var(--afm-color-border);
    border-radius: var(--afm-radius);
    margin-bottom: 6px;
    background: var(--afm-color-faq-bg);
    width: 100%;
    box-sizing: border-box;
}

.afm-faq-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--afm-color-primary);
    text-align: left;
    transition: background 0.2s, color 0.2s;
    min-width: 0;
    overflow: hidden;
}

.afm-faq-header:hover,
.afm-faq-header:focus-visible {
    background: #fafafa;
    color: var(--afm-color-hover);
    outline: none;
}

/* ── Risposta ─────────────────────────────────────────────── */

.afm-faq-body {
    padding: 14px 15px;
    border-top: 1px solid var(--afm-color-border);
    color: #555;
    line-height: 1.7;
    overflow: hidden;
    /* Contenuto non può allargare il pannello */
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;        /* testo/img non escono lateralmente */
}

.afm-faq-body[hidden] {
    display: none;
}

.afm-faq-body p:first-child { margin-top: 0; }
.afm-faq-body p:last-child  { margin-bottom: 0; }

/* Immagini e altri contenuti inline non escono dal pannello */
.afm-faq-body img,
.afm-faq-body table,
.afm-faq-body iframe {
    max-width: 100%;
    height: auto;
}

/* ── CTA Buttons ─────────────────────────────────────────── */

.afm-cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--afm-color-border);
}

.afm-cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    background: var(--afm-color-primary);
    color: #fff;
    border: 2px solid var(--afm-color-primary);
    border-radius: var(--afm-radius);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.afm-cta-btn:hover,
.afm-cta-btn:focus-visible {
    background: transparent;
    color: var(--afm-color-hover);
    border-color: var(--afm-color-hover);
    outline: none;
}

/* Secondo pulsante (ogni pari): stile outline di default */
.afm-cta-buttons .afm-cta-btn:nth-child(2) {
    background: transparent;
    color: var(--afm-color-primary);
    border-color: var(--afm-color-primary);
}

.afm-cta-buttons .afm-cta-btn:nth-child(2):hover,
.afm-cta-buttons .afm-cta-btn:nth-child(2):focus-visible {
    background: var(--afm-color-hover);
    color: #fff;
    border-color: var(--afm-color-hover);
}

/* ── Feedback Modal ──────────────────────────────────────── */

.afm-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.afm-modal[hidden] {
    display: none;
}

.afm-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

.afm-modal-box {
    position: relative;
    background: #fff;
    border-radius: 6px;
    padding: 32px 28px 24px;
    max-width: 460px;
    width: calc(100% - 32px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    text-align: center;
    z-index: 1;
}

.afm-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 4px;
    transition: color 0.15s;
}

.afm-modal-close:hover { color: #333; }

.afm-modal-box h3 {
    margin: 0 0 20px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
}

/* ── Stelle ──────────────────────────────────────────────── */

.afm-stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
}

.afm-star {
    background: none;
    border: none;
    font-size: 2rem;
    color: #ddd;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    transition: color 0.12s, transform 0.1s;
}

.afm-star:hover,
.afm-star.afm-star--hover,
.afm-star.afm-star--selected {
    color: #f5a623;
}

.afm-star:hover {
    transform: scale(1.15);
}

/* ── Invito "Aiutaci a migliorare" ───────────────────────── */

.afm-feedback-invite {
    margin: 4px 0 8px;
    font-size: 0.92rem;
    font-weight: 600;
    color: #333;
}

/* ── Disclaimer (non è un canale di assistenza) ──────────── */

.afm-feedback-disclaimer {
    margin: -6px 0 16px;
    font-size: 0.76rem;
    line-height: 1.45;
    color: #777;
}

/* ── Campo messaggio ─────────────────────────────────────── */

.afm-feedback-message {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 16px;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.88rem;
    color: #333;
    resize: vertical;
    line-height: 1.5;
    transition: border-color 0.15s;
}

.afm-feedback-message:focus {
    outline: none;
    border-color: #999;
}

/* ── Pulsante Invia ──────────────────────────────────────── */

.afm-feedback-submit {
    display: inline-block;
    padding: 9px 28px;
    background: var(--afm-color-primary, #333);
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.afm-feedback-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.afm-feedback-submit:not(:disabled):hover {
    opacity: 0.85;
}

/* ── Messaggio di ringraziamento ─────────────────────────── */

.afm-modal-thankyou {
    padding: 8px 0;
}

.afm-modal-thankyou p {
    font-size: 1.05rem;
    color: #3a7d44;
    font-weight: 600;
    margin: 0;
}

.afm-modal-thankyou[hidden] { display: none; }

/* ── Responsive ──────────────────────────────────────────── */

@media ( max-width: 768px ) {
    .afm-faq-wrapper {
        margin: 1rem 0;
    }
    .afm-cat-header {
        font-size: 0.9rem;
        padding: 12px 14px;
        letter-spacing: 0.02em;
    }
    .afm-faq-header {
        font-size: 0.88rem;
        padding: 11px 12px;
    }
    .afm-cat-body {
        padding: 8px 10px;
    }
    .afm-faq-body {
        padding: 12px 12px;
        font-size: 0.9rem;
    }
}

@media ( max-width: 480px ) {
    .afm-cat-header {
        font-size: 0.82rem;
        padding: 11px 12px;
    }
    .afm-faq-header {
        font-size: 0.8rem;
        padding: 10px 10px;
    }
    .afm-icon {
        width: 14px;
        height: 14px;
    }
}
