/**
 * com_chat — site styles (portal light theme).
 */

.chat-hub {
    --chat-accent: var(--cassiopeia-color-primary, #1a56db);
    --chat-accent-soft: rgba(26, 86, 219, .08);
    --chat-line: #e6e8ec;
    --chat-muted: #64748b;
    --chat-ink: #1f2937;

    max-width: 100%;
}

.chat-hub .btn {
    border-radius: 8px;
}

.chat-hub__title {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 1rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--chat-ink);
}

.chat-hub__guest,
.chat-hub__empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: #fff;
    border: 1px solid var(--chat-line);
    border-radius: 14px;
    color: var(--chat-muted);
}

.chat-hub__guest .fa-comments {
    font-size: 2.2rem;
    color: var(--chat-accent);
    margin-bottom: .75rem;
}

.chat-hub__guest h2 {
    font-size: 1.25rem;
    color: var(--chat-ink);
}

.chat-cards {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.chat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--chat-line);
    border-radius: 14px;
    padding: .8rem .9rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.chat-card:hover {
    border-color: rgba(26, 86, 219, .35);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}

.chat-card__main {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    flex: 1 1 auto;
    color: inherit;
    text-decoration: none;
}

.chat-card__icon {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--chat-accent-soft);
    color: var(--chat-accent);
    font-size: .9rem;
    line-height: 1;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-card__icon > i {
    line-height: 1;
    font-size: inherit;
}

.chat-card__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-card__title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--chat-ink);
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-card__meta {
    display: flex;
    align-items: center;
    gap: .2rem;
    font-size: .8rem;
    color: var(--chat-muted);
}

