/* Estilos Globais do Chat */
.chat-window { height: 100vh; display: flex; flex-direction: column; background: var(--bg-dark); }

.chat-header {
    height: 60px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.back-btn { margin-right: 15px; font-size: 1.2rem; text-decoration: none; color: white; }

.messages-container {
    flex: 1;
    overflow-y: auto;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    background-size: 400px;
    background-color: #0b141a;
    background-blend-mode: soft-light;
    opacity: 0.95;
}

#messages-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 15px 120px 15px !important;
}

.message-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
    word-wrap: break-word;
}

.message-bubble img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 250px; /* Tamanho padrão de tela de celular para miniaturas */
    border-radius: 6px;
    margin-bottom: 4px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-bubble img:hover {
    transform: scale(1.02);
}

.sent { 
    background: #005c4b;
    color: #e9edef;
    align-self: flex-end; 
    border-bottom-right-radius: 2px;
}

.received { 
    background: #202c33;
    color: #e9edef;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.input-container {
    padding: 10px 15px 80px 15px; /* Aumentado para 80px (+20px) para respiro total */
    background: linear-gradient(to top, rgba(10, 14, 18, 0.98), transparent);
    position: relative;
    z-index: 1000;
}

.input-bar {
    background: rgba(35, 45, 54, 0.9) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
    padding: 12px 12px 18px 12px !important; /* Adicionado 18px de padding interno inferior */
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-bar:focus-within {
    border-color: rgba(0, 168, 132, 0.5) !important;
    box-shadow: 0 8px 32px 0 rgba(0, 168, 132, 0.2) !important;
    transform: translateY(-2px);
}

.input-bar input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 8px !important; /* Sincronizado com a barra */
    padding: 12px 18px !important;
    color: white !important;
    outline: none !important;
    font-size: 1rem !important;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.4) !important;
    transition: all 0.3s ease;
}

.input-bar input:focus {
    background: rgba(0, 0, 0, 0.3) !important;
}

/* 3D Glass Buttons */
.input-bar button {
    width: 42px;
    height: 42px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.03) !important;
    border: 1px solid rgba(255,255,255,0.05) !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.input-bar button:hover {
    background: rgba(255,255,255,0.1) !important;
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

#bell-trigger .icon {
    animation: bell-glow 2s infinite;
}

@keyframes bell-glow {
    0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 202, 40, 0.2)); }
    50% { filter: drop-shadow(0 0 10px rgba(255, 202, 40, 0.6)); }
}

#submit-btn {
    background: var(--accent) !important;
    color: white !important;
    box-shadow: 0 4px 15px rgba(0, 168, 132, 0.3) !important;
}

/* E2EE Flicker Protection */
.msg-content[data-e2ee="true"] {
    font-size: 0 !important;
    opacity: 0;
}
.msg-content[data-e2ee="true"]::before {
    content: "🔒 Protegido...";
    font-size: 0.85rem;
    font-style: italic;
    opacity: 0.7;
    display: block;
}
.message-bubble.decrypted .msg-content[data-e2ee="true"] {
    font-size: 1rem !important;
    opacity: 1;
}
.message-bubble.decrypted .msg-content[data-e2ee="true"]::before {
    display: none;
}

/* Modal de Confirmação Premium */
#confirm-bell-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10001;
    justify-content: center;
    align-items: center;
}

.confirm-box {
    background: #1e1e1e;
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid #333;
}

@keyframes modalPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Estilos Adicionais do Header */
.chat-header .avatar {
    flex-shrink: 0;
}

.chat-header .info {
    flex: 1;
    min-width: 0;
}

.chat-header .info h4 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-options {
    position: relative;
}

.options-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

.options-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 45px;
    background: #232d36;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    min-width: 150px;
    overflow: hidden;
}

.options-menu a, .options-menu button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    color: #e9edef;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
}

.options-menu a:hover, .options-menu button:hover {
    background: #182229;
}

.options-menu .danger {
    color: #ff5252;
}

