/* =========================================
   Arquivo: filex/css/mensagens.css
   XONA — MENSAGENS
   Requer main.css carregado antes.
   ========================================= */

.messages-body { overflow: hidden; }

body.messages-body .main-content {
    margin-right: 0 !important;
    margin-left: 260px;
    max-width: none !important;
    width: auto;
    padding: 0 !important;
}
.messages-main {
    padding: 0 !important;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.messages-main .top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px 0;
    margin-bottom: 12px;
    position: static;
}
.messages-page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}
.messages-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.messages-header-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.messages-header-btn:hover {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
}
.messages-header-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--accent-pink);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    min-width: 16px;
    text-align: center;
}

/* Layout 2 colunas */
.messages-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 270px 1fr;
    gap: 14px;
    padding: 0 24px 24px;
    min-height: 0;
    overflow: hidden;
}
.conversations-panel,
.chat-panel { min-width: 0; }

/* Conversas */
.conversations-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.conversations-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px 12px;
}
.conversations-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.conversations-new-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--accent-pink);
    border: none;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}
.conversations-new-btn:hover { background-color: var(--accent-pink-hover); }

.conversations-tabs {
    display: flex;
    gap: 6px;
    padding: 0 14px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}
.conversations-tabs::-webkit-scrollbar { display: none; }

.conv-tab {
    flex-shrink: 0;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    padding: 6px 11px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.conv-tab:hover {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
}
.conv-tab.active {
    background-color: var(--accent-pink);
    border-color: var(--accent-pink);
    color: #fff;
}
.conv-tab-badge {
    background-color: rgba(255, 255, 255, 0.25);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
}
.conv-tab.active .conv-tab-badge {
    background-color: rgba(255, 255, 255, 0.35);
}

.conversations-search {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 9px 14px;
    margin: 0 14px 12px;
    transition: border-color 0.2s;
}
.conversations-search:focus-within { border-color: var(--accent-pink); }
.conversations-search i { color: var(--text-muted); font-size: 13px; }
.conversations-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    min-width: 0;
}
.conversations-search input::placeholder { color: var(--text-muted); }

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: #30363d transparent;
}
.conversations-list::-webkit-scrollbar { width: 4px; }
.conversations-list::-webkit-scrollbar-track { background: transparent; }
.conversations-list::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 999px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.15s;
    position: relative;
}
.conversation-item:hover { background-color: var(--bg-dark); }
.conversation-item.active {
    background-color: rgba(240, 36, 110, 0.1);
    border-left: 3px solid var(--accent-pink);
}
.conversation-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}
.conversation-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    background-color: var(--bg-dark);
}
.conversation-online {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background-color: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}
.conversation-item.active .conversation-online { border-color: #1a050c; }
.conversation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.conversation-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-last-message {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conversation-last-message.unread {
    color: var(--text-primary);
    font-weight: 500;
}
.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.conversation-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.conversation-unread-badge {
    background-color: var(--accent-pink);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat */
.chat-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    width: 100%;
}
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card);
    flex-shrink: 0;
}
.chat-back-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}
.chat-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-header-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-status {
    font-size: 12px;
    color: #22c55e;
    font-weight: 500;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-header-btn:hover {
    background-color: var(--bg-dark);
    color: var(--accent-pink);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    min-width: 0;
    scrollbar-width: thin;
    scrollbar-color: #30363d transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 999px;
}

.chat-date-separator {
    align-self: center;
    background-color: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    margin: 8px 0;
}

.chat-message {
    max-width: 68%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: relative;
    animation: messageIn 0.2s ease;
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-message.received { align-self: flex-start; }
.chat-message.sent {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.chat-message.received .chat-bubble {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-message.sent .chat-bubble {
    background-color: var(--accent-pink);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 6px;
}
.chat-message.sent .chat-meta { color: rgba(240, 36, 110, 0.75); }
.chat-message.sent .chat-meta i {
    color: var(--accent-pink);
    font-size: 11px;
}

.chat-bubble-image {
    max-width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
}
.chat-bubble-image img {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
}
.chat-bubble-image .image-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
}
.chat-bubble-image .image-hd {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
}

/* Input bar */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-card);
    flex-shrink: 0;
}
.chat-input-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-input-btn:hover {
    color: var(--accent-pink);
    background-color: var(--bg-dark);
}
.chat-input {
    flex: 1;
    min-width: 0;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--accent-pink); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background-color: var(--accent-pink);
    border: none;
    color: #fff;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:hover {
    background-color: var(--accent-pink-hover);
    transform: scale(1.05);
}

/* Responsivo */
@media (max-width: 1400px) {
    .messages-layout { grid-template-columns: 260px 1fr; }
}
@media (max-width: 1200px) {
    .messages-layout { grid-template-columns: 260px 1fr; }
}
@media (max-width: 900px) {
    .messages-layout { grid-template-columns: 250px 1fr; }
}

@media (max-width: 768px) {
    body.messages-body .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 0 !important;
    }
    .messages-body { overflow: auto; }
    .messages-main {
        height: auto;
        min-height: 100vh;
        padding: 0 !important;
    }
    .messages-main .top-header { display: none; }
    .messages-layout {
        display: block;
        padding: 0;
        min-height: calc(100vh - 60px);
        position: relative;
    }
    .conversations-panel {
        border: none;
        border-radius: 0;
        height: calc(100vh - 60px);
        padding-bottom: 110px;
    }
    .conversations-top { padding: 14px 14px 10px; }
    .conversations-title { font-size: 20px; }
    .conversations-tabs { padding: 0 14px 10px; gap: 6px; }
    .conv-tab { font-size: 12px; padding: 6px 11px; }
    .conversations-search { margin: 0 14px 10px; }
    .conversation-avatar { width: 44px; height: 44px; }
    .chat-panel {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        inset: 0;
        width: 100%;
        height: 100dvh;
        border: none;
        border-radius: 0;
        z-index: 300;
        padding-bottom: 0;
    }
    .chat-panel.open { display: flex; }
    .chat-back-btn { display: flex; }
    .chat-header { padding: 12px 14px; }
    .chat-avatar { width: 38px; height: 38px; }
    .chat-header-name { font-size: 14px; }
    .chat-header-status { font-size: 11px; }
    .chat-header-actions .chat-header-btn:nth-child(1),
    .chat-header-actions .chat-header-btn:nth-child(4) {
        display: none;
    }
    .chat-messages { padding: 16px 14px; }
    .chat-message { max-width: 82%; }
    .chat-bubble { font-size: 14px; padding: 9px 13px; }
    .chat-input-bar {
        padding: 10px 12px 14px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    .chat-input-btn { width: 34px; height: 34px; font-size: 15px; }
    .chat-send-btn { width: 40px; height: 40px; font-size: 14px; }
}