* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #dfe3e8;
}

.app {
    max-width: 900px;
    height: 95vh;
    margin: 2.5vh auto;
    display: flex;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
        0 5px 25px
        rgba(0,0,0,.18);
}

.sidebar {
    width: 300px;
    border-right:
        1px solid #ddd;
    background: #fff;
}

.logo {
    background: #075e54;
    color: white;
    padding: 20px;
    font-size: 22px;
    font-weight: bold;
}

.login {
    padding: 15px;
}

.login input {
    width: 100%;
    padding: 11px;
    margin-bottom: 10px;
    border-radius: 8px;
    border:
        1px solid #bbb;
}

.login button {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 8px;
    background: #128c7e;
    color: white;
}

.connection {
    padding: 10px 15px;
    font-size: 13px;
    border-bottom:
        1px solid #eee;
}

.users-title {
    padding: 15px;
    font-weight: bold;
}

#onlineUsers {
    padding: 0 15px;
}

.user {
    padding: 12px;
    border-bottom:
        1px solid #eee;
    cursor: pointer;
}

.dot {
    color: green;
}

.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 18px;
    background: #f0f2f5;
    border-bottom:
        1px solid #ddd;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #efeae2;
}

.message-row {
    display: flex;
    margin-bottom: 8px;
}

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

.bubble {
    padding: 9px 12px;
    border-radius: 9px;
    max-width: 70%;
    background: white;
}

.mine .bubble {
    background: #d9fdd3;
}

.sender {
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 4px;
}

.meta {
    display: flex;
    justify-content:
        flex-end;
    gap: 5px;
    margin-top: 4px;
    font-size: 10px;
    color: #667781;
}

.footer {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #f0f2f5;
}

.footer input {
    border: none;
    border-radius: 20px;
    padding: 12px 15px;
}

#recipient {
    width: 150px;
}

#messageInput {
    flex: 1;
}

.footer button {
    border: none;
    border-radius: 20px;
    padding: 0 20px;
    background: #128c7e;
    color: white;
}

.system {
    text-align: center;
    color: #777;
    font-size: 12px;
    margin: 10px;
}

.conversation-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.conversation-item:hover {
    background: #f5f5f5;
}

.conversation-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.conversation-name {
    font-weight: bold;
}

.conversation-time {
    font-size: 11px;
    color: #777;
}

.conversation-bottom {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    gap: 10px;
}

.conversation-last {
    font-size: 12px;
    color: #666;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #25d366;
    color: white;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.meta .read {
    color: #53bdeb;
    font-weight: bold;
}

.mobile-back {
    display: none;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    padding: 0 10px 0 0;
}

@media (max-width: 700px), (max-width: 1100px) and (pointer: coarse) and (hover: none) {

    html,
    body {
        height: 100%;
        overflow: hidden;
    }

    body {
        background: white;
    }

    .app {
        width: 100%;
        max-width: none;
        height: 100vh;
        height: 100dvh;
        height: var(--mobile-viewport-height, 100dvh);
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        position: fixed;
        top: var(--mobile-viewport-top, 0px);
        left: 0;
        overflow: hidden;
    }

    .sidebar {
        width: 100%;
        height: 100%;
        border-right: none;
        display: block;
        overflow-y: auto;
    }

    .chat {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        background: white;

        transform: translateX(100%);
        transition: transform .22s ease;
        z-index: 10;
    }

    .app.mobile-chat-open .chat {
        transform: translateX(0);
    }

    .chat-header {
        min-height: 60px;
        display: flex;
        align-items: center;
    }

    .mobile-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .messages {
        min-height: 0;
        padding: 12px;
        overscroll-behavior-y: contain;
    }

    .chat-header,
    .footer {
        flex-shrink: 0;
    }

    .login input,
    .footer input {
        font-size: 16px;
    }

    .bubble {
        max-width: 85%;
    }

    .footer {
        padding: 8px;
        gap: 6px;
    }

    #recipient {
        display: none;
    }

    #messageInput {
        min-width: 0;
        width: 100%;
    }

    .footer button {
        padding: 0 16px;
    }

    .logo {
        font-size: 20px;
        padding: 16px;
    }

    .login {
        padding: 12px;
    }

    .users-title {
        padding: 12px 15px;
    }

    .conversation-item {
        padding: 14px 15px;
    }

    .user {
        padding: 14px 12px;
    }
}

