/* ═══════════════════════════════════════════════
   CHAT - ReusFlix
   ═══════════════════════════════════════════════ */

.chat-modal-overlay {
    background: #0d1117;
    align-items: stretch; /* Garantir que preencha a altura */
    justify-content: center;
    z-index: 2500;
}

.chat-container {
    width: 100%;
    max-width: 700px;
    height: 100%; /* Respeita a altura do fixed do modal, evitando transbordar pro rodapé no Android */
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0d1117;
    position: relative;
    margin: 0 auto;
}

/* ── Header ─────────────────────────────────── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: #161b22;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar-group {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e50914, #b20710);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.chat-title {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.chat-subtitle {
    font-size: 0.75rem;
    color: #8b949e;
    margin-top: 1px;
}

/* ── Messages Area ──────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }

/* ── Empty State ────────────────────────────── */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 40px 20px;
    margin: auto;
}

.chat-empty i {
    font-size: 3.5rem;
    opacity: 0.2;
    color: #8b949e;
}

.chat-empty p {
    font-size: 1.05rem;
    font-weight: 600;
    color: #8b949e;
    margin: 0;
}

.chat-empty span {
    font-size: 0.82rem;
    color: #484f58;
}

/* ── Date Separator ─────────────────────────── */
.chat-date-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0 6px;
}

.chat-date-sep span {
    background: #21262d;
    color: #8b949e;
    font-size: 0.72rem;
    padding: 3px 12px;
    border-radius: 20px;
    font-weight: 500;
}

/* ── Message Bubbles ────────────────────────── */
.chat-msg {
    display: flex;
    margin-bottom: 2px;
}

.chat-msg.own  { justify-content: flex-end; }
.chat-msg.other { justify-content: flex-start; }

.chat-bubble {
    max-width: 78%;
    border-radius: 18px;
    padding: 9px 13px;
    word-break: break-word;
    position: relative;
    line-height: 1.45;
}

.chat-msg.own .chat-bubble {
    background: linear-gradient(135deg, #c0392b, #e50914);
    border-bottom-right-radius: 4px;
    color: #fff;
}

.chat-msg.other .chat-bubble {
    background: #21262d;
    border-bottom-left-radius: 4px;
    color: #e6edf3;
}

.chat-sender {
    font-size: 0.72rem;
    font-weight: 700;
    color: #e50914;
    margin-bottom: 3px;
}

.chat-msg.own .chat-sender {
    color: rgba(255,255,255,0.7);
}

.chat-text {
    font-size: 0.92rem;
}

.chat-time {
    font-size: 0.68rem;
    opacity: 0.6;
    text-align: right;
    margin-top: 4px;
}

/* Image inside bubble */
.chat-img {
    max-width: 220px;
    max-height: 260px;
    width: 100%;
    border-radius: 10px;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    margin-bottom: 4px;
}

/* ── Emoji Picker ───────────────────────────── */
.emoji-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 10px 8px;
    background: #161b22;
    border-top: 1px solid rgba(255,255,255,0.07);
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

.emoji-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.15s;
    line-height: 1;
}

.emoji-btn:hover {
    background: rgba(255,255,255,0.08);
}

/* ── Input Bar ──────────────────────────────── */
.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); /* Aumentado um pouco para respiro */
    background: #161b22;
    border-top: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    position: sticky; /* Forçar ancoragem se necessário */
    bottom: 0;
}

.chat-tool-btn {
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.chat-tool-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.chat-textarea {
    flex: 1;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 20px;
    color: #e6edf3;
    font-size: 16px; /* Evita zoom automático no Safari iOS */
    font-family: inherit;
    padding: 10px 14px; /* Menor preenchimento horizontal, ajustado vertical */
    resize: none;
    outline: none;
    height: 44px; /* Altura inicial perfeitamente ajustada */
    min-height: 44px; /* Garante que o flex não esmague a caixa */
    max-height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    line-height: 22px; /* Espaço exato da linha considerando padding (10+10+22+2(borda) = 44px) */
    transition: border-color 0.2s;
}

.chat-textarea:focus { border-color: #e50914; }
.chat-textarea::placeholder { 
    color: #484f58;
    white-space: nowrap; /* Evita que o texto quebre e force o espaço */
    text-overflow: ellipsis; 
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c0392b, #e50914);
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 10px rgba(229, 9, 20, 0.4);
}

.chat-send-btn:active { transform: scale(0.92); }

/* ── Animation ──────────────────────────────── */
.chat-modal-overlay.active .chat-container {
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Desktop ────────────────────────────────── */
@media (min-width: 700px) {
    .chat-modal-overlay {
        justify-content: center;
        align-items: center; /* Centraliza no desktop */
        padding: 20px;
    }
    .chat-container {
        height: 90vh; /* Não precisa ser full screen no desktop */
        border-radius: 16px;
        border: 1px solid #21262d;
    }
}

/* ── Pequenas Telas ─────────────────────────── */
@media (max-width: 380px) {
    .chat-input-bar {
        gap: 4px;
        padding-top: 8px;
        padding-left: 10px;
        padding-right: 10px;
        /* mantém o padding-bottom definido na regra principal com env() */
    }
    .chat-tool-btn {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
}

/* ── Deletion Modal & Long Press ─────────────── */

.chat-delete-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 4000;
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-delete-modal-overlay.active {
    display: flex;
}

.delete-modal-card {
    background: #161b22;
    width: 100%;
    max-width: 340px;
    border-radius: 24px;
    padding: 30px 24px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.delete-modal-icon {
    width: 60px;
    height: 60px;
    background: rgba(229, 9, 20, 0.1);
    color: #e50914;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 18px;
}

.delete-modal-card h3 {
    margin-bottom: 12px;
    font-size: 1.3rem;
    color: #fff;
}

.delete-modal-card p {
    color: #8b949e;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 25px;
}

.delete-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.delete-modal-actions button {
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: transform 0.1s;
}

.delete-modal-actions button:active {
    transform: scale(0.97);
}

.btn-confirm-delete {
    background: #e50914;
    color: #fff;
}

.btn-cancel {
    background: #30363d;
    color: #fff;
}

/* ── Message Interaction ──────────── */
.chat-bubble {
    position: relative;
    transition: transform 0.2s, opacity 0.2s;
}

.chat-bubble.can-delete {
    cursor: pointer;
}

.chat-bubble.can-delete:active {
    transform: scale(0.98);
}
