/* ===========================================================================
   Мессенджер: личные сообщения.
   Оформление — по мотивам Telegram, но в цветах сайта: все цвета берём из
   переменных темы Bootstrap, поэтому светлая и тёмная темы работают сразу.
   =========================================================================== */

.np-msng {
    display: flex;
    height: calc(100vh - 210px);
    min-height: 460px;
    border: 1px solid var(--bs-border-color);
    border-radius: 14px;
    overflow: hidden;
    background: var(--bs-body-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

/* ------------------------------------------------------- список переписок -- */
.np-msng-side {
    flex: 0 0 330px;
    width: 330px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

.np-msng-side-head {
    padding: 12px 12px 10px;
    border-bottom: 1px solid var(--bs-border-color);
}

.np-msng-side-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
}

.np-msng-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    background: var(--bs-body-bg);
    color: var(--bs-secondary-color);
}

.np-msng-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 14px;
}

.np-dialog-list {
    flex: 1;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
}

.np-dialog {
    margin-bottom: 2px;
}

.np-dialog-link {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
}

.np-dialog-link:hover {
    background: var(--bs-tertiary-bg);
}

.np-dialog--active .np-dialog-link,
.np-dialog--active .np-dialog-link:hover {
    background: var(--bs-primary);
    color: #fff;
}

.np-dialog-avatar {
    position: relative;
    flex: 0 0 48px;
}

.np-dialog-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bs-tertiary-bg);
}

.np-dialog-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.np-dialog-top,
.np-dialog-bottom {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.np-dialog-nick {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-dialog-time {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--bs-secondary-color);
}

.np-dialog--active .np-dialog-time,
.np-dialog--active .np-dialog-preview {
    color: rgba(255, 255, 255, .8);
}

.np-dialog-preview {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-dialog-you {
    color: var(--bs-secondary-color);
    opacity: .8;
}

.np-dialog--active .np-dialog-you {
    color: rgba(255, 255, 255, .8);
    opacity: 1;
}

.np-dialog-badge {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bs-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.np-dialog--active .np-dialog-badge {
    background: #fff;
    color: var(--bs-primary);
}

.np-online-dot {
    position: absolute;
    right: 0;
    bottom: 2px;
    width: 12px;
    height: 12px;
    border: 2px solid var(--bs-body-bg);
    border-radius: 50%;
    background: var(--bs-success);
}

.np-dialog--active .np-online-dot {
    border-color: var(--bs-primary);
}

.np-dialog-empty,
.np-dialog-none {
    padding: 18px 16px;
    color: var(--bs-secondary-color);
    font-size: 13px;
    text-align: center;
}

.np-dialog-empty-title {
    font-weight: 700;
    color: var(--bs-body-color);
    margin-bottom: 6px;
}

.np-dialog-empty-text {
    margin: 0;
    line-height: 1.4;
}

.np-dialog-hidden {
    display: none;
}

/* ---------------------------------------------------------- переписка ------ */
.np-msng-chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg);
}

.np-msng-chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

.np-msng-back {
    display: none;
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    font-size: 20px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 8px;
}

.np-msng-back:hover {
    background: var(--bs-tertiary-bg);
}

.np-msng-partner {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.np-msng-partner-avatar {
    position: relative;
}

.np-msng-partner-avatar img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bs-tertiary-bg);
}

.np-msng-partner-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.np-msng-nick {
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-msng-status {
    font-size: 12px;
    color: var(--bs-secondary-color);
}

.np-msng-history {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px 16px 4px;
    /* полоски, как в мессенджерах, но из темы сайта */
    background-image: linear-gradient(var(--bs-tertiary-bg) 1px, transparent 1px);
    background-size: 100% 44px;
    background-color: var(--bs-body-bg);
}

#np-history-list {
    margin-top: auto;
}

.np-history-loader {
    display: none;
    padding: 6px 0;
    text-align: center;
    color: var(--bs-secondary-color);
}

.np-history-loader--visible {
    display: block;
}

/* Пока переписка грузится, в окне виден только спиннер: письма прошлого
   собеседника не должны «висеть» под новым заголовком. */
#np-history.np-history--loading {
    justify-content: center;
}

.np-history--loading #np-history-list {
    margin-top: 0;
}