/* Keep writing controls usable on phones with little vertical space. */
@media (max-width: 1100px) and (max-height: 500px) and (pointer: coarse) and (hover: none) {
    .chat-header {
        min-height: 40px;
        padding: 6px 12px;
    }

    .footer {
        padding: 4px 8px;
    }

    .footer input {
        padding: 8px 12px;
    }

    .messages {
        padding: 6px 12px;
    }
}

/* The keyboard can leave less room than the normal header and composer need. */
.app.mobile-short-height .chat-header {
    min-height: 0;
    height: 28px;
    padding: 0 8px;
    font-size: 14px;
}

.app.mobile-short-height .mobile-back {
    font-size: 20px;
}

.app.mobile-short-height .messages {
    flex: 1 1 0px;
    min-height: 0;
    padding: 0 8px;
}

.app.mobile-short-height .footer {
    height: 34px;
    padding: 2px 6px;
    gap: 6px;
}

.app.mobile-short-height .footer input {
    min-height: 0;
    height: 30px;
    padding: 3px 10px;
    line-height: 24px;
}

.app.mobile-short-height .footer button {
    height: 30px;
    padding: 0 12px;
}

[hidden] { display: none !important; }
.login label { display: block; margin-bottom: 5px; font-size: 13px; }
#sessionControls button + button { margin-top: 8px; }
.login button:disabled { opacity: .6; cursor: wait; }
.sidebar { overflow-y: auto; }