/* Scroll para baixo btn */
#scroll-bottom-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 42px;
    height: 42px;
    background: #202c33;
    color: #8696a0;
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 1px 1px 0 rgba(0,0,0,0.06), 0 2px 5px 0 rgba(0,0,0,0.2);
    z-index: 100;
}

#scroll-bottom-btn:hover {
    color: white;
}

.unread-count {
    position: absolute;
    top: -5px;
    left: -5px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
    display: none;
}

/* Audio Player */
.audio-player {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    padding: 5px 0;
}

.audio-player audio {
    height: 35px;
    flex: 1;
}

.mic-icon {
    font-size: 1.4rem;
    color: #8696a0;
    transition: color 0.3s;
}

.mic-played {
    color: #4fc3f7 !important; /* Azul Celeste Vibrante */
    filter: drop-shadow(0 0 5px rgba(79, 195, 247, 0.4));
}

.audio-avatar-wrapper {
    position: relative;
    width: 40px;
    height: 40px;
    margin-left: 5px;
    flex-shrink: 0;
}

.audio-msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 1px solid rgba(255,255,255,0.1);
}

.audio-unread-dot {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 12px;
    height: 12px;
    background: #00ef8b; /* Esmeralda Vibrante */
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 239, 139, 0.6);
    z-index: 10;
}

/* Recording UI */
.recording-ui {
    display: none;
    align-items: center;
    gap: 10px;
    flex: 1;
    color: #ff5252;
}

.input-bar.recording .recording-ui { display: flex; }
.input-bar.recording #chat-input, 
.input-bar.recording #voice-trigger,
.input-bar.recording span:first-child { display: none; }

.recording-dot {
    width: 10px;
    height: 10px;
    background: #ff5252;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Deletion UI */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none; /* JS will set to flex */
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #232d36;
    padding: 24px;
    border-radius: 20px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-modal-option {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: white;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.btn-modal-option:hover {
    background: rgba(255,255,255,0.1);
}

.btn-modal-cancel {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
}

.is-deleted-all {
    background: rgba(255,255,255,0.03) !important;
    border: 1px dashed rgba(255,255,255,0.1) !important;
    pointer-events: none; /* Não permitir interagir com mensagem apagada */
}

/* Attachment Menu */
.attachment-wrapper {
    position: relative;
}
#attachment-trigger {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dim);
}
.attachment-menu {
    display: none !important;
    position: absolute;
    bottom: 65px;
    left: 0;
    background: rgba(35, 45, 54, 0.98) !important;
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px !important;
    padding: 10px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.8);
    z-index: 1000;
    animation: menuSlideUp 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    flex-direction: row;
    gap: 4px;
    align-items: center;
}
.attachment-menu.active {
    display: flex !important;
}
@keyframes menuSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.attachment-menu button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: white;
    padding: 10px 5px;
    cursor: pointer;
    width: 75px;
    font-size: 0.75rem;
    transition: transform 0.2s;
}
.attachment-menu .icon {
    width: 48px;
    height: 48px;
    min-width: 48px; /* Previne distorção */
    min-height: 48px; /* Previne distorção */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.attachment-menu button:hover .icon {
    transform: scale(1.1);
}

/* Lightbox Premium */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(8px);
    z-index: 20000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: lightboxZoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lightboxZoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    padding: 10px;
    line-height: 1;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: #ff5252;
}

/* Reactions */
.message-reactions {
    position: absolute;
    bottom: -15px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    z-index: 10;
}

.sent .message-reactions {
    right: 15px;
}

.received .message-reactions {
    left: 15px;
}

.message-bubble {
    margin-bottom: 20px !important; /* Espaço para as reações flutuantes */
}

.reaction-badge {
    background: #202c33; /* Fundo sólido igual à mensagem recebida */
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 2px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.reaction-count {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-dim);
}

/* Emoji Picker UI */
.emoji-picker-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-dim);
}

.reaction-menu {
    position: fixed;
    background: #232d36;
    border-radius: 20px;
    padding: 8px 12px;
    display: flex;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 21000;
    animation: bounceIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.reaction-option {
    font-size: 1.4rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.reaction-option:hover {
    transform: scale(1.3);
}
