/* --- GERAL E RESET --- */
* { padding: 0; margin: 0; box-sizing: border-box; }
html, body {
    height: 100%; background-color: #e5ddd5; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
}

/* --- ESTRUTURA --- */
.container { max-width: 850px; height: 100%; margin: auto; display: flex; flex-direction: column; }
.chat { display: flex; flex-direction: column; height: 100%; background-color: transparent; position: relative; }
.chat-box { flex: 1; padding: 10px; padding-bottom: 50px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }

/* --- CABEÇALHO --- */
.chat-header { background: #005E54; color: white; display: flex; align-items: center; padding: 10px 15px; height: 60px; flex-shrink: 0; z-index: 20; }
.profile { display: flex; align-items: center; width: 100%; }
.profile .left { display: flex; align-items: center; flex-grow: 1; }
.profile .pp { width: 40px; height: 40px; border-radius: 50%; margin-right: 15px; }
.profile h2 { font-size: 16px; font-weight: 500; }
.profile span { font-size: 13px; color: #d1d1d1; }
.profile .verified-icon { width: 16px; height: 16px; margin-left: 5px; vertical-align: text-bottom; }
.profile .right { display: flex; gap: 15px; }
.profile .right .icon { width: 24px; color: #d1d1d1; }

/* --- ALINHAMENTO DE MENSAGENS E AVATAR --- */
.chat-l, .chat-r { max-width: 75%; opacity: 0; transform: translateY(20px); transition: opacity 0.4s ease-out, transform 0.4s ease-out; display: flex; align-items: flex-end; }
.chat-l.visible, .chat-r.visible { opacity: 1; transform: translateY(0); }
.chat-r { align-self: flex-end; }
.chat-l { align-self: flex-start; }
.message-avatar-wrapper { width: 38px; flex-shrink: 0; }
.message-avatar { width: 30px; height: 30px; border-radius: 50%; opacity: 0; transition: opacity 0.3s; }
.chat-l[data-with-avatar="true"] .message-avatar { opacity: 1; }

/* --- ESTILO DOS BALÕES E HORÁRIO --- */
.mess { padding: 8px 12px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,0.1); position: relative; padding-bottom: 20px; }
.mess p { font-size: 15px; line-height: 1.5; word-wrap: break-word; }
.check { position: absolute; bottom: 5px; right: 10px; line-height: 1; }
.check span { font-size: 11px; color: rgba(0,0,0,0.45); }
.check svg { width: 18px; height: 18px; color: #53bdeb; margin-left: 3px; vertical-align: middle; }
.chat-l .mess { background-color: #FFFFFF; }
.chat-r .mess { background-color: #dcf8c6; color: #303030; }
.chat-r .check span { color: rgba(0,0,0,0.45); }

/* --- MENSAGENS DE SISTEMA --- */
.system-message-container { align-self: center; margin: 8px 0; opacity: 1; transform: none; }
.system-message-container.sticky { position: sticky; top: 10px; z-index: 10; }
.system-message { background-color: #E1F3FB; padding: 6px 12px; border-radius: 8px; font-size: 13px; color: #505050; box-shadow: 0 1px 1px rgba(0,0,0,0.05); }

/* --- INDICADOR DE DIGITANDO (NÃO UTILIZADO, POIS A LÓGICA AGORA ESTÁ NO CABEÇALHO) --- */
.typing-indicator { display: none; }

/* --- ÁREA DE INPUT E BOTÕES --- */
.chat-input-area { align-self: stretch; padding: 10px 0; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.chat-input-area.grid-layout { justify-content: center; }
.option-button { background-color: #005c4b; color: white; border: none; border-radius: 20px; padding: 10px 18px; font-size: 15px; cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.15); transition: background-color 0.2s; }
.option-button:hover { background-color: #004c3f; }
.link-button { text-decoration: none; display: inline-block; }
.user-input { flex-grow: 1; border: 1px solid #ccc; background-color: white; border-radius: 20px; padding: 12px 18px; font-size: 16px; outline: none; }
.send-button { background-color: #005c4b; color: white; border: none; border-radius: 50%; width: 48px; height: 48px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 4px rgba(0,0,0,0.15); flex-shrink: 0; }
.send-button:hover { background-color: #004c3f; }

/* --- SELEÇÃO DE CARTAS --- */
.card-option { width: calc(25% - 10px); border-radius: 8px; border: 3px solid transparent; cursor: pointer; transition: transform 0.2s, border-color 0.2s; }
.card-option:hover { transform: scale(1.05); }
.card-option.selected { border-color: #005c4b; transform: scale(1.05); }

/* --- ESTILOS DE MÍDIA (CORREÇÃO FINAL) --- */
.video-message, .image-message { padding: 0 !important; overflow: hidden; border-radius: 8px; }

.audio-message {
    padding: 8px !important;
    padding-bottom: 20px !important;
    width: 300px;
    max-width: 100%; /* Adicionado para responsividade */
}

.audio-message audio {
    width: 100%;
    height: 40px;
    display: block;
}

/* --- ALTERAÇÃO AQUI --- */
/* Esta nova regra torna o iframe do YouTube responsivo */
.video-message iframe {
    width: 100%; /* Ocupa 100% da largura do balão da mensagem */
    aspect-ratio: 16 / 9; /* Mantém a proporção 16:9 (widescreen) */
    display: block;
    border: none;
}

.image-message img { max-width: 100%; display: block; }

/* --- SCROLLBAR --- */
*::-webkit-scrollbar { width: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }

/* --- MEDIA QUERIES PARA RESPONSIVIDADE --- */
@media (max-width: 850px) { 
    .container { width: 100%; height: 100%; } 
    .chat-l, .chat-r { max-width: 85%; } 
    .card-option { width: calc(33% - 10px); } 
}