:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-page: #0b1120;
    --bg-card: #1e293b;
    --bg-chat: #111827;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --bot-bubble: #2a3347;
    --border: rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Container Principal - Adaptado para Iframe */
.app-card {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-card);
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
header {
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 12px;
    overflow: hidden;
    /* Garante que a imagem siga o arredondamento */
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-info h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
}

.brand-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Área de Chat */
.chat-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.chat-container::-webkit-scrollbar {
    width: 5px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.message {
    max-width: 75%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: var(--bot-bubble);
    color: var(--text-main);
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
}

/* Fontes e Tags */
.sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.source-tag {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

/* Seletor de Tópicos */
.topic-selector-container {
    padding: 0 2rem;
    margin-bottom: 0.5rem;
}

.topic-selector {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-chat);
    padding: 0.3rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    width: fit-content;
}

.topic-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.topic-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.topic-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

/* Botões de boas-vindas */
.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.action-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    text-align: left;
}

.action-btn span {
    font-size: 1.2rem;
}

.action-btn:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
    transform: translateX(4px);
}

/* Barra de Input */
.input-area {
    padding: 0 2rem 1.5rem;
}

.file-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.input-bar {
    background: var(--bg-chat);
    border-radius: 16px;
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    gap: 1rem;
    border: 1px solid var(--border);
}

.attach-btn {
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.attach-btn:hover {
    color: white;
}

input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    font-size: 0.95rem;
    padding: 0.5rem 0;
}

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

/* Helpers */
.typing {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 2.5rem 1rem;
    display: none;
}

#authOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

/* Responsividade Mobile */
@media (max-width: 600px) {
    header {
        padding: 1rem 1.25rem;
    }

    .brand-icon {
        width: 40px;
        height: 40px;
    }

    .brand-info h1 {
        font-size: 1.1rem;
    }

    .chat-container {
        padding: 1.25rem;
        gap: 1rem;
    }

    .message {
        max-width: 85%;
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }

    .input-area {
        padding: 0 1rem 1rem;
    }

    .topic-selector-container {
        padding: 0 1rem;
        margin-bottom: 0.5rem;
    }

    .topic-selector {
        width: 100%;
        justify-content: space-around;
        padding: 0.2rem;
    }

    .topic-btn {
        padding: 0.4rem 0.5rem;
        flex: 1;
        text-align: center;
    }

    .input-bar {
        padding: 0.4rem 0.75rem;
        gap: 0.75rem;
        border-radius: 12px;
    }

    input {
        font-size: 16px; /* Evita zoom automático no iOS */
    }

    .send-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
}