@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: #130b29; /* Fundo Base */
    background-image: radial-gradient(circle at 50% 0%, #2d1f57 0%, #130b29 60%);
    color: #fff;
    height: 100vh;

    /* 🔧 CORREÇÃO 1 → permitir scroll no mobile */
    overflow-x: hidden;
    overflow-y: auto;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
}

/* --- CABEÇALHO --- */
header {
    text-align: center;
    flex-shrink: 0;
    margin-bottom: 15px;
    z-index: 10;
    animation: slideDown 0.5s ease-out;
}

header h1 {
    font-size: 2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #a855f7;
    text-shadow: 0 0 25px rgba(168, 85, 247, 0.5);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    color: #cbd5e1;
    margin-top: 5px;
    font-weight: 400;
}

#clear-history-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #9ca3af;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}
#clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: #f87171;
    transform: translateY(-1px);
}

/* --- CONTAINER DO CHAT (EFEITO VIDRO) --- */
.chat-container {
    width: 90%;
    max-width: 950px;

    /* 🔧 CORREÇÃO 2 → usar dvh para evitar corte no iPhone */
    height: calc(100dvh - 180px);

    background-color: rgba(26, 16, 60, 0.75); 
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    animation: zoomIn 0.4s ease-out;
}

/* --- ÁREA DE MENSAGENS --- */
#chat-output {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbar Moderna */
#chat-output::-webkit-scrollbar { width: 8px; }
#chat-output::-webkit-scrollbar-track { background: transparent; }
#chat-output::-webkit-scrollbar-thumb { 
    background: #3f306b; 
    border-radius: 10px; 
    border: 2px solid rgba(26, 16, 60, 0.5);
}
#chat-output::-webkit-scrollbar-thumb:hover { background: #5b4696; }

/* --- BOLHAS DE MENSAGEM --- */
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlide 0.3s ease-out;
}

.bot-message { align-self: flex-start; }
.user-message { align-self: flex-end; }

.message-bubble {
    padding: 16px 22px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.bot-message .message-bubble {
    background-color: #262042;
    color: #e2e8f0;
    border-top-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #6d28d9, #7c3aed);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.bot-message.welcome-container .message-bubble {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none;
    width: 100%;
    max-width: 100%;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.2s;
    padding: 5px;
    border-radius: 6px;
}
.message-bubble:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background-color: rgba(255,255,255,0.1); color: #fff; transform: scale(1.1); }

.bot-message ul { list-style: none; padding: 0; margin-top: 15px; }
.bot-message li {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bot-message b, .bot-message strong { 
    color: #fff; 
    font-size: 1.05rem; 
    font-weight: 700; 
}

.spec-explanation {
    display: block;
    color: #cbd5e1;
    font-size: 0.95rem;
    line-height: 1.5;
    padding-left: 2px;
}
.spec-explanation b { color: #fbbf24 !important; font-weight: 700; margin-right: 5px; }

.spec-total {
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.4);
    color: #fff;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-weight: bold;
    margin: 25px 0 10px 0;
    font-size: 1.1rem;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.1);
}

.bot-message h3 {
    color: #e9d5ff;
    margin: 25px 0 12px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 8px;
}

.bot-message a {
    color: #a855f7;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px dashed rgba(168, 85, 247, 0.5);
    transition: all 0.2s;
}
.bot-message a:hover { 
    color: #d8b4fe; 
    background-color: rgba(168, 85, 247, 0.1);
    border-radius: 4px;
    padding: 0 4px;
    border-bottom-style: solid; 
}

/* --- CARDS DE BOAS VINDAS --- */
.welcome-options { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 10px; }
.option-card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.option-card:hover {
    background-color: rgba(124, 58, 237, 0.15);
    border-color: #7c3aed;
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.option-badge {
    background: linear-gradient(135deg, #6d28d9, #8b5cf6);
    color: #fff;
    min-width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.option-text { font-size: 0.95rem; color: #e2e8f0; line-height: 1.4; }
.option-text strong { color: #fff; font-weight: 600; }

/* --- ÁREA DE INPUT --- */
.input-area {
    padding: 25px;
    background-color: rgba(19, 11, 41, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 15px;
}

#chat-input {
    flex: 1;
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 15px 20px;
    border-radius: 12px;
    outline: none;
    font-size: 1rem;
    transition: all 0.3s;
}
#chat-input:focus {
    border-color: #a855f7;
    background-color: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}
#chat-input::placeholder { color: #64748b; }

#enviar-btn {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    border: none;
    padding: 0 35px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
#enviar-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(124, 58, 237, 0.3);
}
#enviar-btn:active { transform: translateY(0); }
#enviar-btn:disabled { background: #475569; cursor: not-allowed; }

/* --- RODAPÉ --- */
footer {
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
    flex-shrink: 0;
    margin-top: 5px;
}
footer a { color: #64748b; text-decoration: none; margin: 0 8px; transition: color 0.2s; }
footer a:hover { color: #a855f7; }

.typing-cursor { display: inline-block; width: 8px; height: 8px; background-color: #a855f7; border-radius: 50%; margin-left: 5px; animation: pulse 1s infinite; }
.brain-icon { display: inline-block; font-size: 1.3rem; margin-right: 8px; vertical-align: middle; animation: brainPulse 1.5s infinite alternate ease-in-out; }

@keyframes pulse { 0%, 100% { opacity: 0.5; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes brainPulse { 0% { filter: drop-shadow(0 0 2px rgba(168,85,247,0.4)); transform: scale(1); } 100% { filter: drop-shadow(0 0 8px rgba(168,85,247,0.8)); transform: scale(1.1); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
@keyframes messageSlide { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }

.message-time { display: none !important; }

/* --- RESPONSIVIDADE (MOBILE) --- */
@media (max-width: 768px) {
    .chat-container {
        width: 95%;

        /* Usa dvh também no mobile */
        height: calc(100dvh - 160px);

        border-radius: 15px;
    }

    header h1 { font-size: 1.5rem; }
    .subtitle { font-size: 0.85rem; padding: 0 10px; }

    #chat-output { padding: 15px; }

    .message-bubble {
        padding: 12px 16px;
        font-size: 0.9rem;
        max-width: 92%;
    }

    .input-area {
        padding: 15px;
        gap: 8px;
    }

    #chat-input {
        font-size: 16px;
        padding: 12px;
    }

    #enviar-btn {
        padding: 0 20px;
        font-size: 0.9rem;
    }

    .option-card { padding: 10px 14px; }
    .option-text { font-size: 0.85rem; }
}

/* 🔧 CORREÇÃO 3 → Responsividade para telas muito pequenas */
@media (max-width: 360px) {
    header h1 { font-size: 1.3rem; }
    .logo-img { width: 32px; height: 32px; }

    .message-bubble {
        font-size: 0.85rem;
        padding: 10px 14px;
    }

    #enviar-btn {
        padding: 0 14px;
        font-size: 0.8rem;
    }
}