.np-history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 0;
    color: var(--bs-secondary-color);
    font-size: 13px;
    text-align: center;
}

/* Спиннер на строке списка, по которой кликнули (вместо времени письма). */
.np-dialog--loading .np-dialog-time {
    display: none;
}

.np-dialog-spinner {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.np-history-start,
.np-date-sep,
.np-unread-sep {
    margin: 10px 0;
    text-align: center;
}

.np-history-start,
.np-date-sep span,
.np-unread-sep span {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 12px;
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    font-size: 12px;
}

.np-unread-sep {
    position: relative;
}

.np-unread-sep span {
    background: var(--bs-success-bg-subtle);
    color: var(--bs-body-color);
}

.np-message {
    display: flex;
    margin-bottom: 6px;
}

.np-message--mine {
    justify-content: flex-end;
}

.np-bubble {
    max-width: 72%;
    padding: 8px 12px 6px;
    border-radius: 16px 16px 16px 4px;
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    overflow-wrap: break-word;
}

.np-message--mine .np-bubble {
    border-radius: 16px 16px 4px 16px;
    background: var(--bs-primary);
    color: #fff;
}

.np-bubble-subject {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    opacity: .85;
}

.np-bubble-text {
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.np-bubble-text a {
    color: inherit;
    text-decoration: underline;
}

.np-bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1;
    color: var(--bs-secondary-color);
}

.np-message--mine .np-bubble-meta {
    color: rgba(255, 255, 255, .85);
}

.np-bubble-ticks {
    letter-spacing: -2px;
}

.np-bubble-ticks--read {
    color: var(--bs-success);
}

.np-message--mine .np-bubble-ticks--read {
    color: #fff;
    font-weight: 700;
}

/* --------------------------------------------------------- вложения ------- */
.np-attachments {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
}

.np-attachments--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.np-attachment-image {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
}

.np-attachment-image img {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    cursor: zoom-in;
}

.np-attachments:not(.np-attachments--grid) .np-attachment-image img {
    max-height: 420px;
    object-fit: contain;
}

.np-attachment-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, .06);
    color: inherit;
    text-decoration: none;
}

.np-message--mine .np-attachment-file {
    background: rgba(255, 255, 255, .18);
    color: #fff;
}

.np-attachment-icon {
    font-size: 22px;
    line-height: 1;
}

.np-attachment-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.np-attachment-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-attachment-size {
    font-size: 11px;
    color: var(--bs-secondary-color);
}

.np-message--mine .np-attachment-size {
    color: rgba(255, 255, 255, .8);
}

/* ------------------------------------------------- кнопка «вниз» ---------- */
.np-scroll-down {
    position: sticky;
    bottom: 8px;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    cursor: pointer;
}

.np-scroll-down-count:empty {
    display: none;
}

.np-scroll-down-count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bs-primary);
    color: #fff;
    font-weight: 700;
    text-align: center;
}

/* ------------------------------------------------------- поле ввода ------- */
.np-composer {
    position: relative;
    padding: 10px 12px 8px;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

.np-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.np-composer-attach,
.np-composer-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--bs-body-bg);
    color: var(--bs-secondary-color);
    font-size: 19px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.np-composer-attach:hover {
    color: var(--bs-primary);
}

.np-composer-send {
    background: var(--bs-primary);
    color: #fff;
}

.np-composer-send:disabled {
    opacity: .5;
}

.np-composer-text {
    flex: 1;
    min-width: 0;
    max-height: 160px;
    padding: 9px 14px;
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    overflow-y: auto;
}

.np-composer-text:focus {
    outline: none;
    border-color: var(--bs-primary);
}

.np-composer-hint {
    margin-top: 6px;
    font-size: 11px;
    color: var(--bs-secondary-color);
}

.np-composer-hint--error {
    color: var(--bs-danger);
    font-weight: 600;
}

.np-composer-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.np-composer-file {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 220px;
    padding: 6px 26px 6px 8px;
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    background: var(--bs-body-bg);
    font-size: 12px;
}

.np-composer-file-thumb {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bs-tertiary-bg);
}

.np-composer-file-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bs-tertiary-bg);
    font-size: 16px;
}