.chat-card__last {
    font-size: .82rem;
    color: var(--chat-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-card__leave {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.chat-card__leave .btn {
    white-space: nowrap;
    font-size: .8rem;
    padding: .2rem .55rem;
    line-height: 1.4;
}

/* ---------------------------------------------------------------- chat page */
.chat-page {
    --chat-accent: var(--cassiopeia-color-primary, #1a56db);
    --chat-accent-soft: rgba(26, 86, 219, .08);
    --chat-line: #e6e8ec;
    --chat-muted: #64748b;
    --chat-ink: #1f2937;

    display: flex;
    flex-direction: column;
    height: min(72vh, 780px);
    min-height: 26rem;
    background: #fff;
    border: 1px solid var(--chat-line);
    border-radius: 14px;
    overflow: hidden;
}

.chat-page__head {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--chat-line);
    background: #fafbfe;
}

.chat-page__back {
    color: var(--chat-muted);
    text-decoration: none;
    font-size: 1rem;
}

.chat-page__back:hover {
    color: var(--chat-accent);
}

.chat-page__icon > i {
    line-height: 1;
    font-size: inherit;
}

.chat-page__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 10px;
    background: var(--chat-accent-soft);
    color: var(--chat-accent);
    font-size: .9rem;
    line-height: 1;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-page__title {
    min-width: 0;
    flex: 1 1 auto;
}

.chat-page__title h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--chat-ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-page__meta {
    font-size: .8rem;
    color: var(--chat-muted);
}

.chat-page__leave {
    flex: 0 0 auto;
}

.chat-page__notice {
    margin: 2rem;
    padding: 1.5rem;
    text-align: center;
    background: #f8fafc;
    border-radius: 12px;
    color: var(--chat-muted);
}

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    min-height: 0;
}

.chat-messages__inner {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    min-height: 100%;
    justify-content: flex-end;
}

.chat-messages__empty {
    margin: auto;
    color: var(--chat-muted);
    font-size: .9rem;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: min(78%, 40rem);
    align-self: flex-start;
}

.chat-msg--own {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg__author {
    font-size: .72rem;
    color: var(--chat-muted);
    margin-bottom: .1rem;
    padding: 0 .25rem;
    align-self: flex-start;
}

.chat-msg__bubble {
    padding: .55rem .8rem;
    border-radius: 12px 12px 12px 4px;
    background: #f1f5f9;
    color: var(--chat-ink);
    font-size: .92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-msg--own .chat-msg__bubble {
    background: var(--chat-accent);
    color: #fff;
    border-radius: 12px 12px 4px 12px;
}

.chat-msg__time {
    font-size: .68rem;
    color: var(--chat-muted);
    margin-top: .15rem;
    padding: 0 .25rem;
    align-self: flex-start;
}

.chat-msg--own .chat-msg__author,
.chat-msg--own .chat-msg__time {
    align-self: flex-end;
}

.chat-composer {
    display: flex;
    gap: .5rem;
    padding: .7rem 1rem;
    border-top: 1px solid var(--chat-line);
    background: #fafbfe;
}

.chat-composer__input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid var(--chat-line);
    border-radius: 10px;
    padding: .55rem .7rem;
    font-size: .92rem;
    line-height: 1.4;
}

.chat-composer__input:focus {
    outline: none;
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 3px var(--chat-accent-soft);
}

.chat-composer__send {
    flex: 0 0 auto;
    align-self: flex-end;
}

.chat-composer__hint {
    padding: 0 1rem .6rem;
    font-size: .72rem;
    color: var(--chat-muted);
    background: #fafbfe;
}

@media (max-width: 575.98px) {
    .chat-page {
        height: min(80vh, 640px);
    }

    .chat-msg {
        max-width: 88%;
    }
}

/* ---------------------------------------------------------------- layout with participants */
.chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 991.98px) {
    .chat-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.chat-side {
    background: #fff;
    border: 1px solid var(--chat-line, #e6e8ec);
    border-radius: 14px;
    padding: .9rem 1rem;
    max-height: min(72vh, 780px);
    overflow-y: auto;
}

.chat-side__title {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .75rem;
    font-size: .95rem;
    font-weight: 700;
    color: #1f2937;
}

.chat-side__count {
    margin-left: auto;
    font-size: .78rem;
    font-weight: 600;
    color: #64748b;
}

.chat-members {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.chat-members__item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .3rem .35rem;
    border-radius: 9px;
}

.chat-members__item:hover {
    background: rgba(26, 86, 219, .06);
}

.chat-members__avatar {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 86, 219, .1);
    color: var(--cassiopeia-color-primary, #1a56db);
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
}

.chat-members__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.chat-members__name {
    font-size: .88rem;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-members__me {
    font-size: .68rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 0 .3rem;
    margin-left: .25rem;
}

.chat-members__username {
    font-size: .75rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-members__write {
    flex: 0 0 auto;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--cassiopeia-color-primary, #1a56db);
    text-decoration: none;
}

.chat-members__write:hover {
    background: rgba(26, 86, 219, .1);
}

.chat-side__person {
    text-align: center;
    padding: .75rem 0;
}

.chat-side__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    background: rgba(26, 86, 219, .1);
    color: var(--cassiopeia-color-primary, #1a56db);
    font-size: 1.3rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: .5rem;
}

.chat-side__person-name {
    font-weight: 700;
    color: #1f2937;
}

.chat-side__person-username {
    font-size: .82rem;
    color: #64748b;
}

/* ---------------------------------------------------------------- direct messages list */
.chat-hub__subtitle {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: 1.5rem 0 .75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
}

.chat-dm {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.chat-dm__item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .8rem;
    background: #fff;
    border: 1px solid var(--chat-line, #e6e8ec);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
}

.chat-dm__item:hover {
    border-color: rgba(26, 86, 219, .35);
    text-decoration: none;
    color: inherit;
}

.chat-dm__avatar {
    flex: 0 0 auto;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 86, 219, .1);
    color: var(--cassiopeia-color-primary, #1a56db);
    font-weight: 700;
    text-transform: uppercase;
}

.chat-dm__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.chat-dm__name {
    font-weight: 600;
    font-size: .9rem;
    color: #1f2937;
}

.chat-dm__last {
    font-size: .8rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------- unread badges */
.chat-badge-inline {
    flex: 0 0 auto;
    min-width: 1.3rem;
    height: 1.3rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 .3rem;
}

.chat-card__main {
    position: relative;
}

.chat-card__main .chat-badge-inline {
    margin-left: auto;
}

/* ---------------------------------------------------------------- floating phone badge */
.chat-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1050;
}

.chat-fab__btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.6rem;
    height: 3.6rem;
    border-radius: 50%;
    background: var(--cassiopeia-color-primary, #1a56db);
    color: #fff;
    font-size: 1.3rem;
    text-decoration: none;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .28);
    transition: transform .15s ease, box-shadow .15s ease;
}

.chat-fab__btn:hover,
.chat-fab__btn:focus-visible {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .32);
}

.chat-fab__count {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.chat-fab__count[hidden] {
    display: none;
}

.chat-fab[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- contacts */
.chat-hub__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.chat-hub__head .chat-hub__title {
    margin: 0;
}

.chat-search {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}

.chat-search__input {
    max-width: 28rem;
}

.chat-contacts__item {
    gap: .75rem;
}

.chat-contacts__item .btn {
    flex: 0 0 auto;
}

/* ---------------------------------------------------------------- create chat form */
.chat-hub__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    padding: 1.25rem 1.35rem;
    background: #fff;
    border: 1px solid var(--chat-line, #e6e8ec);
    border-radius: 14px;
}

.chat-form__row {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.chat-icon-presets {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.chat-icon-presets__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--chat-line, #e6e8ec);
    border-radius: 8px;
    background: transparent;
    color: #1f2937;
    cursor: pointer;
}

.chat-icon-presets__btn:hover {
    background: rgba(26, 86, 219, .08);
    color: var(--cassiopeia-color-primary, #1a56db);
}

.chat-side__add {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-top: .9rem;
    padding-top: .8rem;
    border-top: 1px solid var(--chat-line, #e6e8ec);
}

.chat-side__add-title {
    font-size: .8rem;
    font-weight: 700;
    color: #64748b;
}
