/* Сообщения (messages.html) */

.messages-page {
    padding-top: 28px;
}

.ms {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 240px;
    height: calc(100vh - 250px);
    min-height: 520px;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
}

/* Левая колонка */
.ms-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border-main);
}

.ms-side__top {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid var(--border-main);
}

.ms-folders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--border-main);
}

.ms-folder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: var(--bg-input);
    border: none;
}

.ms-folder + .ms-folder {
    border-left: 1px solid var(--border-main);
}

.ms-folder.is-active {
    color: var(--text-main);
    background: rgba(204, 36, 29, 0.12);
    box-shadow: inset 0 -2px 0 var(--text-red);
}

.ms-folder__n {
    min-width: 18px;
    padding: 1px 5px;
    color: #fff;
    font-size: 10px;
    background: var(--text-red);
    border-radius: 9px;
}

.ms-online-only {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ms-online-only.is-active {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.08);
    border-color: rgba(46, 204, 113, 0.5);
}

.ms-list {
    flex: 1;
    overflow-y: auto;
}

.ms-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-main);
}

.ms-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.ms-item.is-active {
    background: rgba(204, 36, 29, 0.06);
    box-shadow: inset 3px 0 0 var(--text-red);
}

.ms-item.is-blocked {
    opacity: 0.45;
}

.ms-item__avatar {
    position: relative;
}

.ms-item__avatar .ms-dot {
    position: absolute;
    right: -2px;
    bottom: -2px;
}

.ms-item__body {
    flex: 1;
    min-width: 0;
}

.ms-item__top {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ms-item__time {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 10px;
    white-space: nowrap;
}

.ms-item__flag {
    font-size: 10px;
}

.ms-item .unread-badge.is-muted {
    color: var(--text-main);
    background: var(--border-accent);
}

.ms-item__name {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
}

.ms-item__last {
    display: block;
    overflow: hidden;
    color: var(--text-dim);
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ms-item .unread-badge {
    margin: 0;
}

.ms-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--text-dim);
    border: 1px solid var(--bg-card);
}

.ms-dot--online {
    background: #2ecc71;
}

.ms-dot--ingame {
    background: #9b59b6;
}

.ms-side__foot {
    padding: 12px 14px;
    color: var(--text-green);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-top: 1px solid var(--border-main);
}

/* Центральная колонка */
.ms-chat {
    display: flex;
    min-width: 0;
    min-height: 0;
}

.ms-empty {
    margin: auto;
    padding: 20px;
    color: var(--text-dim);
    font-size: 13px;
    text-align: center;
}

.ms-chat__inner {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.ms-chat__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-main);
}

.ms-back {
    display: none;
    padding: 4px 10px;
    color: var(--text-main);
    font-size: 18px;
    background: none;
    border: 1px solid var(--border-accent);
}

.ms-chat__who {
    flex: 1;
    min-width: 0;
}

.ms-chat__name {
    color: var(--text-main);
    font-size: 15px;
    font-weight: 700;
}

.ms-chat__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ms-status {
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid currentColor;
}

.ms-status--ingame {
    color: #9b59b6;
}

.ms-status--online {
    color: #2ecc71;
}

.ms-status--offline {
    color: var(--text-dim);
}

.ms-blocked {
    padding: 12px 20px;
    color: var(--text-muted);
    font-size: 12px;
    background: rgba(153, 0, 0, 0.08);
    border-bottom: 1px solid rgba(153, 0, 0, 0.4);
}

.ms-feed {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.12);
}

.ms-msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ms-msg--mine .avatar {
    border-color: var(--text-red);
}

.ms-msg__meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.ms-msg__from {
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
}

.ms-msg--mine .ms-msg__from {
    color: var(--text-red);
}

.ms-msg__time {
    color: var(--text-muted);
    font-size: 10px;
}

.ms-msg__text {
    margin-top: 4px;
    color: var(--text-gold);
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.ms-msg--mine .ms-msg__text {
    color: var(--text-main);
}

.ms-form {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-main);
}

.ms-form .input {
    flex: 1;
}

/* Правая колонка */
.ms-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 22px 16px;
    border-left: 1px solid var(--border-main);
}

.ms-profile__avatar {
    margin-bottom: 14px;
    border-width: 2px;
}

.ms-profile__name {
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
}

.ms-profile__status {
    margin: 4px 0 18px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.ms-profile__stats {
    width: 100%;
    font-size: 12px;
}

.ms-profile__stats div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-main);
}

.ms-profile__stats dt {
    color: var(--text-muted);
}

.ms-profile__stats dd {
    color: var(--text-main);
    font-weight: 700;
}

.ms-profile__open {
    width: 100%;
    margin-top: auto;
}

@media (max-width: 1000px) {
    .ms {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .ms-profile {
        display: none;
    }
}

.ms-skeleton {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-main);
}

/* ---------- Меню ⋯ ---------- */
.ms-menu {
    position: relative;
}

.ms-menu__btn {
    min-width: 34px;
    font-size: 16px;
    line-height: 1;
}

.ms-menu__list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    padding: 6px 0;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow);
}

.ms-menu__list[hidden] {
    display: none;
}

.ms-menu__list .ms-menu__mobile {
    display: none;
}

.ms-menu__list a {
    padding: 9px 14px;
    color: var(--text-main);
    font-size: 13px;
    text-decoration: none;
}

.ms-menu__list a:hover {
    background: rgba(255, 255, 255, 0.04);
}

.ms-menu__list button {
    padding: 9px 14px;
    color: var(--text-main);
    font-size: 13px;
    text-align: left;
    background: none;
    border: none;
}

.ms-menu__list button:hover {
    background: rgba(255, 255, 255, 0.04);
}