.np-composer-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-composer-file-remove {
    position: absolute;
    top: 2px;
    right: 4px;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.np-composer-file-remove:hover {
    color: var(--bs-danger);
}

.np-composer-progress {
    position: absolute;
    left: 0;
    right: 0;
    top: -4px;
    height: 4px;
    background: var(--bs-tertiary-bg);
}

.np-composer-progress-bar {
    width: 0;
    height: 100%;
    background: var(--bs-primary);
    transition: width .2s ease;
}

/* ----------------------------------------------- состояния страницы ------- */
.np-msng-chat-empty,
.np-msng-no-reply {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px;
    color: var(--bs-secondary-color);
    text-align: center;
}

.np-msng-chat-empty .bi {
    font-size: 42px;
    opacity: .5;
}

.np-msng-no-reply {
    flex: 0 0 auto;
    padding: 14px;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
    font-size: 13px;
}

.np-msng-dragover .np-msng-history {
    outline: 2px dashed var(--bs-primary);
    outline-offset: -8px;
}

/* ------------------------------------------------------- лайтбокс --------- */
/* Просмотр изображений: листалка стрелками, счётчик кадров, закрытие по
   клику по фону, кнопке или клавише Escape. */
.np-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 72px;
    background: rgba(0, 0, 0, .86);
}

.np-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
    cursor: zoom-out;
}

.np-lightbox-close,
.np-lightbox-nav {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease, opacity .15s ease;
}

.np-lightbox-close:hover,
.np-lightbox-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, .3);
}

.np-lightbox-close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
}

.np-lightbox-nav {
    top: 50%;
    width: 52px;
    height: 52px;
    margin-top: -26px;
    font-size: 22px;
}

.np-lightbox-prev {
    left: 16px;
}

.np-lightbox-next {
    right: 16px;
}

.np-lightbox-nav:disabled {
    opacity: .3;
    cursor: default;
}

.np-lightbox-counter {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 13px;
}

/* Пока просмотрщик открыт, страница под ним не прокручивается. */
body.np-lightbox-open {
    overflow: hidden;
}

@media (max-width: 576px) {
    .np-lightbox {
        padding: 52px 8px 44px;
    }

    .np-lightbox-nav {
        width: 42px;
        height: 42px;
        margin-top: -21px;
    }

    .np-lightbox-prev {
        left: 6px;
    }

    .np-lightbox-next {
        right: 6px;
    }

    .np-lightbox-close {
        top: 8px;
        right: 8px;
        width: 34px;
        height: 34px;
        font-size: 20px;
    }
}

/* ------------------------------------------------ тосты на всех страницах -- */
.np-toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1080;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    width: 320px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

.np-toast {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 10px 34px 12px 10px;
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid var(--bs-primary);
    border-radius: 12px;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
    text-decoration: none;
    pointer-events: auto;
    animation: np-toast-in .18s ease-out;
    overflow: hidden;
}

.np-toast:hover {
    background: var(--bs-tertiary-bg);
}

.np-toast-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bs-tertiary-bg);
}

.np-toast-body {
    min-width: 0;
}

.np-toast-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.np-toast-nick {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.np-toast-time {
    font-size: 11px;
    color: var(--bs-secondary-color);
}

.np-toast-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    color: var(--bs-secondary-color);
    line-height: 1.35;
}

.np-toast-close {
    position: absolute;
    top: 6px;
    right: 6px;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.np-toast-close:hover {
    color: var(--bs-danger);
}

@keyframes np-toast-in {
    from {
        transform: translateY(12px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --------------------------------------------------- мобильный вид -------- */
@media (max-width: 991.98px) {
    .np-msng {
        height: calc(100vh - 190px);
    }

    .np-msng-side {
        flex: 1 1 auto;
        width: auto;
        border-right: 0;
    }

    .np-msng-chat {
        display: none;
        flex: 1 1 auto;
    }

    .np-msng--open .np-msng-side {
        display: none;
    }

    .np-msng--open .np-msng-chat {
        display: flex;
    }

    .np-msng-back {
        display: block;
    }

    .np-msng-history {
        padding: 12px 10px 4px;
    }

    .np-bubble {
        max-width: 86%;
    }

    .np-toasts {
        right: 10px;
        bottom: 10px;
    }
}



