/* =====================================================
   FN Leads Manager — Area Riservata (Login / Recupero / Dashboard)
   ===================================================== */

.fn-auth-card {
    max-width: 440px;
    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;
    padding: 0 0 28px;
}
.fn-auth-header {
    background: linear-gradient(135deg, var(--fnlm-blue, #003580) 0%, #0060cc 100%);
    padding: 26px 28px 22px;
    color: #fff;
}
.fn-auth-header h3 {
    margin: 0 0 6px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--fnlm-gold, #c8a040);
}
.fn-auth-header p {
    margin: 0;
    font-size: .92rem;
    color: rgba(255,255,255,.88);
}
.fn-auth-form {
    padding: 24px 28px 0;
}
.fn-auth-msg {
    margin: 18px 28px 0;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: .88rem;
    font-weight: 600;
    display: none;
}
.fn-auth-msg--error {
    background: #fdecec;
    color: #a11212;
    border: 1px solid #f3c6c6;
}
.fn-auth-msg--success {
    background: #e9f9ef;
    color: #0d7a3d;
    border: 1px solid #bfe9cf;
}
.fn-auth-form .fn-field-group {
    margin-bottom: 16px;
}
.fn-auth-form .fn-label {
    display: block;
    font-size: .82rem;
    font-weight: 700;
    color: var(--fnlm-text, #1a2235);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.fn-auth-form .fn-req { color: var(--fnlm-red, #cc0000); }
.fn-auth-form .fn-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1.5px solid var(--fnlm-border, #dde3ed);
    border-radius: 8px;
    font-size: .96rem;
    background: var(--fnlm-light, #f4f6f9);
    transition: var(--fnlm-trans, all .22s ease);
}
.fn-auth-form .fn-input:focus {
    outline: none;
    border-color: var(--fnlm-blue, #003580);
    background: #fff;
}
.fn-auth-link {
    display: inline-block;
    font-size: .85rem;
    color: var(--fnlm-blue, #003580);
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 18px;
}
.fn-auth-link:hover { text-decoration: underline; }
.fn-auth-footer {
    margin: 18px 0 0;
    text-align: center;
    font-size: .9rem;
    color: #555;
}
.fn-auth-footer .fn-auth-link {
    display: inline;
    margin: 0 0 0 4px;
}
.fn-auth-submit {
    width: 100%;
    padding: 15px 24px;
    background: linear-gradient(135deg, var(--fnlm-red, #cc0000) 0%, #a10000 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: .3px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(204,0,0,.3);
    transition: var(--fnlm-trans, all .22s ease);
}
.fn-auth-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(204,0,0,.4); }
.fn-auth-submit:disabled { opacity: .65; cursor: not-allowed; }

.fn-auth-btn {
    display: inline-block;
    margin: 4px 28px 0;
    padding: 12px 22px;
    background: var(--fnlm-blue, #003580);
    color: #fff !important;
    font-weight: 700;
    font-size: .92rem;
    border-radius: 50px;
    text-decoration: none !important;
}
.fn-auth-btn:hover { background: #0060cc; }
.fn-auth-error-standalone {
    margin: 24px 28px 4px;
    color: var(--fnlm-red, #cc0000);
    font-weight: 600;
    font-size: .92rem;
}

/* ---- DASHBOARD ---- */
.fn-dashboard-shell {
    max-width: 780px;
    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;
}
.fn-dashboard-header {
    background: linear-gradient(135deg, var(--fnlm-blue, #003580) 0%, #0060cc 100%);
    padding: 30px 32px 24px;
    color: #fff;
}
.fn-dashboard-header h2 {
    margin: 0 0 6px;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--fnlm-gold, #c8a040);
}
.fn-dashboard-header p { margin: 0; color: rgba(255,255,255,.88); }
.fn-dashboard-header-top { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.fn-dashboard-avatar { border: 3px solid rgba(255,255,255,.35); }
.fn-dashboard-change-photo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    font-size: .82rem;
    font-weight: 600;
    color: #fff !important;
    opacity: .9;
    text-decoration: underline !important;
}
.fn-dashboard-change-photo:hover { opacity: 1; }
.fn-dashboard-body { padding: 40px 32px; }

/* ---- FOTO PROFILO (pagina dedicata) ---- */
.fn-avatar-card { text-align: center; }
.fn-avatar-form { align-items: center; }
.fn-avatar-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 6px 0 18px;
}
.fn-avatar-preview {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--fnlm-light, #f4f6f9);
    border: 2px dashed var(--fnlm-border, #dde3ed);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--fnlm-gray, #6b7280);
    font-size: 2.2rem;
    transition: border-color .15s ease;
}
.fn-avatar-upload:hover .fn-avatar-preview { border-color: var(--fnlm-blue, #003580); }
.fn-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.fn-avatar-upload-label { font-weight: 700; font-size: .92rem; color: var(--fnlm-blue, #003580); display: flex; align-items: center; gap: 6px; }
.fn-avatar-upload small { color: var(--fnlm-gray, #6b7280); font-size: .78rem; }
.fn-avatar-skip { display: block; margin-top: 14px; font-size: .84rem; }
.fn-avatar-warning {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff4e0;
    border: 1px solid #f3c26a;
    color: #7a4d00;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: .86rem;
    font-weight: 600;
    text-align: left;
    margin-bottom: 18px;
}
.fn-avatar-warning i { font-size: 1.1rem; color: #c9840a; flex-shrink: 0; }

/* ---- CONTATTI E MESSAGGI: AVATAR ---- */
.fn-contact-item { align-items: center; }
.fn-contact-avatar {
    width: 38px; height: 38px; min-width: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fnlm-blue, #003580), #0060cc);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .82rem;
    margin-right: 10px;
}
.fn-contact-avatar--photo { object-fit: cover; }
.fn-contact-info { display: flex; flex-direction: column; }
.fn-contact-item.active .fn-contact-avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.6); }

.fn-msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.fn-msg-row.fn-msg-mine { align-self: flex-end; flex-direction: row-reverse; }
.fn-msg-row.fn-msg-theirs { align-self: flex-start; }
.fn-msg-avatar {
    width: 28px; height: 28px; min-width: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--fnlm-light, #f4f6f9);
}
.fn-msg-avatar--blank { display: flex; align-items: center; justify-content: center; color: var(--fnlm-gray, #6b7280); font-size: .8rem; }
.fn-dashboard-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.fn-dashboard-placeholder {
    text-align: center;
    padding: 50px 20px;
    border: 2px dashed var(--fnlm-border, #dde3ed);
    border-radius: 12px;
    color: var(--fnlm-gray, #6b7280);
}
.fn-dashboard-placeholder i { font-size: 2rem; margin-bottom: 14px; display: block; color: var(--fnlm-blue, #003580); }
.fn-dashboard-placeholder p { margin: 0; font-size: .96rem; }
.fn-dashboard-footer {
    padding: 18px 32px;
    background: var(--fnlm-light, #f4f6f9);
    border-top: 1px solid var(--fnlm-border, #dde3ed);
    text-align: right;
}
.fn-dashboard-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--fnlm-red, #cc0000);
    font-weight: 700;
    font-size: .88rem;
    text-decoration: none;
}
.fn-dashboard-logout:hover { text-decoration: underline; }
.fn-dashboard-locked {
    max-width: 480px;
    margin: 60px auto;
    text-align: center;
    background: #fff;
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: var(--fnlm-shadow, 0 8px 32px rgba(0,53,128,.14));
}
.fn-dashboard-locked p { color: var(--fnlm-text, #1a2235); font-weight: 600; margin-bottom: 18px; }

/* ---- INVITO ---- */
.fn-invite-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #003580 0%, #00214d 100%);
    color: #fff;
    padding: 22px 26px;
    border-radius: 14px;
    margin: 22px 0;
}
.fn-invite-card-text { display: flex; align-items: flex-start; gap: 14px; }
.fn-invite-card-text i { font-size: 1.8rem; color: #25D366; margin-top: 2px; }
.fn-invite-card-text strong { display: block; margin-bottom: 4px; font-size: 1.02rem; }
.fn-invite-card-text p { margin: 0; font-size: .88rem; color: rgba(255,255,255,.85); max-width: 420px; }
.fn-invite-wa-btn { background: #25D366 !important; color: #05310f !important; white-space: nowrap; }
.fn-invite-wa-btn:hover { background: #1ebc59 !important; }

/* ---- CONTATTI INVITATI ---- */
.fn-contacts-card {
    background: #fff;
    border: 1px solid var(--fnlm-border, #dde3ed);
    border-radius: 14px;
    padding: 20px 24px;
    margin: 0 0 22px;
}
.fn-contacts-card h3, .fn-messages-panel h3 {
    margin: 0 0 14px;
    font-size: 1.02rem;
    color: var(--fnlm-blue, #003580);
    display: flex;
    align-items: center;
    gap: 8px;
}
.fn-invited-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fn-invited-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--fnlm-light, #f4f6f9);
    border-radius: 8px;
    font-size: .92rem;
}
.fn-invited-name { font-weight: 600; color: var(--fnlm-text, #1a2235); }
.fn-invited-username { color: var(--fnlm-gray, #6b7280); }
.fn-invited-empty { margin: 0; color: var(--fnlm-gray, #6b7280); font-size: .92rem; }

/* ---- PULSANTE MESSAGGI (badge non letti) ---- */
.fn-msg-toggle-btn { position: relative; border: none; cursor: pointer; }
.fn-msg-total-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--fnlm-red, #cc0000);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    border-radius: 10px;
    text-align: center;
    padding: 0 5px;
}

/* ---- PANNELLO MESSAGGI ---- */
.fn-messages-panel {
    background: #fff;
    border: 1px solid var(--fnlm-border, #dde3ed);
    border-radius: 14px;
    padding: 20px 24px;
    margin-bottom: 22px;
}
.fn-messages-layout { display: flex; gap: 18px; min-height: 340px; }
.fn-contacts-list { width: 220px; flex-shrink: 0; border-right: 1px solid var(--fnlm-border, #dde3ed); padding-right: 14px; overflow-y: auto; max-height: 420px; }
.fn-contact-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    margin-bottom: 4px;
}
.fn-contact-item:hover { background: var(--fnlm-light, #f4f6f9); }
.fn-contact-item.active { background: var(--fnlm-blue, #003580); }
.fn-contact-item.active .fn-contact-name,
.fn-contact-item.active .fn-contact-username { color: #fff; }
.fn-contact-name { font-weight: 600; font-size: .9rem; color: var(--fnlm-text, #1a2235); }
.fn-contact-username { font-size: .78rem; color: var(--fnlm-gray, #6b7280); }
.fn-contact-unread {
    position: absolute;
    right: 10px;
    top: 10px;
    background: var(--fnlm-red, #cc0000);
    color: #fff;
    font-size: .7rem;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    text-align: center;
}
.fn-contacts-empty { font-size: .86rem; color: var(--fnlm-gray, #6b7280); }
.fn-msg-thread-wrap { flex: 1; display: flex; flex-direction: column; }
.fn-msg-thread { flex: 1; overflow-y: auto; max-height: 360px; padding: 4px 8px; display: flex; flex-direction: column; gap: 8px; }
.fn-msg-placeholder { color: var(--fnlm-gray, #6b7280); font-size: .9rem; margin: auto; }
.fn-msg-row .fn-msg-bubble { max-width: 100%; }
.fn-msg-bubble {
    max-width: 70%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: .9rem;
    line-height: 1.35;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.fn-msg-bubble .fn-msg-text { white-space: pre-wrap; word-break: break-word; }
.fn-msg-bubble .fn-msg-time { font-size: .68rem; opacity: .7; align-self: flex-end; }
.fn-msg-theirs { align-self: flex-start; background: var(--fnlm-light, #f4f6f9); color: var(--fnlm-text, #1a2235); }
.fn-msg-mine { align-self: flex-end; background: var(--fnlm-blue, #003580); color: #fff; }
.fn-msg-send-form { display: flex; gap: 10px; margin-top: 12px; }
.fn-msg-send-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--fnlm-border, #dde3ed);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: .9rem;
}
.fn-msg-send-form button { align-self: flex-end; }

@media (max-width: 700px) {
    .fn-messages-layout { flex-direction: column; }
    .fn-contacts-list { width: 100%; border-right: none; border-bottom: 1px solid var(--fnlm-border, #dde3ed); padding-right: 0; padding-bottom: 10px; max-height: 160px; }
}

@media (max-width: 560px) {
    .fn-auth-card, .fn-dashboard-shell { margin: 20px 12px; max-width: none; }
    .fn-invite-card { flex-direction: column; align-items: flex-start; }
}