.ms-menu__list button.is-danger {
    color: #e5534b;
    border-top: 1px solid var(--border-main);
}

/* ---------- Запрос ---------- */
.ms-request {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(209, 184, 148, 0.06);
    border-bottom: 1px solid var(--border-gold);
}

.ms-request__text {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
}

.ms-request__text b {
    display: block;
    color: var(--text-gold);
    font-size: 13px;
}

.ms-request__text span {
    color: var(--text-muted);
}

.ms-request__actions {
    display: flex;
    gap: 8px;
}

.ms-blocked {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ---------- Разделители и отметки ---------- */
.ms-day,
.ms-new {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ms-day::before,
.ms-day::after,
.ms-new::before,
.ms-new::after {
    flex: 1;
    height: 1px;
    background: var(--border-main);
    content: "";
}

.ms-new {
    color: var(--text-red);
}

.ms-new::before,
.ms-new::after {
    background: rgba(204, 36, 29, 0.5);
}

.ms-msg__body {
    min-width: 0;
}

.ms-tick {
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: -2px;
}

.ms-tick.is-seen {
    color: #5aa9e6;
}

.ms-link {
    color: #5aa9e6;
    text-decoration: underline;
    overflow-wrap: anywhere;
}

.ms-link.is-external {
    color: #e0a35a;
}

.ms-link.is-external::after {
    content: " ↗";
}

/* ---------- Карточки в чате ---------- */
.ms-card {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 360px;
    margin-top: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    text-decoration: none;
    background: var(--bg-input);
    border: 1px solid var(--border-accent);
    border-left: 3px solid var(--text-gold);
}

.ms-card:hover {
    border-color: var(--text-gold);
}

.ms-card__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ms-card__kicker {
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ms-card__name {
    font-weight: 700;
}

.ms-card__stats {
    color: var(--text-muted);
    font-size: 12px;
}

.ms-invite-card {
    max-width: 380px;
    margin-top: 6px;
    padding: 14px;
    background: linear-gradient(135deg, rgba(204, 36, 29, 0.1), transparent 60%), var(--bg-input);
    border: 1px solid rgba(204, 36, 29, 0.45);
}

.ms-invite-card__title {
    margin-bottom: 10px;
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ms-invite-card__grid {
    display: grid;
    gap: 6px;
    margin: 0 0 12px;
    font-size: 13px;
}

.ms-invite-card__grid div {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 10px;
}

.ms-invite-card__grid dt {
    color: var(--text-dim);
}

.ms-invite-card__grid dd {
    margin: 0;
    color: var(--text-main);
    font-weight: 700;
}

.ms-invite-card__none {
    color: var(--text-muted);
    font-weight: 400;
}

.ms-invite-card__btns {
    display: flex;
    gap: 8px;
}

.ms-invite-card__answer {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.ms-invite-card__answer.is-yes {
    color: #2ecc71;
}

.ms-invite-card__answer.is-no {
    color: #e5534b;
}

/* ---------- Поле ввода, быстрые ответы, приглашение ---------- */
.ms-compose {
    border-top: 1px solid var(--border-main);
}

.ms-compose[hidden] {
    display: none;
}

.ms-quick {
    display: flex;
    gap: 6px;
    padding: 10px 20px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.ms-chip {
    flex-shrink: 0;
    padding: 5px 10px;
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    background: var(--bg-input);
    border: 1px solid var(--border-main);
    border-radius: 14px;
    transition:
        color var(--transition),
        border-color var(--transition);
}

.ms-chip:hover {
    color: var(--text-main);
    border-color: var(--text-gold);
}

.ms-form {
    border-top: none;
}

.ms-form__invite {
    flex-shrink: 0;
    padding: 0 12px;
    font-size: 16px;
}

.ms-invite {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 20px 0;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-accent);
    border-top: 3px solid var(--text-red);
}

.ms-invite[hidden] {
    display: none;
}

.ms-invite__title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.ms-invite__row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ms-inv-when {
    flex: 1;
    min-width: 150px;
}

.ms-inv-time {
    width: 110px;
}

.ms-invite__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ---------- Предупреждение о стороннем сайте ---------- */
.ms-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 5, 5, 0.85);
}

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

.ms-modal__box {
    width: 460px;
    max-width: 100%;
    padding: 26px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-top: 4px solid #e0a35a;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.ms-modal__icon {
    font-size: 30px;
}

.ms-modal__title {
    margin: 8px 0 10px;
    font-family: var(--font-heading);
    font-size: 20px;
    text-transform: uppercase;
}

.ms-modal__url {
    margin: 0 0 12px;
    padding: 8px 10px;
    color: #e0a35a;
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-input);
    overflow-wrap: anywhere;
}

.ms-modal__text {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.ms-modal__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* ---------- Телефон: список и чат как в мессенджерах ---------- */
@media (max-width: 700px) {
    .ms {
        grid-template-columns: minmax(0, 1fr);
        height: calc(100vh - 210px);
        min-height: 480px;
    }

    .ms-side {
        border-right: none;
    }

    .ms-chat {
        display: none;
    }

    .ms.is-chat-open .ms-side {
        display: none;
    }

    .ms.is-chat-open .ms-chat {
        display: flex;
    }

    .ms-back {
        display: block;
    }

    .ms-menu__list .ms-menu__mobile {
        display: block;
    }

    .ms-chat__head {
        padding: 10px 12px;
    }

    .ms-chat__actions .btn--sm:not(.ms-menu__btn) {
        display: none;
    }

    .ms-feed,
    .ms-request {
        padding: 14px 12px;
    }

    .ms-quick {
        padding: 10px 12px 0;
    }

    .ms-form {
        padding: 10px 12px;
    }

    .ms-invite {
        margin: 10px 12px 0;
    }
}
