/* ==========================================================================
   CSS PRINCIPAL — ELIZA 2026
   Focado em criar um ambiente caloroso, seguro e esteticamente premium.
   ========================================================================== */

/* Definição de Variáveis e Transições Dinâmicas */
:root {
    /* Paleta de Cores Padrão (Calm - Serenidade) */
    --bg-gradient-start: #0e1118;
    --bg-gradient-end: #07090d;
    --orb-glow: rgba(99, 140, 255, 0.15);
    --panel-bg: rgba(255, 255, 255, 0.03);
    --panel-border: rgba(255, 255, 255, 0.06);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-color: #ffd8a8; /* Âmbar suave para aconchego */
    --accent-glow: rgba(255, 216, 168, 0.3);
    
    /* Cores das Mensagens */
    --msg-user-bg: rgba(255, 255, 255, 0.08);
    --msg-user-text: #ffffff;
    --msg-eliza-bg: rgba(255, 216, 168, 0.03);
    --msg-eliza-text: #ffd8a8;
}

/* Modificações Cromáticas baseadas no Humor Analisado */
body.theme-calm {
    --bg-gradient-start: #0c0f17;
    --bg-gradient-end: #06080c;
    --orb-glow: rgba(81, 126, 237, 0.18);
    --accent-color: #a5d8ff;
    --msg-eliza-text: #a5d8ff;
}

body.theme-joy {
    --bg-gradient-start: #1c150c;
    --bg-gradient-end: #0c0906;
    --orb-glow: rgba(250, 176, 5, 0.15);
    --accent-color: #ffe066;
    --msg-eliza-text: #ffe066;
}

body.theme-sadness {
    --bg-gradient-start: #110e1a;
    --bg-gradient-end: #08060c;
    --orb-glow: rgba(156, 136, 255, 0.18);
    --accent-color: #eebefa;
    --msg-eliza-text: #eebefa;
}

body.theme-anger {
    --bg-gradient-start: #170d0d;
    --bg-gradient-end: #0c0606;
    --orb-glow: rgba(255, 107, 107, 0.15);
    --accent-color: #ffc9c9;
    --msg-eliza-text: #ffc9c9;
}

body.theme-anxiety {
    --bg-gradient-start: #0d1611;
    --bg-gradient-end: #060b08;
    --orb-glow: rgba(80, 200, 120, 0.15);
    --accent-color: #c3fae8;
    --msg-eliza-text: #c3fae8;
}

/* Reset básico de Layout */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-gradient-end);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 2.5s ease;
}

/* Acessibilidade */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Atmosfera: Iluminação e Orbe de Respiração */
.ambient-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, var(--orb-glow) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
    transition: background 2.5s ease;
}

.breathing-orb {
    position: fixed;
    bottom: -150px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--orb-glow) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(40px);
    animation: breath 12s infinite ease-in-out;
    transition: background 2.5s ease;
}

@keyframes breath {
    0%, 100% {
        transform: translateX(-50%) scale(0.9);
        opacity: 0.7;
    }
    50% {
        transform: translateX(-50%) scale(1.1);
        opacity: 0.95;
    }
}

/* Contêiner da Aplicação Principal */
.app-container {
    width: 100%;
    max-width: 720px;
    height: 95vh;
    max-height: 850px;
    display: flex;
    flex-direction: column;
    z-index: 10;
    padding: 20px;
    transition: padding 0.3s ease;
}

/* Cabeçalho */
.app-header {
    text-align: center;
    margin-bottom: 24px;
}

.eliza-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2.8rem;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--accent-color);
    text-shadow: 0 0 20px var(--accent-glow);
    transition: color 2s ease, text-shadow 2s ease;
    margin-bottom: 6px;
}

.eliza-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.5px;
}

/* Área do Chat (Glassmorphism Premium) */
.chat-wrapper {
    flex: 1;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 20px;
    position: relative;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 30px 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Estilização da Scrollbar */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mensagens */
.message {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 1.02rem;
    line-height: 1.6;
    letter-spacing: 0.1px;
    word-wrap: break-word;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Alinhamento de Mensagens: Usuário vs ELIZA */
.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background-color: var(--msg-user-bg);
    color: var(--msg-user-text);
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.eliza-message {
    align-self: flex-start;
}

.eliza-message .message-content {
    background-color: var(--msg-eliza-bg);
    color: var(--msg-eliza-text);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 216, 168, 0.06);
    transition: color 2s ease, border-color 2s ease;
}

.initial-message {
    animation-delay: 0.2s;
}

/* Indicador de Digitação (Sintonizando) */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 16px 25px;
    align-self: flex-start;
    animation: fadeIn 0.3s ease forwards;
}

.typing-indicator.hidden {
    display: none !important;
}

.indicator-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
    opacity: 0.4;
    animation: dotPulse 1.4s infinite ease-in-out both;
    transition: background-color 2s ease;
}

.indicator-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.indicator-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.indicator-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: 6px;
    font-weight: 300;
    letter-spacing: 1px;
}

@keyframes dotPulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.3;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Contêiner da Entrada */
.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-form {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 8px 8px 20px;
    border-radius: 20px;
    align-items: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.chat-form:focus-within {
    border-color: rgba(255, 255, 255, 0.15);
    background-color: rgba(255, 255, 255, 0.04);
}

.user-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 300;
    line-height: 1.5;
}

.user-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.send-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    width: 46px;
    height: 46px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease, border-color 0.3s ease;
}

.send-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.96);
}

/* Indicador de Conexão */
.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.connection-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

.connection-dot.connected {
    background-color: #51cf66;
    box-shadow: 0 0 10px rgba(81, 207, 102, 0.5);
}

.connection-dot.disconnected {
    background-color: #ff6b6b;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.connection-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.5px;
}

/* Botão de Reset Conversacional */
.reset-button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-left: 8px;
    border-radius: 50%;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.reset-button:hover {
    opacity: 1;
    color: var(--accent-color);
    transform: rotate(30deg);
}

.reset-button:active {
    transform: scale(0.9) rotate(90deg);
}

/* Responsividade */
@media (max-width: 600px) {
    .app-container {
        height: 100vh;
        max-height: none;
        padding: 12px;
    }
    
    .eliza-title {
        font-size: 2.2rem;
        letter-spacing: 3px;
    }
    
    .chat-wrapper {
        border-radius: 18px;
    }
    
    .chat-history {
        padding: 20px 15px;
        gap: 15px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .message-content {
        padding: 12px 16px;
        font-size: 0.98rem;
    }
}
