/* ========================================
   VARIÁVEIS E RESET
======================================== */
:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a8a;
    --primary-dark: #0f2440;
    --accent: #e67e22;
    --accent-hover: #d35400;
    --success: #27ae60;
    --bg-main: #f0f4f8;
    --bg-chat: #ffffff;
    --bg-bot: #e8eef4;
    --bg-user: #1e3a5f;
    --text-primary: #1a1a2e;
    --text-secondary: #5a6978;
    --text-light: #8896a6;
    --text-white: #ffffff;
    --border: #d1dce6;
    --shadow-sm: 0 2px 8px rgba(30, 58, 95, 0.08);
    --shadow-md: 0 4px 20px rgba(30, 58, 95, 0.12);
    --shadow-lg: 0 8px 40px rgba(30, 58, 95, 0.16);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   CONTAINER PRINCIPAL
======================================== */
.chat-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    box-shadow: var(--shadow-lg);
}

@media (min-width: 840px) {
    .chat-container {
        margin: 20px auto;
        min-height: calc(100vh - 40px);
        border-radius: var(--radius-lg);
        overflow: hidden;
    }
}

/* ========================================
   HEADER
======================================== */
.chat-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: 20px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.logo-icon svg {
    color: var(--accent);
}

.logo-text h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo-text .subtitle {
    font-size: 0.85rem;
    opacity: 0.8;
    font-weight: 400;
}

.progress-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 16px;
    border-radius: var(--radius-full);
}

.progress-text {
    font-size: 0.8rem;
    font-weight: 500;
    opacity: 0.9;
    white-space: nowrap;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    overflow: hidden;
    min-width: 100px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #f39c12 100%);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.5s ease;
}

.progress-percent {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* ========================================
   ÁREA DE MENSAGENS
======================================== */
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-main);
}

/* ========================================
   BALÕES DE MENSAGEM
======================================== */
.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: messageSlide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent) 0%, #f39c12 100%);
    color: white;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    position: relative;
}

.message.bot .message-bubble {
    background: var(--bg-chat);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-white);
    border-bottom-right-radius: 4px;
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.7;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content .emoji {
    font-size: 1.2em;
}

/* ========================================
   INDICADOR DE DIGITAÇÃO
======================================== */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* ========================================
   ÁREA DE INPUT
======================================== */
.chat-input-area {
    background: var(--bg-chat);
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Botões de opção */
.options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

.option-btn {
    padding: 12px 24px;
    border: 2px solid var(--border);
    background: var(--bg-chat);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--bg-bot);
    transform: translateY(-2px);
}

.option-btn:active {
    transform: translateY(0);
}

.option-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--text-white);
}

.option-btn.primary {
    background: linear-gradient(135deg, var(--accent) 0%, #f39c12 100%);
    border-color: transparent;
    color: var(--text-white);
    font-weight: 600;
    padding: 14px 32px;
}

.option-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Checkbox options */
.checkbox-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-main);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.checkbox-option:hover {
    background: var(--bg-bot);
    border-color: var(--primary-light);
}

.checkbox-option.selected {
    background: rgba(30, 58, 95, 0.1);
    border-color: var(--primary);
}

.checkbox-option input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkbox-option.selected .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-custom svg {
    width: 14px;
    height: 14px;
    color: white;
    opacity: 0;
    transition: var(--transition);
}

.checkbox-option.selected .checkbox-custom svg {
    opacity: 1;
}

.checkbox-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* Campo de texto */
.text-input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.text-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.text-input {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-main);
    transition: var(--transition);
    resize: none;
    min-height: 56px;
    max-height: 150px;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-chat);
    box-shadow: 0 0 0 4px rgba(30, 58, 95, 0.1);
}

.text-input::placeholder {
    color: var(--text-light);
}

.send-btn {
    width: 56px;
    height: 56px;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

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

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-btn svg {
    width: 24px;
    height: 24px;
}

/* Exemplo/Dica */
.input-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-bot);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent);
}

.input-hint strong {
    color: var(--primary);
}

/* Continue button container */
.continue-container {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}

.continue-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.continue-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========================================
   TELA FINAL
======================================== */
.final-screen {
    text-align: center;
    padding: 40px 20px;
}

.final-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--success) 0%, #2ecc71 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes successPop {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.final-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.final-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.final-message {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ========================================
   RESUMO DAS RESPOSTAS
======================================== */
.summary-container {
    background: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 24px;
    text-align: left;
}

.summary-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-question {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.summary-answer {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ========================================
   RESPONSIVIDADE
======================================== */
@media (max-width: 600px) {
    .chat-header {
        padding: 16px;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .logo-text h1 {
        font-size: 1rem;
    }

    .progress-indicator {
        padding: 8px 12px;
    }

    .progress-text {
        display: none;
    }

    .chat-messages {
        padding: 16px;
    }

    .message {
        max-width: 90%;
    }

    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .message-bubble {
        padding: 14px 16px;
    }

    .chat-input-area {
        padding: 16px;
    }

    .option-btn {
        padding: 10px 18px;
        font-size: 0.85rem;
    }

    .text-input {
        padding: 14px 16px;
    }

    .send-btn {
        width: 50px;
        height: 50px;
    }
}

/* ========================================
   SCROLLBAR PERSONALIZADA
======================================== */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ========================================
   ANIMAÇÕES DE ENTRADA
======================================== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   ESTADOS DE LOADING
======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
