/**
 * CHAT.CSS - Estilos do Sistema de Chat
 */

/* ============================================
   LAYOUT PRINCIPAL DO CHAT
   ============================================ */

.chat-layout {
    display: flex;
    min-height: calc(100vh - 120px);
    max-height: calc(100vh - 100px);
    height: auto;
    background: var(--card-bg, #1a1a2e);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

/* ============================================
   SIDEBAR DO CHAT
   ============================================ */

.chat-sidebar {
    width: 320px;
    background: var(--sidebar-bg, rgba(30, 30, 50, 0.95));
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    display: flex;
    flex-direction: column;
}

.chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.chat-sidebar-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-sidebar-header h3 i {
    color: var(--accent-color, #6c5ce7);
}

.btn-new-chat {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-new-chat:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

.chat-search {
    padding: 1rem;
}

.chat-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #fff);
    font-size: 0.9rem;
}

.chat-search input::placeholder {
    color: var(--text-secondary, #999);
}

/* Lista de Salas */
.chat-rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-room-item {
    display: flex;
    align-items: center;
    padding: 0.875rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
}

.chat-room-item:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.05));
}

.chat-room-item.active {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(162, 155, 254, 0.1));
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.room-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.875rem;
    flex-shrink: 0;
}

.room-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.room-avatar span {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.room-info {
    flex: 1;
    min-width: 0;
}

.room-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary, #fff);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.room-last-message {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary, #999);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #e74c3c;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Usuários Online */
.chat-online-users {
    padding: 1rem;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.chat-online-users h4 {
    font-size: 0.85rem;
    color: var(--text-secondary, #999);
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-online-users h4 .text-success {
    color: #00b894;
    font-size: 0.5rem;
}

/* ============================================
   ÁREA PRINCIPAL DO CHAT
   ============================================ */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--main-bg, rgba(26, 26, 46, 0.5));
}

/* Tela de boas-vindas */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.welcome-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(162, 155, 254, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.welcome-icon i {
    font-size: 3rem;
    color: #6c5ce7;
}

.chat-welcome h2 {
    color: var(--text-primary, #fff);
    margin: 0 0 0.5rem 0;
}

.chat-welcome p {
    color: var(--text-secondary, #999);
    margin: 0 0 1.5rem 0;
}

/* Container de Sala */
.chat-room-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Importante para flexbox */
    overflow: hidden;
}

/* Header da Sala */
.chat-room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--header-bg, rgba(30, 30, 50, 0.5));
}

.room-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.room-header-info .room-avatar {
    width: 40px;
    height: 40px;
    margin-right: 0;
}

.room-details .room-name {
    font-size: 1rem;
}

.room-status {
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
}

.room-header-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary, #999);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.room-header-actions button:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.1));
    color: var(--text-primary, #fff);
}

/* ============================================
   ÁREA DE MENSAGENS
   ============================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100px;
    max-height: calc(100vh - 300px); /* Garante espaço para header e input */
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 70%;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.other {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-avatar span {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

.message-content {
    display: flex;
    flex-direction: column;
}

.message-sender {
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
    margin-bottom: 0.25rem;
}

.message-bubble {
    padding: 0.875rem 1.125rem;
    border-radius: 18px;
    max-width: 100%;
}

.message.own .message-bubble {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.other .message-bubble {
    background: var(--card-bg, rgba(255, 255, 255, 0.08));
    color: var(--text-primary, #fff);
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    margin: 0;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-secondary, #999);
    margin-top: 0.25rem;
}

.message.own .message-time {
    text-align: right;
}

/* ============================================
   INPUT DE MENSAGEM
   ============================================ */

.chat-input-container {
    padding: 1rem 1.5rem;
    background: var(--header-bg, rgba(30, 30, 50, 0.5));
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    flex-shrink: 0; /* Nunca encolhe */
    min-height: 70px; /* Altura mínima garantida */
    position: sticky;
    bottom: 0;
}

.chat-typing {
    font-size: 0.8rem;
    color: var(--text-secondary, #999);
    height: 20px;
    margin-bottom: 0.5rem;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-input-row input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border-radius: 24px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #fff);
    font-size: 0.95rem;
}

.chat-input-row input::placeholder {
    color: var(--text-secondary, #999);
}

.btn-emoji,
.btn-attach {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary, #999);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-emoji:hover,
.btn-attach:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.1));
    color: var(--accent-color, #6c5ce7);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}

/* ============================================
   ESTADOS VAZIOS E LOADING
   ============================================ */

.empty-state,
.loading-state,
.empty-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary, #999);
}

.empty-state i,
.loading-state i,
.empty-messages i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--accent-color, #6c5ce7);
    opacity: 0.5;
}

.empty-state p,
.loading-state p,
.empty-messages p {
    margin: 0 0 0.5rem 0;
}

.empty-state small,
.empty-messages small {
    font-size: 0.8rem;
    opacity: 0.7;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent-color, #6c5ce7);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
}

/* ============================================
   BOTÕES
   ============================================ */

.btn-primary {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

/* ============================================
   TEMA CLARO
   ============================================ */

html[data-theme="light"] .chat-layout,
:root:not([data-theme="dark"]) .chat-layout {
    background: #ffffff;
    border-color: #e2e8f0;
}

html[data-theme="light"] .chat-sidebar,
:root:not([data-theme="dark"]) .chat-sidebar {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .chat-sidebar-header h3,
html[data-theme="light"] .room-name,
:root:not([data-theme="dark"]) .chat-sidebar-header h3,
:root:not([data-theme="dark"]) .room-name {
    color: #1e293b;
}

html[data-theme="light"] .chat-search input,
:root:not([data-theme="dark"]) .chat-search input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

html[data-theme="light"] .chat-room-item:hover,
:root:not([data-theme="dark"]) .chat-room-item:hover {
    background: #f1f5f9;
}

html[data-theme="light"] .chat-main,
:root:not([data-theme="dark"]) .chat-main {
    background: #ffffff;
}

html[data-theme="light"] .message.other .message-bubble,
:root:not([data-theme="dark"]) .message.other .message-bubble {
    background: #f1f5f9;
    color: #1e293b;
}

html[data-theme="light"] .chat-input-row input,
:root:not([data-theme="dark"]) .chat-input-row input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

html[data-theme="light"] .chat-welcome h2,
:root:not([data-theme="dark"]) .chat-welcome h2 {
    color: #1e293b;
}

html[data-theme="light"] .chat-room-header,
html[data-theme="light"] .chat-input-container,
:root:not([data-theme="dark"]) .chat-room-header,
:root:not([data-theme="dark"]) .chat-input-container {
    background: #f8fafc;
    border-color: #e2e8f0;
}

/* ============================================
   RESPONSIVIDADE
   ============================================ */

@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
        height: calc(100vh - 80px);
    }

    .chat-sidebar {
        width: 100%;
        max-height: 40vh;
    }

    .chat-main {
        min-height: 60vh;
    }

    .message {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .chat-sidebar {
        max-height: 35vh;
    }

    .room-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-input-container {
        padding: 0.75rem 1rem;
    }
}

/* ============================================
   EMOJI PICKER
   ============================================ */

.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg, #1e1e2e);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 350px;
    overflow: hidden;
}

.emoji-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--sidebar-bg, rgba(30, 30, 50, 0.95));
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.emoji-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.emoji-tab {
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.emoji-tab:hover {
    background: rgba(108, 92, 231, 0.2);
}

.emoji-tab.active {
    background: rgba(108, 92, 231, 0.3);
}

.emoji-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary, #999);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.emoji-close:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

.emoji-content {
    padding: 4px;
    max-height: 280px;
    overflow-y: auto;
}

.emoji-section {
    display: grid !important;
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 0;
    width: 100%;
}

.emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    width: 100%;
    aspect-ratio: 1;
}

.emoji-item:hover {
    background: rgba(108, 92, 231, 0.2);
    transform: scale(1.2);
}

/* ============================================
   EMOJIS NAS MENSAGENS DO CHAT
   ============================================ */

/* Emojis maiores nas mensagens */
.message-bubble p {
    font-size: 1rem;
    line-height: 1.5;
}

/* Detecta mensagens que são só emojis e aumenta o tamanho */
.message-bubble {
    font-size: 1rem;
}

/* Emojis inline nas mensagens ficam maiores */
.message-bubble p:only-child {
    font-size: 1.8rem;
}

/* ============================================
   IMAGENS NO CHAT
   ============================================ */

.chat-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 8px;
}

.chat-image:hover {
    transform: scale(1.02);
}

.chat-image-expired {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    color: var(--text-secondary, #999);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-image-expired i {
    color: #ff6b6b;
}

/* Lightbox para visualizar imagens em tela cheia */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
}

.image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

