/* =========================================================
   NEETLY MESSAGES CENTER
   Tutte le classi sono modificabili senza forzature globali.
   Prefix: ntlmsg-
   ========================================================= */

:root {
    --ntlmsg-red: #c70000;
    --ntlmsg-ink: #202020;
    --ntlmsg-muted: #777777;
    --ntlmsg-bg: #ffffff;
    --ntlmsg-soft: #f5f5f5;
    --ntlmsg-line: #dedede;
    --ntlmsg-green: #00bd4e;
    --ntlmsg-shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
    --ntlmsg-radius-xl: 28px;
    --ntlmsg-radius-lg: 22px;
    --ntlmsg-radius-md: 16px;
    --ntlmsg-radius-sm: 12px;
}

.ntlmsg-menu-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ntlmsg-header-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    border-radius: 999px;
    color: var(--ntlmsg-ink);
    text-decoration: none;
    background: transparent;
    position: relative;
}

.ntlmsg-header-trigger:hover,
.ntlmsg-header-trigger:focus {
    color: var(--ntlmsg-red);
    background: rgba(199, 0, 0, 0.07);
    outline: none;
}

.ntlmsg-header-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.ntlmsg-header-icon {
    color: currentColor;
    font-size: 22px;
    line-height: 1;
}

.ntlmsg-header-badge {
    position: absolute;
    top: -9px;
    right: -9px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ntlmsg-red);
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 999px;
    font-family: Poppins, Arial, Helvetica, sans-serif;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(199, 0, 0, 0.25);
}

.ntlmsg-root {
    position: fixed;
    inset: auto 18px 0 auto;
    z-index: 2147482100;
    font-family: Poppins, Arial, Helvetica, sans-serif;
    color: var(--ntlmsg-ink);
}

.ntlmsg-app {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 12px;
}

.ntlmsg-dock {
    width: 360px;
    max-width: calc(100vw - 32px);
    background: var(--ntlmsg-bg);
    border: 1px solid var(--ntlmsg-line);
    border-radius: var(--ntlmsg-radius-xl) var(--ntlmsg-radius-xl) 0 0;
    box-shadow: var(--ntlmsg-shadow);
    overflow: hidden;
    transform: translateY(calc(100% - 54px));
    transition: transform 0.24s ease, box-shadow 0.24s ease;
}

.ntlmsg-app.is-open .ntlmsg-dock {
    transform: translateY(0);
}

.ntlmsg-dock-head {
    min-height: 54px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #ffffff;
    border-bottom: 1px solid var(--ntlmsg-line);
    cursor: pointer;
}

.ntlmsg-dock-title {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ntlmsg-ink);
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

.ntlmsg-dock-title-icon {
    color: var(--ntlmsg-red);
    font-size: 17px;
}

.ntlmsg-dock-counter {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ntlmsg-red);
    color: #ffffff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.ntlmsg-dock-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ntlmsg-head-button {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #f1f1f1;
    color: var(--ntlmsg-ink);
    cursor: pointer;
}

.ntlmsg-head-button:hover,
.ntlmsg-head-button:focus {
    background: rgba(199, 0, 0, 0.08);
    color: var(--ntlmsg-red);
    outline: none;
}

.ntlmsg-dock-body {
    height: 520px;
    max-height: min(70vh, 560px);
    display: grid;
    grid-template-rows: auto 1fr;
    background: #ffffff;
}

.ntlmsg-search-panel {
    padding: 12px;
    border-bottom: 1px solid var(--ntlmsg-line);
    background: #ffffff;
}

.ntlmsg-new-title {
    margin: 0 0 8px 0;
    color: var(--ntlmsg-ink);
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
}

.ntlmsg-search-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.ntlmsg-search-input,
.ntlmsg-compose-textarea {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--ntlmsg-line);
    border-radius: var(--ntlmsg-radius-sm);
    background: #ffffff;
    color: var(--ntlmsg-ink);
    font-family: Poppins, Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.35;
    box-sizing: border-box;
}

.ntlmsg-search-input {
    height: 42px;
    padding: 10px 12px;
}

.ntlmsg-search-input:focus,
.ntlmsg-compose-textarea:focus {
    border-color: var(--ntlmsg-red);
    outline: 3px solid rgba(199, 0, 0, 0.10);
}

