/* --- Layout Independente (Aba) --- */
.alty-chat-main-layout {
    display: flex;
    height: 85vh;
    /* Ajuste para preencher a tela */
    background: #0a0f0d;
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    overflow: hidden;
}

.chat-sidebar-list {
    width: 320px;
    border-right: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    flex-direction: column;
    background: #0f1714;
}

.chat-sidebar-header {
    padding: 15px;
    background: rgba(16, 185, 129, 0.05);
    border-bottom: 1px solid rgba(16, 185, 129, 0.1);
}

.new-chat-input-group {
    display: flex;
    gap: 8px;
    background: #050807;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.new-chat-input-group input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 13px;
    padding: 5px;
    outline: none;
}

.new-chat-input-group button {
    background: none;
    border: none;
    color: #10b981;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.recent-chats-list {
    flex: 1;
    overflow-y: auto;
}

.recent-chat-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    gap: 12px;
    cursor: pointer;
    transition: 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.recent-chat-item:hover {
    background: rgba(16, 185, 129, 0.05);
}

.recent-chat-item.active {
    background: rgba(16, 185, 129, 0.15);
    border-left: 4px solid #10b981;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    background: #1e2925;
    color: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    /* Garante que a imagem fique redonda */
    border: 1px solid rgba(16, 185, 129, 0.2);
    flex-shrink: 0;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.chat-jid {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-jid {
    font-weight: bold;
    font-size: 14px;
    color: #f1f5f9;
}

.chat-date {
    font-size: 10px;
    color: #64748b;
}

.chat-snippet {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-main-window {
    flex: 1;
    background: #0a0f0d;
    display: flex;
    flex-direction: column;
}

/* --- Container do Chat (Modal ou Main) --- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* No modal, será fixo, na aba será 100% */
    background: #0a0f0d;
    overflow: hidden;
}

.modal-content .chat-container {
    height: 550px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-top: 15px;
}

.chat-header {
    padding: 12px 20px;
    background: #0f1714;
    border-bottom: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ecfdf5;
}

.chat-header-actions {
    display: flex;
    gap: 10px;
}

.btn-header-action {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: 0.2s;
}

.btn-header-action:hover {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px; /* Reduzido de 20px */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduzido de 12px */
    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;
    position: relative;
}

/* Camada para garantir que o wallpaper fique nítido */
.messages-list::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 20, 26, 0.6);
    /* Reduzido de 0.85 para 0.6 para clarear os desenhos */
    z-index: 0;
}

.msg-bubble {
    z-index: 1;
    /* Fica acima do overlay */
    max-width: 88%; /* Um pouco mais largo para ocupar espaço horizontal */
    padding: 5px 8px; /* Reduzido de 6px 10px */
    border-radius: 8px;
    font-size: 12.5px; /* Reduzido de 13px */
    position: relative;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.msg-in {
    align-self: flex-start;
    background: #202c33;
    /* Cor oficial de bolha recebida */
    color: #e9edef;
    border-bottom-left-radius: 2px;
}

.msg-out {
    align-self: flex-end;
    background: #005c4b;
    /* Verde oficial do WhatsApp modo escuro */
    color: #e9edef;
    border-bottom-right-radius: 2px;
}

.msg-time {
    font-size: 9px;
    opacity: 0.6;
    margin-top: 3px;
    text-align: right;
    display: block;
}

.chat-input-area {
    padding: 8px 12px; /* Reduzido de 15px 20px */
    background: #0f1714;
    border-top: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#chat-input-text {
    flex: 1;
    background: #050807;
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: white;
    padding: 6px 10px; /* Reduzido de 8px 12px */
    border-radius: 8px;
    outline: none;
    font-size: 13px;
    resize: none;
    font-family: inherit;
    line-height: 1.3;
    min-height: 35px; /* Reduzido de 40px */
    max-height: 100px;
    transition: 0.2s;
}

#chat-input-text:focus {
    border-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.btn-send {
    background: #10b981;
    color: white;
    padding: 6px;
    border-radius: 8px;
    width: 34px; /* Reduzido de 38px */
    height: 34px; /* Reduzido de 38px */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.2);
}

.btn-send:hover {
    background: #059669;
    transform: translateY(-2px);
}

.is-fullscreen {
    position: fixed;
    top: 50px;
    /* Ajuste para não cobrir o header se quiser, ou 0 para tela toda */
    left: 0;
    width: 100vw;
    height: calc(100vh - 50px);
    z-index: 9999;
    border-radius: 0 !important;
}

.template-tag {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #10b981;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.template-tag:hover {
    background: #10b981;
    color: white;
}

/* --- Botões de Ação Dinâmicos --- */
.btn-chat-action {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.2s;
    color: #94a3b8;
}

.btn-chat-action:hover {
    transform: scale(1.15);
    color: #10b981;
}

.btn-magic {
    color: #a855f7;
    font-size: 24px;
    filter: drop-shadow(0 0 5px rgba(168, 85, 247, 0.3));
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-magic:hover {
    color: #c084fc;
    transform: scale(1.2) rotate(15deg);
    filter: drop-shadow(0 0 15px rgba(168, 85, 247, 0.6));
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.8);
}

/* Animação de Faíscas quando a IA está trabalhando */
@keyframes wand-sparkle {
    0% {
        transform: scale(1) rotate(0);
        filter: brightness(1) drop-shadow(0 0 5px #a855f7);
    }

    25% {
        transform: scale(1.2) rotate(15deg);
        filter: brightness(1.5) drop-shadow(0 0 20px #a855f7);
    }

    50% {
        transform: scale(1) rotate(-15deg);
        filter: brightness(1.2) drop-shadow(0 0 10px #a855f7);
    }

    75% {
        transform: scale(1.2) rotate(10deg);
        filter: brightness(1.5) drop-shadow(0 0 20px #a855f7);
    }

    100% {
        transform: scale(1) rotate(0);
        filter: brightness(1) drop-shadow(0 0 5px #a855f7);
    }
}

.is-polishing {
    animation: wand-sparkle 0.8s infinite;
    cursor: wait;
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Animação Polishing (IA) */
@keyframes spark {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.is-polishing {
    animation: spark 1s infinite;
    pointer-events: none;
}