/* =====================================================
   FN Leads Manager — Canale (feed broadcast stile WhatsApp)
   ===================================================== */

.fnc-wrap {
    max-width: 640px;
    margin: 40px auto;
    background: rgba(255,255,255,.97);
    border-radius: 16px;
    box-shadow: var(--fnlm-shadow, 0 8px 32px rgba(0,53,128,.14));
    overflow: hidden;
}

.fnc-header {
    background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
    padding: 22px 26px 18px;
    color: #fff;
}
.fnc-header h2 {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fnc-header p {
    margin: 0;
    font-size: .84rem;
    color: rgba(255,255,255,.85);
}

/* ---- FEED ---- */
.fnc-feed-scroll {
    max-height: 70vh;
    min-height: 320px;
    overflow-y: auto;
    padding: 18px 20px;
    background: #e9edf3 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><circle cx="4" cy="4" r="1.4" fill="%23ffffff" opacity="0.6"/></svg>');
    display: flex;
    flex-direction: column;
}
.fnc-feed-loader-top { text-align: center; padding: 10px 0; }
.fnc-feed-list { display: flex; flex-direction: column; gap: 14px; }

.fnc-empty {
    text-align: center;
    padding: 40px 10px;
    color: var(--fnlm-gray, #6b7280);
}
.fnc-empty i { font-size: 2rem; color: #25d366; margin-bottom: 10px; display: block; }

/* ---- SINGOLO MESSAGGIO ---- */
.fnc-post {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 92%;
}
.fnc-post-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #075e54, #128c7e);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
}
.fnc-post-bubble {
    background: #fff;
    border-radius: 4px 14px 14px 14px;
    padding: 10px 14px 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.12);
    min-width: 100px;
}
.fnc-post-author {
    font-size: .78rem;
    font-weight: 800;
    color: #075e54;
    margin-bottom: 4px;
}
.fnc-post-caption {
    font-size: .93rem;
    color: var(--fnlm-text, #1a2235);
    line-height: 1.4;
    white-space: pre-wrap;
}
.fnc-post-image {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin-bottom: 6px;
    cursor: zoom-in;
}
.fnc-post-video {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin-bottom: 6px;
    background: #000;
}
.fnc-post-audio-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: #075e54;
}
.fnc-post-audio { max-width: 240px; }
.fnc-post-link {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--fnlm-light, #f4f6f9);
    border: 1px solid var(--fnlm-border, #dde3ed);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    text-decoration: none !important;
    color: var(--fnlm-blue, #003580) !important;
    font-weight: 700;
    font-size: .9rem;
    word-break: break-word;
}
.fnc-post-link i { color: #25d366; }
.fnc-post-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}
.fnc-post-time {
    font-size: .72rem;
    color: #9aa5b1;
}
.fnc-post-delete {
    background: none;
    border: none;
    color: #c94b4b;
    cursor: pointer;
    font-size: .78rem;
    padding: 2px 4px;
    opacity: .55;
    transition: opacity .2s ease;
}
.fnc-post-delete:hover { opacity: 1; }

/* ---- COMPOSER (solo amministratore) ---- */
.fnc-composer {
    padding: 14px 20px;
    background: #f6f8fb;
    border-bottom: 1px solid var(--fnlm-border, #dde3ed);
}
.fnc-composer-text {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid var(--fnlm-border, #dde3ed);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: .92rem;
    font-family: inherit;
    resize: vertical;
    min-height: 44px;
}
.fnc-composer-text:focus { outline: none; border-color: #25d366; }
.fnc-composer-link {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.fnc-composer-link .fn-input { padding: 9px 12px; font-size: .88rem; }
.fnc-composer-preview {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--fnlm-border, #dde3ed);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: .85rem;
}
.fnc-composer-preview img { max-height: 60px; border-radius: 6px; }
.fnc-composer-preview video { max-height: 60px; border-radius: 6px; }
.fnc-composer-preview-remove {
    margin-left: auto;
    background: none;
    border: none;
    color: #c94b4b;
    cursor: pointer;
    font-size: .95rem;
}
.fnc-composer-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
}
.fnc-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--fnlm-border, #dde3ed);
    color: #075e54;
    cursor: pointer;
    font-size: .95rem;
    transition: var(--fnlm-trans, all .2s ease);
}
.fnc-tool-btn:hover { background: #e9f9ef; }
.fnc-tool-btn.is-active { background: #c94b4b; border-color: #c94b4b; color: #fff; }
.fnc-composer-spacer { flex: 1; }
.fnc-send-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #128c7e, #075e54);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    font-weight: 800;
    font-size: .9rem;
    cursor: pointer;
    transition: var(--fnlm-trans, all .2s ease);
}
.fnc-send-btn:disabled { opacity: .55; cursor: not-allowed; }
.fnc-send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.fnc-composer-msg {
    margin-top: 8px;
    font-size: .84rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
}
.fnc-composer-msg--error { background: #fdecec; color: #a11212; }
.fnc-composer-msg--success { background: #e9f9ef; color: #0d7a3d; }

/* ---- LIGHTBOX (immagine a schermo intero) ---- */
.fnc-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 30px;
    cursor: zoom-out;
}
.fnc-lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ---- GATE (email/telefono) ---- */
.fnc-gate-card .fn-auth-header h3 { display: flex; align-items: center; gap: 8px; }

/* I moduli del Canale ("Entra nel Canale" e accesso) usano la classe
   .fnc-auth-form: senza queste regole restano senza respiri interni
   (campi attaccati ai bordi della scheda e pulsante che sborda).
   Stessi spazi del modulo di accesso standard (.fn-auth-form). */
.fn-auth-card .fnc-auth-form { padding: 24px 28px 0; }
.fnc-auth-form .fn-input,
.fnc-auth-form .fn-auth-submit { box-sizing: border-box; }

/* ---- INVITO ALL'ISCRIZIONE (utente non registrato/non loggato) ---- */
.fnc-signup-body {
    padding: 24px 28px 28px;
    text-align: center;
}
.fnc-signup-body p {
    margin: 0 0 18px;
    color: var(--fnlm-text, #1a2235);
    font-size: .95rem;
}
.fnc-signup-btn {
    display: inline-flex;
    text-decoration: none;
}

/* ---- ICONA/LOGO DEL CANALE: piuma con il segno del messaggio ---- */
.fnc-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.fnc-icon .fnc-icon-msg {
    position: absolute;
    right: -.4em;
    bottom: -.28em;
    font-size: .42em;
    color: #128c7e;
    background: #fff;
    border-radius: 50%;
    width: 1.5em;
    height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 1px rgba(0,0,0,.1);
}

/* ---- MOBILE ---- */
@media (max-width: 640px) {
    /* Su telefono la scheda del Canale respira: margini ai lati e spazio
       in basso per la barra di navigazione fissa (~62px), così si vede
       tutto, casella di scrittura compresa. */
    .fnc-wrap { margin: 12px 10px 84px; border-radius: 14px; }
    .fnc-feed-scroll { max-height: calc(100vh - 360px); }
    .fnc-post { max-width: 100%; }
}

/* =====================================================
   ICONA FISSA (WIDGET FLOTTANTE), staccata dal contenuto della pagina
   ===================================================== */
.fnc-float-widget {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 999950;
}
.fnc-float-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: #fff;
    font-size: 1.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 22px rgba(7,94,84,.45);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.fnc-float-btn:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(7,94,84,.55); }
.fnc-float-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #e63946;
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    min-width: 21px;
    height: 21px;
    line-height: 1;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #fff;
}
.fnc-float-panel {
    position: absolute;
    right: 0;
    bottom: 76px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 570px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 18px 54px rgba(0,0,0,.3);
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px) scale(.97);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}
.fnc-float-widget.is-open .fnc-float-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.fnc-float-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.35);
    color: #fff;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fnc-float-close:hover { background: rgba(0,0,0,.5); }
.fnc-float-panel-body {
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.fnc-float-panel-body .fnc-wrap {
    margin: 0;
    border-radius: 16px;
    box-shadow: none;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.fnc-float-panel-body .fnc-feed-scroll { flex: 1 1 auto; max-height: none; min-height: 0; }
.fnc-float-panel-body .fn-auth-card {
    margin: 20px 16px;
    /* Non farsi comprimere dal pannello (che ha altezza fissa): la scheda
       mantiene la sua altezza naturale e il pannello scorre, così campi e
       pulsante restano sempre raggiungibili. */
    flex-shrink: 0;
}
/* Nel pannello flottante il modulo resta esattamente com'era (lì è già
   a posto): i nuovi respiri interni valgono solo per la pagina del Canale. */
.fnc-float-panel-body .fnc-auth-form { padding: 0; }
.fnc-float-loading {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}
.fnc-float-loading .fnb-spinner {
    display: inline-block;
    width: 26px;
    height: 26px;
    border: 3px solid rgba(7,94,84,.18);
    border-top-color: #128c7e;
    border-radius: 50%;
    animation: fnc-spin .7s linear infinite;
}
@keyframes fnc-spin { to { transform: rotate(360deg); } }
.fnc-float-error { padding: 30px; text-align: center; color: #a11212; }

/* La barra di navigazione in basso è alta ~62px su ≤860px:
   alza il widget e il pannello per non finire sotto di essa. */
@media (max-width: 860px) {
    .fnc-float-widget {
        bottom: 82px; /* 22px margine + 60px nav bar */
    }
    .fnc-float-panel {
        bottom: 82px;          /* sopra il pulsante widget */
        max-height: calc(100vh - 200px);
    }
    /* Riduci il margine della auth-card nel pannello per guadagnare spazio */
    .fnc-float-panel-body .fn-auth-card {
        margin: 16px 14px;
    }
}

/* Su schermi piccoli il pannello diventa full-width fisso */
@media (max-width: 640px) {
    .fnc-float-widget { right: 14px; bottom: 76px; } /* 14px + 62px nav bar */
    .fnc-float-btn { width: 54px; height: 54px; font-size: 1.5rem; }
    .fnc-float-panel {
        position: fixed;
        right: 8px;
        left: 8px;
        bottom: 140px; /* 76px widget-bottom + 54px pulsante + 10px gap */
        width: auto;
        height: calc(100vh - 164px); /* 76px basso + 26px top + 62px nav */
        max-height: none;
    }
    /* Scorri la auth-card se supera l'altezza del pannello */
    .fnc-float-panel-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .fnc-float-panel-body .fn-auth-card {
        margin: 12px 10px;
        flex-shrink: 0;
    }
}