.ntlmsg-user-results {
    display: grid;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.ntlmsg-user-result {
    width: 100%;
    display: grid;
    grid-template-columns: 38px 1fr;
    align-items: center;
    gap: 9px;
    padding: 7px;
    border: 1px solid #eeeeee;
    border-radius: var(--ntlmsg-radius-sm);
    background: #ffffff;
    color: var(--ntlmsg-ink);
    text-align: left;
    cursor: pointer;
}

.ntlmsg-user-result:hover,
.ntlmsg-user-result:focus {
    background: rgba(199, 0, 0, 0.06);
    border-color: rgba(199, 0, 0, 0.22);
    outline: none;
}

.ntlmsg-user-result-avatar,
.ntlmsg-thread-avatar,
.ntlmsg-message-avatar {
    display: block;
    border-radius: 999px;
    object-fit: cover;
    object-position: center center;
    background: #f1f1f1;
}

.ntlmsg-user-result-avatar {
    width: 38px;
    height: 38px;
}

.ntlmsg-user-result-name {
    display: block;
    color: var(--ntlmsg-ink);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.1;
}

.ntlmsg-user-result-role {
    display: block;
    margin-top: 3px;
    color: var(--ntlmsg-muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
}

.ntlmsg-main-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
}

.ntlmsg-thread-list {
    min-height: 0;
    overflow-y: auto;
    background: #ffffff;
}

.ntlmsg-thread-item {
    width: 100%;
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #f0f0f0;
    background: #ffffff;
    color: var(--ntlmsg-ink);
    text-align: left;
    cursor: pointer;
}

.ntlmsg-thread-item:hover,
.ntlmsg-thread-item:focus,
.ntlmsg-thread-item.is-active {
    background: #f7f7f7;
    outline: none;
}

.ntlmsg-thread-avatar {
    width: 46px;
    height: 46px;
}

.ntlmsg-thread-title {
    display: block;
    max-width: 220px;
    color: var(--ntlmsg-ink);
    font-size: 14px;
    font-weight: 900;
    line-height: 1.12;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ntlmsg-thread-preview {
    display: block;
    max-width: 220px;
    margin-top: 4px;
    color: var(--ntlmsg-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ntlmsg-thread-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.ntlmsg-thread-dot {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--ntlmsg-red);
    color: #ffffff;
    font-size: 10px;
    font-weight: 900;
}

.ntlmsg-thread-time {
    color: #9a9a9a;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.ntlmsg-empty-state {
    padding: 28px 18px;
    color: var(--ntlmsg-muted);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.ntlmsg-chat-window {
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: min(70vh, 560px);
    display: grid;
    grid-template-rows: auto 1fr auto;
    background: #ffffff;
    border: 1px solid var(--ntlmsg-line);
    border-radius: var(--ntlmsg-radius-xl) var(--ntlmsg-radius-xl) 0 0;
    box-shadow: var(--ntlmsg-shadow);
    overflow: hidden;
}

.ntlmsg-chat-head {
    min-height: 58px;
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--ntlmsg-line);
    background: #ffffff;
}

.ntlmsg-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    object-fit: cover;
    background: #f1f1f1;
}

.ntlmsg-chat-title {
    margin: 0;
    color: var(--ntlmsg-ink);
    font-size: 14px;
    font-weight: 900;
    line-height: 1.12;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ntlmsg-chat-subtitle {
    display: block;
    margin-top: 4px;
    color: var(--ntlmsg-muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.ntlmsg-chat-close {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: #f1f1f1;
    color: var(--ntlmsg-ink);
    cursor: pointer;
}

.ntlmsg-chat-close:hover,
.ntlmsg-chat-close:focus {
    background: rgba(199, 0, 0, 0.08);
    color: var(--ntlmsg-red);
    outline: none;
}

.ntlmsg-message-list {
    min-height: 0;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    background: #f7f7f7;
}

.ntlmsg-message-row {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 8px;
    align-items: end;
}

.ntlmsg-message-row.is-mine {
    grid-template-columns: minmax(0, 1fr) 30px;
}

.ntlmsg-message-avatar {
    width: 30px;
    height: 30px;
}

.ntlmsg-message-row.is-mine .ntlmsg-message-avatar {
    grid-column: 2;
}

.ntlmsg-message-bubble {
    width: fit-content;
    max-width: min(78%, 260px);
    padding: 9px 11px;
    border-radius: 18px;
    background: #ffffff;
    color: var(--ntlmsg-ink);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ntlmsg-message-row.is-mine .ntlmsg-message-bubble {
    justify-self: end;
    background: var(--ntlmsg-red);
    color: #ffffff;
    border-bottom-right-radius: 6px;
}

.ntlmsg-message-row:not(.is-mine) .ntlmsg-message-bubble {
    border-bottom-left-radius: 6px;
}

.ntlmsg-message-time {
    display: block;
    margin-top: 5px;
    opacity: 0.75;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.ntlmsg-compose {
    padding: 10px;
    border-top: 1px solid var(--ntlmsg-line);
    background: #ffffff;
}

.ntlmsg-compose-form {
    display: grid;
    grid-template-columns: 1fr 42px;
    align-items: end;
    gap: 8px;
}

.ntlmsg-compose-textarea {
    min-height: 42px;
    max-height: 120px;
    padding: 10px 12px;
    resize: none;
    border-radius: 18px;
}

.ntlmsg-send-button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--ntlmsg-red);
    color: #ffffff;
    cursor: pointer;
}

.ntlmsg-send-button:hover,
.ntlmsg-send-button:focus {
    background: #202020;
    outline: none;
}

.ntlmsg-open-button,
.ntlmsg-login-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--ntlmsg-red);
    color: #ffffff;
    font-family: Poppins, Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.ntlmsg-open-button:hover,
.ntlmsg-open-button:focus,
.ntlmsg-login-link:hover,
.ntlmsg-login-link:focus {
    background: #202020;
    color: #ffffff;
    outline: none;
}

.ntlmsg-page {
    width: 100%;
    padding: clamp(14px, 3vw, 28px);
    box-sizing: border-box;
    font-family: Poppins, Arial, Helvetica, sans-serif;
}

.ntlmsg-page-shell,
.ntlmsg-page-card {
    width: min(100%, 1180px);
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid var(--ntlmsg-line);
    border-radius: var(--ntlmsg-radius-xl);
    overflow: hidden;
}

.ntlmsg-page-card {
    padding: clamp(20px, 4vw, 44px);
    text-align: center;
}

.ntlmsg-page-card h1 {
    margin: 0 0 8px 0;
    color: var(--ntlmsg-ink);
    font-size: clamp(28px, 5vw, 44px);
    font-weight: 900;
    letter-spacing: -0.06em;
}

.ntlmsg-page-card p {
    margin: 0 0 18px 0;
    color: var(--ntlmsg-muted);
    font-size: 15px;
    font-weight: 600;
}

.ntlmsg-page-mount .ntlmsg-app {
    justify-content: stretch;
    align-items: stretch;
}

.ntlmsg-page-mount .ntlmsg-dock {
    width: 360px;
    max-width: 360px;
    height: min(76vh, 720px);
    transform: none;
    border-radius: 0;
    box-shadow: none;
    border: 0;
    border-right: 1px solid var(--ntlmsg-line);
}

.ntlmsg-page-mount .ntlmsg-chat-window {
    width: 100%;
    max-width: none;
    height: min(76vh, 720px);
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.ntlmsg-page-mount .ntlmsg-dock-body,
.ntlmsg-page-mount .ntlmsg-chat-window {
    max-height: none;
}

.ntlmsg-page-mount .ntlmsg-dock-head {
    cursor: default;
}

.ntlmsg-status-line {
    padding: 8px 12px;
    color: var(--ntlmsg-muted);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

@media (max-width: 760px) {
    .ntlmsg-root {
        inset: 0;
        pointer-events: none;
    }

    .ntlmsg-app {
        width: 100%;
        height: 100%;
        align-items: stretch;
        justify-content: stretch;
        pointer-events: none;
    }

    .ntlmsg-app.is-open {
        pointer-events: auto;
    }

    .ntlmsg-dock {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        transform: translateY(100%);
        display: grid;
        grid-template-rows: auto 1fr;
    }

    .ntlmsg-app.is-open .ntlmsg-dock {
        transform: translateY(0);
    }

    .ntlmsg-dock-head {
        min-height: 62px;
        padding: max(10px, env(safe-area-inset-top)) 14px 10px 14px;
        cursor: default;
    }

    .ntlmsg-dock-title {
        font-size: 17px;
    }

    .ntlmsg-dock-body {
        height: auto;
        max-height: none;
        min-height: 0;
    }

    .ntlmsg-search-panel {
        padding: 12px 14px;
    }

    .ntlmsg-search-input {
        height: 46px;
        border-radius: 16px;
        font-size: 16px;
    }

    .ntlmsg-main-grid {
        min-height: 0;
    }

    .ntlmsg-thread-list {
        min-height: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .ntlmsg-thread-item {
        grid-template-columns: 50px 1fr auto;
        padding: 12px 14px;
    }

    .ntlmsg-thread-avatar {
        width: 50px;
        height: 50px;
    }

    .ntlmsg-thread-title,
    .ntlmsg-thread-preview {
        max-width: calc(100vw - 140px);
    }

    .ntlmsg-chat-window {
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        z-index: 2;
    }

    .ntlmsg-chat-head {
        min-height: 64px;
        padding: max(10px, env(safe-area-inset-top)) 14px 10px 14px;
    }

    .ntlmsg-message-list {
        padding: 12px 12px 8px 12px;
        gap: 9px;
    }

    .ntlmsg-message-bubble {
        max-width: 82vw;
        padding: 10px 12px;
        font-size: 15px;
        line-height: 1.35;
    }

    .ntlmsg-compose {
        padding: 10px 10px max(10px, env(safe-area-inset-bottom)) 10px;
        background: #ffffff;
    }

    .ntlmsg-compose-form {
        grid-template-columns: 1fr 48px;
        gap: 8px;
        align-items: end;
    }

    .ntlmsg-compose-textarea {
        min-height: 48px;
        max-height: 150px;
        padding: 12px 14px;
        border-radius: 20px;
        font-size: 16px;
        line-height: 1.35;
    }

    .ntlmsg-send-button {
        width: 48px;
        height: 48px;
    }

    .ntlmsg-page {
        padding: 0;
    }

    .ntlmsg-page-shell {
        width: 100%;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .ntlmsg-page-mount .ntlmsg-app {
        height: 100dvh;
        pointer-events: auto;
    }

    .ntlmsg-page-mount .ntlmsg-dock {
        position: relative;
        transform: none;
        height: 100dvh;
    }
}

@media (max-width: 380px) {
    .ntlmsg-thread-item {
        grid-template-columns: 44px 1fr auto;
        gap: 8px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .ntlmsg-thread-avatar {
        width: 44px;
        height: 44px;
    }

    .ntlmsg-thread-title,
    .ntlmsg-thread-preview {
        max-width: calc(100vw - 122px);
    }
}

/* =========================================================
   NEETLY MESSAGES CENTER 0.1.12
   Test anti-conflitto: dock e finestre a sinistra.
   Non tocca barra Neetly, punteggi o accordion.
   ========================================================= */

.ntlmsg-root {
    inset: auto auto 0 18px;
    pointer-events: none;
}

.ntlmsg-app,
.ntlmsg-app.is-open {
    justify-content: flex-start;
    pointer-events: none;
}

.ntlmsg-dock,
.ntlmsg-chat-window {
    pointer-events: auto;
}

.ntlmsg-dock {
    transform-origin: left bottom;
}

/* Icona messaggi nell'header mobile tra 321px e 720px. */
.ntlmsg-mobile-header-slot {
    display: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 42px;
    margin: 0;
    padding: 0;
}

.ntlmsg-mobile-header-trigger {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 42px;
    color: #202020;
    text-decoration: none;
    border: 0;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
}

.ntlmsg-mobile-header-trigger:hover,
.ntlmsg-mobile-header-trigger:focus {
    color: #c70000;
    background: rgba(199, 0, 0, 0.07);
    outline: none;
}

.ntlmsg-mobile-header-icon-wrap {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
}

.ntlmsg-mobile-header-icon {
    color: currentColor;
    font-size: 22px;
    line-height: 1;
}

.ntlmsg-mobile-header-badge {
    position: absolute;
    right: -4px;
    top: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    background: #c70000;
    color: #ffffff;
    font-family: Poppins, Arial, Helvetica, sans-serif;
    font-size: 10px;
    font-weight: 900;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(199, 0, 0, 0.28);
}

@media (max-width: 720px) and (min-width: 321px) {
    .site-header .ntlmsg-mobile-header-slot,
    .neetly-main-header .ntlmsg-mobile-header-slot {
        display: inline-flex;
    }

    .site-header .ntlmsg-menu-item,
    .neetly-main-header .ntlmsg-menu-item {
        display: none;
    }
}

@media (max-width: 320px) {
    .ntlmsg-mobile-header-slot {
        display: none;
    }
}

@media (max-width: 760px) {
    .ntlmsg-root {
        inset: 0;
        pointer-events: none;
    }

    .ntlmsg-dock,
    .ntlmsg-chat-window {
        pointer-events: auto;
    }
}


/* =========================================================
   NEETLY MESSAGES CENTER 0.1.12
   Badge coerente: nessuna modifica alla barra Neetly.
   ========================================================= */