/* Conversation navigation */
.account-card { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.account-caption { color: #667781; font-size: 12px; }
#accountName { font-size: 20px; overflow-wrap: anywhere; }
.chat-tools { padding: 14px 15px; border-bottom: 1px solid #edf0f2; }
.chat-tools-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.chat-tools button { border: none; border-radius: 8px; background: #e4f4ee; color: #075e54; padding: 9px 10px; cursor: pointer; font-weight: bold; }
.chat-tools input { width: 100%; min-width: 0; border: 1px solid #cdd6d4; border-radius: 9px; padding: 10px; font: inherit; font-size: 16px; }
#newChatForm { margin-top: 14px; }
#newChatForm label { display: block; margin-bottom: 8px; font-size: 13px; }
.field-hint, .list-empty { color: #667781; font-size: 13px; line-height: 1.4; }
.field-error { color: #a22828; font-size: 13px; }
.new-chat-actions { display: flex; gap: 8px; }
.list-empty { padding: 4px 15px; }
.conversation-item, .user { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #eee; background: white; font: inherit; color: inherit; }
.conversation-item.selected { background: #e3f2ed; box-shadow: inset 4px 0 #128c7e; }
.conversation-item.selected .conversation-name { color: #075e54; }
button:focus-visible, input:focus-visible { outline: 2px solid #128c7e; outline-offset: 2px; }
.conversation-name { min-width: 0; overflow-wrap: anywhere; }
.conversation-time, .unread-badge { flex-shrink: 0; }
.chat { min-width: 0; min-height: 0; }
.messages { min-height: 0; }
.chat-header, .footer { flex-shrink: 0; }
#messageInput { min-width: 0; }
.bubble { overflow-wrap: anywhere; }
.sidebar { flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Image attachment and protected image messages */
.footer #attachImageButton { padding: 0 10px; font-size: 24px; flex-shrink: 0; background: transparent; color: #075e54; }
.image-dialog { width: min(480px, 92vw); max-height: 90vh; max-height: 90dvh; overflow-y: auto; border: none; border-radius: 14px; padding: 16px; color: #182923; }
.image-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.image-dialog h2 { margin: 0 0 12px; font-size: 18px; overflow-wrap: anywhere; }
.image-dialog > img { display: block; width: 100%; max-height: 55vh; max-height: 55dvh; object-fit: contain; }
.image-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.image-actions button { padding: 10px 14px; border: none; border-radius: 8px; background: #128c7e; color: white; font: inherit; cursor: pointer; }
.image-actions button:disabled { opacity: .6; cursor: wait; }
.image-message { display: block; width: min(260px, 60vw); max-width: 100%; border: none; border-radius: 6px; padding: 0; overflow: hidden; background: #e5eae7; color: #42584e; cursor: pointer; }
.image-message img { display: block; width: 100%; height: auto; max-height: 280px; object-fit: contain; }
.image-message span { display: block; padding: 10px; font-size: 12px; }

.document-message { display: grid; gap: 8px; min-width: 140px; max-width: min(280px, 65vw); overflow-wrap: anywhere; }
.document-message button { justify-self: start; padding: 8px 12px; border: 1px solid #128c7e; border-radius: 8px; color: #075e54; background: white; font: inherit; cursor: pointer; }
.document-message small { color: #52666a; }
#attachmentDetails { overflow-wrap: anywhere; }

.reply-composer { display: flex; align-items: center; gap: 8px; flex-shrink: 0; background: #e4f2ed; padding: 8px 12px; border-left: 4px solid #128c7e; }
.reply-composer[hidden] { display: none; }
#replySummary { flex: 1; min-width: 0; max-height: 3em; overflow: auto; overflow-wrap: anywhere; font-size: 13px; }
.reply-composer button { border: 0; background: transparent; font-size: 24px; color: #075e54; padding: 2px 10px; cursor: pointer; }
.reply-action { border: 0; background: transparent; color: #075e54; font: inherit; padding: 4px 6px; cursor: pointer; }
.reply-quote { display: grid; gap: 3px; border: 0; border-left: 3px solid #128c7e; background: rgba(18,140,126,.1); border-radius: 4px; padding: 8px; margin: 4px 0 8px; max-width: min(320px, 65vw); text-align: left; font: inherit; color: #214d43; cursor: pointer; overflow-wrap: anywhere; }
.reply-quote span { font-size: 13px; max-height: 4.5em; overflow: auto; }
.quoted-highlight .bubble { outline: 2px solid #128c7e; }
.mobile-short-height .reply-composer { padding: 2px 8px; }
.mobile-short-height #replySummary { max-height: 1.5em; }

.chat-header { display: flex; align-items: center; gap: 10px; }
#chatTitle { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.search-control, .message-search-panel button { border: 0; border-radius: 6px; padding: 6px 10px; color: #075e54; background: #e4f2ed; cursor: pointer; }
.message-search-panel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 10px; background: #f0f2f5; flex-shrink: 0; }
.message-search-panel[hidden], #openMessageSearch[hidden] { display: none; }
#messageSearchInput { flex: 1; min-width: 100px; width: 0; padding: 8px; border: 1px solid #ccd6d3; border-radius: 6px; font-size: 16px; }
#messageSearchStatus { width: 100%; color: #52666a; }
.search-match .bubble { outline: 3px solid #b58100; background-color: #fff2bb; }
.message-search-panel button:disabled { opacity: .45; cursor: default; }
.mobile-short-height .message-search-panel { padding: 2px 6px; gap: 2px; }
.mobile-short-height #messageSearchInput { padding: 2px; }
.mobile-short-height #messageSearchStatus { width: auto; }

.message-date { display: flex; justify-content: center; margin: 12px 0; clear: both; }
.message-date span { padding: 5px 12px; border-radius: 8px; background: #e7efed; color: #425954; font-size: 12px; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.draft-label { color: #a33b1f; font-weight: 600; }

#openSharedFiles[hidden] { display: none; }
.shared-files-dialog { width: min(680px, 92vw); }
.shared-files-tools { display: flex; justify-content: space-between; gap: 12px; position: sticky; top: -16px; background: white; padding: 8px 0; }
.shared-files-tools select { padding: 8px; border: 1px solid #ccd6d3; border-radius: 6px; font: inherit; }
#sharedFilesList { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.shared-file-card { min-width: 0; padding: 12px; border: 1px solid #dce6e2; border-radius: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; overflow-wrap: anywhere; }
.shared-file-meta { margin: 0; color: #52666a; font-size: 12px; }
.shared-file-card .document-message { max-width: 100%; min-width: 0; }

.footer textarea { border: none; border-radius: 20px; padding: 11px 15px; background: white; color: #111; font-family: inherit; font-size: 16px; line-height: 22px; resize: none; box-sizing: border-box; height: 44px; min-height: 0; max-height: 140px; }
.footer { align-items: center; }
.footer > button { min-height: 40px; }
textarea:focus-visible { outline: 2px solid #128c7e; outline-offset: 2px; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.app.mobile-short-height .footer textarea { padding: 3px 10px; line-height: 24px; height: 30px; max-height: 30px; }
.app.mobile-short-height .footer > button { min-height: 30px; }

/* =========================================================
   C5Chat - Avatares y presencia
   ========================================================= */

.chat-contact {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.chat-contact-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

#chatTitle {
    display: block;
    line-height: 1.2;
}

.chat-presence {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 400;
    color: #667781;
}

.chat-presence.online {
    color: #128c7e;
}


.contact-avatar,
.conversation-avatar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 42px;
    height: 42px;

    border-radius: 50%;

    background: #dfe5e3;
    color: #546762;

    font-size: 17px;
    font-weight: 600;

    user-select: none;
}


.contact-avatar {
    width: 44px;
    height: 44px;
    font-size: 18px;
}


.conversation-item {
    display: grid !important;

    grid-template-columns:
        48px minmax(0, 1fr);

    grid-template-areas:
        "avatar top"
        "avatar bottom";

    column-gap: 10px;

    align-items: center;
}


.conversation-avatar {
    grid-area: avatar;
    align-self: center;
}


.conversation-top {
    grid-area: top;
    min-width: 0;
}


.conversation-bottom {
    grid-area: bottom;
    min-width: 0;
}


.avatar-online-dot {
    position: absolute;

    right: 0;
    bottom: 1px;

    width: 11px;
    height: 11px;

    border-radius: 50%;

    background: #25d366;

    border: 2px solid white;
    box-sizing: content-box;
}

/* =========================================================
   C5Chat - Fotos de perfil
   ========================================================= */

.contact-avatar,
.conversation-avatar {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.contact-avatar.has-photo,
.conversation-avatar.has-photo {
    color: transparent;
}

.avatar-online-dot {
    z-index: 2;
}


.profile-account-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar-button {
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.profile-avatar-button:hover .profile-avatar {
    filter: brightness(.96);
}

.profile-avatar-button:focus-visible {
    outline: 3px solid #128c7e;
    outline-offset: 3px;
}


.profile-avatar {
    width: 56px;
    height: 56px;
    font-size: 21px;
    cursor: pointer;
}


.account-profile-info {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
}


.profile-photo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
}

.profile-photo-actions button {
    border: 0;
    border-radius: 6px;
    padding: 4px 8px;
    background: #e4f2ed;
    color: #075e54;
    font-size: 11px;
    cursor: pointer;
}

.profile-photo-actions button:hover {
    background: #d8ece5;
}

.profile-photo-actions .remove-avatar-button {
    background: #f1f3f2;
    color: #52635f;
}


.avatar-status {
    display: block;
    min-height: 14px;
    margin-top: 4px;
    color: #667781;
    font-size: 10px;
    line-height: 1.25;
}


@media (
    max-width: 700px
),
(
    max-width: 1100px
)
and (pointer: coarse)
and (hover: none) {

    .profile-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}


/* Avatar ampliable */

.clickable-avatar {
    cursor: pointer;
    transition:
        transform .12s ease,
        filter .12s ease;
}

.clickable-avatar:hover {
    filter: brightness(.94);
    transform: scale(1.04);
}

.clickable-avatar:focus-visible {
    outline: 3px solid #128c7e;
    outline-offset: 2px;
}

#viewerImage {
    max-width: min(80vw, 720px);
    max-height: 75vh;
    object-fit: contain;
}


/* =========================================================
   Nuevo grupo
   ========================================================= */

.new-conversation-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#newGroupForm {
    margin-top: 10px;
}

.new-group-members-heading {
    margin-top: 12px;
    margin-bottom: 7px;
    font-size: 0.86rem;
    font-weight: 600;
}

.new-group-members {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 230px;
    overflow-y: auto;
    padding: 4px 2px;
}

.new-group-member {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
}

.new-group-member:hover {
    background: rgba(127, 127, 127, 0.10);
}

.new-group-member input {
    flex: 0 0 auto;
}

.new-group-member-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(127, 127, 127, 0.16);
    font-weight: 700;
    flex: 0 0 30px;
}


/* Corrección visual de integrantes de grupo */
#newGroupMembers .new-group-member {
    display: flex !important;
    align-items: center !important;
    width: 100%;
    box-sizing: border-box;
    color: #1f2933 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

#newGroupMembers .new-group-member input[type="checkbox"] {
    display: inline-block !important;
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin: 0;
    width: 16px;
    height: 16px;
}

#newGroupMembers .new-group-member-avatar {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    border-radius: 50%;
    background: #e2ebe8 !important;
    color: #35524b !important;
    font-weight: 700;
    opacity: 1 !important;
    visibility: visible !important;
}

#newGroupMembers .new-group-member-name {
    display: inline-block !important;
    color: #1f2933 !important;
    opacity: 1 !important;
    visibility: visible !important;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================================================
   Información del grupo
   ========================================================= */

.group-info-button {
    font-size: 22px;
    line-height: 1;
    min-width: 36px;
}

.group-info-dialog {
    width: min(480px, 92vw);
    max-height: 82vh;
    border: 0;
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
}

.group-info-dialog::backdrop {
    background: rgba(0, 0, 0, .42);
}

.group-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid #e3e8e6;
}

.group-info-header h2 {
    margin: 0;
    font-size: 18px;
}

.group-info-close {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.group-info-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 16px;
    border-bottom: 1px solid #e3e8e6;
}

.group-info-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #d8ebe6;
    color: #075e54;
    font-size: 30px;
    font-weight: 700;
}

#groupInfoName {
    font-size: 19px;
    overflow-wrap: anywhere;
    text-align: center;
}

#groupInfoCount {
    color: #52666a;
    font-size: 13px;
}

.group-info-section-title {
    padding: 14px 18px 8px;
    color: #52666a;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

#groupInfoStatus {
    padding: 0 18px;
}

#groupInfoMembers {
    max-height: 42vh;
    overflow-y: auto;
    padding-bottom: 12px;
}

.group-info-member {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
}

.group-info-member-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #e4f2ed;
    color: #075e54;
    font-weight: 700;
}

.group-info-member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.group-info-member-text {
    min-width: 0;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
}

.group-info-member-text strong {
    overflow-wrap: anywhere;
}

.group-info-member-text span {
    color: #52666a;
    font-size: 12px;
}

@media (max-width: 600px) {
    .group-info-dialog {
        width: calc(100vw - 24px);
        max-height: 88vh;
    }

    #groupInfoMembers {
        max-height: 48vh;
    }
}


/* Administración de grupos */

.group-admin-actions {
    display: flex;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid #e3e8e6;
}

.group-admin-actions[hidden] {
    display: none;
}

.group-admin-actions button,
.group-member-add-actions button {
    border: 0;
    border-radius: 7px;
    padding: 8px 12px;
    background: #e4f2ed;
    color: #075e54;
    cursor: pointer;
    font: inherit;
}

.add-group-member-panel {
    display: grid;
    gap: 10px;
    padding: 12px 18px;
    background: #f7faf9;
    border-bottom: 1px solid #e3e8e6;
}

.add-group-member-panel[hidden] {
    display: none;
}

#addGroupMemberSelect {
    width: 100%;
    padding: 9px;
    border: 1px solid #ccd6d3;
    border-radius: 7px;
    background: white;
    font: inherit;
}

.group-member-add-actions {
    display: flex;
    gap: 8px;
}

.group-member-remove {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: #a33b1f;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    padding: 6px 8px;
}


/* Roles y bots de grupos */

.group-member-name-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.group-bot-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 5px;
    padding: 2px 5px;
    background: #d8ebe6;
    color: #075e54;
    font-size: 9px !important;
    font-weight: 700;
    letter-spacing: .04em;
}

.group-member-role {
    border: 0;
    background: transparent;
    color: #075e54;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    padding: 6px 7px;
    white-space: nowrap;
}

.group-member-remove {
    margin-left: 0;
}

.group-info-member-text {
    margin-right: auto;
}

/* =========================================================
   Edición y eliminación de mensajes
   ========================================================= */



.message-edited {
    font-size: 0.72rem;
    font-style: italic;
    opacity: 0.65;
    margin-right: 4px;
}

.message-deleted .message-text {
    font-style: italic;
    opacity: 0.7;
}

.message-deleted .sender {
    opacity: 0.8;
}

/* =========================================================
   Menú de acciones de mensaje
   ========================================================= */

.message-actions-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.message-actions-trigger {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0 4px;
    margin: 0;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.55;
    cursor: pointer;
    border-radius: 6px;
}

.message-actions-trigger:hover,
.message-actions-trigger:focus-visible {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

.message-actions-menu {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 5px);
    min-width: 135px;
    padding: 5px;
    border-radius: 9px;
    background: #fff;
    box-shadow:
        0 7px 24px rgba(0, 0, 0, 0.16);
    z-index: 50;
}

.message-actions-menu.open {
    display: flex;
    flex-direction: column;
}

.message-action-item {
    appearance: none;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 8px 10px;
    text-align: left;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
}

.message-action-item:hover,
.message-action-item:focus-visible {
    background: rgba(0, 0, 0, 0.06);
}

.message-action-delete {
    color: #b42318;
}

@media (max-width: 700px) {
    .message-actions-menu {
        min-width: 145px;
    }

    .message-action-item {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

/* =========================================================
   Posición del menú ⋮ dentro de la burbuja
   ========================================================= */

.message-row .bubble {
    position: relative;
    padding-right: 30px;
}

.message-row .bubble > .message-actions-wrapper {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 20;
}

.message-row .bubble > .message-actions-wrapper
.message-actions-trigger {
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    line-height: 1;
}

.message-row .bubble > .message-actions-wrapper
.message-actions-menu {
    right: 0;
    top: calc(100% + 4px);
    bottom: auto;
}

/* El menú de una burbuja propia se despliega hacia la izquierda
   del botón para no salirse del área del chat. */
.message-row.mine .bubble > .message-actions-wrapper
.message-actions-menu {
    right: 0;
    left: auto;
}

/* En pantallas pequeñas dejamos un blanco cómodo alrededor. */
@media (max-width: 700px) {
    .message-row .bubble {
        padding-right: 34px;
    }

    .message-row .bubble > .message-actions-wrapper {
        top: 6px;
        right: 6px;
    }
}

/* =========================================================
   Edición integrada en el compositor
   ========================================================= */

.edit-composer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-left: 4px solid currentColor;
    background: rgba(255, 255, 255, 0.92);
}

.edit-composer[hidden] {
    display: none;
}

.edit-composer > div {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.edit-composer strong {
    font-size: 0.82rem;
}

#editSummary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.7;
    font-size: 0.78rem;
}

.edit-composer > button {
    appearance: none;
    border: 0;
    background: transparent;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.65;
}

.edit-composer > button:hover {
    opacity: 1;
}

/* =========================================================
   Corrección de apilamiento del menú de mensajes
   ========================================================= */

.message-row .bubble > .message-actions-wrapper {
    z-index: auto;
}

.message-row .bubble > .message-actions-wrapper:has(
    .message-actions-menu.open
) {
    z-index: 1000;
}

.message-row .bubble:has(
    .message-actions-menu.open
) {
    z-index: 1000;
}

.message-row:has(
    .message-actions-menu.open
) {
    position: relative;
    z-index: 1000;
}

.message-actions-menu.open {
    z-index: 1001;
}

/* =========================================================
   Navegación visual de mensajes citados
   ========================================================= */

.reply-quote-deleted,
.reply-quote:disabled {
    cursor: default;
    opacity: 0.78;
}

.reply-quote:disabled:hover {
    background: rgba(18, 140, 126, .1);
}

.quoted-highlight .bubble {
    animation: c5chat-quoted-highlight 1.8s ease;
}

@keyframes c5chat-quoted-highlight {
    0% {
        outline: 3px solid #128c7e;
        transform: scale(1);
    }

    35% {
        outline: 4px solid #128c7e;
        transform: scale(1.015);
    }

    100% {
        outline: 2px solid transparent;
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .quoted-highlight .bubble {
        animation: none;
        outline: 3px solid #128c7e;
    }
}

.star-action { color: #946600; font-size: 16px; }
#starsList { display: grid; gap: 10px; }
#starsList .message-text { margin: 0; max-height: 160px; overflow: auto; }

/* =========================================================
   C5Chat - Reacciones a mensajes
   ========================================================= */

.message-reaction-picker {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 7px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
}

.message-reaction-option {
    border: 0;
    background: transparent;
    border-radius: 999px;
    padding: 5px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.message-reaction-option:hover {
    background: rgba(18, 140, 126, .12);
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.message-reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    border: 1px solid rgba(0, 0, 0, .12);
    background: rgba(255, 255, 255, .72);
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 14px;
    line-height: 18px;
    cursor: pointer;
}

.message-reaction-chip:hover {
    background: rgba(255, 255, 255, .95);
}

.message-reaction-chip.mine {
    border-color: #128c7e;
    background: rgba(18, 140, 126, .14);
}

.message-reaction-emoji {
    line-height: 1;
}

.message-reaction-count {
    font-size: 12px;
    font-weight: 600;
}

.message-deleted .message-reactions {
    display: none;
}

@media (max-width: 700px) {
    .message-reaction-option {
        padding: 6px;
        font-size: 22px;
    }

    .message-reaction-chip {
        padding: 3px 7px;
    }
}


#sharingText { box-sizing: border-box; width: 100%; height: 120px; font: inherit; padding: 8px; }
#sharingDialog button, #sharingTarget { padding: 9px 12px; margin: 5px 4px 5px 0; border: 1px solid #ccd6d3; border-radius: 7px; font: inherit; }
#sharingDialog button { background: #e4f2ed; color: #075e54; cursor: pointer; }
#sharingDialog button:disabled { opacity: .5; }
#sharingTarget { display: block; width: 100%; }
#sharingFilename { overflow-wrap: anywhere; }

/* Compact account toolbar; account actions stay available in its menu. */
.sidebar .logo { padding: 14px 18px; font-size: 21px; }
.sidebar .login { padding: 12px 14px 6px; }
#sessionControls .profile-account-card { flex-direction: row; gap: 10px; margin: 0; position: relative; }
#sessionControls .profile-avatar-button { width: auto; padding: 0; background: transparent; border-radius: 50%; }
#sessionControls .profile-avatar { width: 42px; height: 42px; font-size: 18px; }
#sessionControls #accountName { font-size: 18px; }
#sessionControls .account-caption { font-size: 11px; }
#sessionControls .avatar-status:empty { display: none; }
#sessionControls .account-stars { width: auto; margin-top: 8px; padding: 6px 10px; background: #e4f2ed; color: #075e54; font-size: 12px; cursor: pointer; }
.account-menu { margin-left: auto; flex-shrink: 0; }
.account-menu summary { display: flex; align-items: center; justify-content: center; width: 40px; height: 42px; border-radius: 8px; cursor: pointer; color: #075e54; font-size: 24px; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover, .account-menu[open] summary { background: #e4f2ed; }
.account-menu summary:focus-visible { outline: 2px solid #128c7e; outline-offset: 2px; }
.account-menu-actions { position: absolute; top: 46px; right: 0; width: 230px; max-width: 100%; z-index: 30; padding: 8px; background: white; border: 1px solid #dce5e2; border-radius: 10px; box-shadow: 0 6px 20px #0003; }
.account-menu-actions > strong { display: block; padding: 8px; font-size: 13px; color: #667781; }
#sessionControls .account-menu-actions button { display: block; width: 100%; margin: 2px 0; padding: 10px; text-align: left; background: white; color: #075e54; font: inherit; font-size: 14px; cursor: pointer; }
#sessionControls .account-menu-actions button:hover { background: #e4f2ed; }
#sessionControls .account-menu-actions button:disabled { opacity: .55; cursor: default; }
.sidebar .connection { padding: 7px 14px; font-size: 12px; }
.sidebar .chat-tools { padding: 10px 14px; }
.sidebar .chat-tools-heading { flex-wrap: wrap; margin-bottom: 8px; }
.sidebar .new-conversation-buttons { display: flex; flex-direction: row; flex-wrap: wrap; gap: 5px; }
.sidebar .new-conversation-buttons button { font-size: 12px; padding: 7px 8px; }
