/* static/css/style.css */
body {
    font-family: sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    display: flex; /* Mantém para o auth-container centralizado */
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* Evita scroll no body quando o app está visível */
}

.hidden { display: none !important; }

/* --- Estilos de Autenticação --- */
#auth-container {
    background-color: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.form-container {
    display: flex;
    gap: 40px;
    margin-top: 20px;
}

#auth-container form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-container input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#auth-container button {
    padding: 10px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.error-message {
    color: #dc3545;
    margin-top: 15px;
    height: 20px;
}


/* --- Container Principal da Aplicação --- */
#app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    background-color: #fff;
}

#app-container.sidebar-closed #sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-width: 0;
    overflow: hidden;
}

/* --- Navbar --- */
#navbar {
    background-color: #007bff;
    color: white;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    flex-shrink: 0;
}
#navbar-title {
    font-size: 1.5rem;
    font-weight: bold;
}
#menu-toggle-button, #logout-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 10px;
}
#menu-toggle-button:hover, #logout-button:hover {
    background-color: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* --- Layout com Sidebar --- */
#app-container > div:not(#navbar) {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

/* --- Sidebar --- */
#sidebar {
    width: 280px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    padding: 15px;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease-in-out, padding 0.3s ease-in-out;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
}
.sidebar-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    text-align: left;
    width: 100%;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 15px;
    font-size: 1rem;
}
.sidebar-button:hover {
    background-color: #0056b3;
}
#chat-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
}
#chat-list li {
    padding: 12px 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 5px;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#chat-list li:hover {
    background-color: #e9ecef;
}
#chat-list li.active-chat {
    background-color: #007bff;
    color: white;
    font-weight: bold;
}

/* --- Conteúdo Principal do Chat --- */
#chat-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    overflow: hidden;
    transition: margin-left 0.3s ease-in-out;
}
#chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.chat-window {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
}
.message {
    margin-bottom: 15px;
    display: flex;
}

.message p {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 70%;
    margin: 0;
    word-wrap: break-word;
}

.message.user {
    justify-content: flex-end;
}

.message.user p {
    background-color: #007bff;
    color: white;
}

.message.bot {
    justify-content: flex-start;
}

.message.bot p {
    background-color: #e9e9eb;
    color: #333;
}

.message.bot p .think-segment {
    display: block;
    margin: 6px 0 0 0;
    padding: 8px 10px;
    border-radius: 12px;
    background-color: #f3f4f6;
    color: #4a4a4a;
    font-style: italic;
}

.message.typing-indicator p {
    background-color: #e9e9eb;
    color: #333;
    display: inline-block;
}

.typing-indicator span {
    animation-name: blink;
    animation-duration: 1.4s;
    animation-iteration-count: infinite;
    animation-fill-mode: both;
    font-size: 1.2em;
}

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

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

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* --- Container do Input e Preferências --- */
#chat-input-container {
    display: flex;
    flex-direction: column;
    border-top: 1px solid #ddd;
    background-color: #f8f9fa;
}

.chat-form {
    display: flex;
    padding: 15px;
    align-items: center; /* Alinha o botão de toggle verticalmente */
}
#message-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 1rem;
    margin-left: 10px; /* Espaço após o botão de toggle */
}

#message-input:focus {
    outline: none;
    border-color: #007bff;
}
.chat-form button[type="submit"] {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    margin-left: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0; /* Impede que o botão encolha */
}

.chat-form button[type="submit"]:hover {
    background-color: #0056b3;
}

/* --- Estilos para o botão de toggle de preferências --- */
.prefs-toggle-btn {
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0; /* Impede que o botão encolha */
}

.prefs-toggle-btn.active, .prefs-toggle-btn:hover {
    background-color: #d1d5db;
}

.prefs-toggle-btn i {
    transition: transform 0.3s ease-in-out;
}

.prefs-toggle-btn.active i {
    transform: rotate(180deg);
}


/* --- Estilos da Área de Preferências --- */
#chat-preferences-area {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 15px;
    border-top: 1px solid #e0e0e0;
    gap: 20px;
    flex-wrap: wrap;
    overflow: hidden; /* Essencial para a animação de colapso */
    transition: max-height 0.35s ease-in-out, padding 0.35s ease-in-out, border-width 0.35s ease-in-out;
    max-height: 200px; /* Altura suficiente para o conteúdo */
}

#chat-preferences-area.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-width: 0;
}


.preference-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #555;
}

.preference-item label {
    font-weight: 500;
}

.preference-item select {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
}

/* Estilo para o Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-track {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider-track:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider-track {
    background-color: #2196F3;
}

input:focus + .slider-track {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider-track:before {
    transform: translateX(20px);
}

/* Estilo para o Slider de Detalhamento */
.slider-container {
    flex-direction: column;
    gap: 4px;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-wrapper span {
    font-size: 0.8rem;
    color: #6c757d;
}

input[type=range] {
    -webkit-appearance: none;
    width: 150px;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #d3d3d3;
    border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    border: 1px solid #007bff;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    margin-top: -5px; /* Centraliza o thumb no track */
}

/* --- Outros Estilos --- */
.centered-message {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #6c757d;
    font-size: 1.2rem;
}

.notification-area {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 2000;
    width: 300px;
}
.notification {
    background-color: #f8d7da; /* Error default */
    color: #721c24;
    padding: 12px 18px;
    margin-bottom: 10px;
    border-radius: 5px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateX(110%);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 0.9rem;
}
.notification.show {
    opacity: 1;
    transform: translateX(0);
}
.notification.success {
    background-color: #d1e7dd;
    color: #0f5132;
    border-left: 5px solid #198754;
}
.notification.error {
    background-color: #f8d7da;
    color: #842029;
    border-left: 5px solid #dc3545;
}
.notification.info {
    background-color: #cff4fc;
    color: #055160;
    border-left: 5px solid #0dcaf0;
}

/* Botões de respostas do questionário */
.question-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 12px; /* Menor padding */
    border-radius: 5px;
    cursor: pointer;
    margin: 4px;
    font-size: 0.95rem;
    width: auto; /* Não ocupa toda a largura */
    min-width: 120px; /* Largura mínima */
    display: inline-block;
}

.question-button:hover {
    background-color: #0056b3;
}

/* --- NOVOS ESTILOS PARA EXIBIÇÃO DE RESULTADOS --- */

/* Container principal dos resultados */
.results-container {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.results-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #007bff;
}

.results-header h2 {
    color: #007bff;
    margin: 0 0 10px 0;
    font-size: 1.8rem;
}

.results-header .success-message {
    color: #28a745;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Seção do perfil do cliente */
.client-profile-section {
    background-color: white;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 25px;
    border-left: 4px solid #17a2b8;
}

.client-profile-section h3 {
    color: #17a2b8;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.profile-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #17a2b8;
}

.profile-item strong {
    color: #495057;
    min-width: 80px;
}

.needs-summary {
    margin-top: 15px;
}

.needs-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.needs-list li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
    color: #495057;
}

.needs-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
}

/* Seção de produtos recomendados */
.products-section {
    background-color: white;
    border-radius: 6px;
    padding: 20px;
    border-left: 4px solid #28a745;
}

.products-section h3 {
    color: #28a745;
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.product-card h4 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.product-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-features li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
    color: #495057;
    font-size: 0.9rem;
}

.product-features li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #007bff;
    font-weight: bold;
}

/* Mensagem quando não há produtos */
.no-products-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 1.1rem;
    background-color: white;
    border-radius: 6px;
    border: 2px dashed #dee2e6;
}

.no-products-message i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #adb5bd;
}

/* Botão de recomeçar */
.restart-button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 25px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    transition: background-color 0.2s ease;
}

.restart-button:hover {
    background-color: #5a6268;
}

/* Indicador de carregamento */
.loading-indicator {
    text-align: center;
    padding: 40px 20px;
    color: #007bff;
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade */
@media (max-width: 768px) {
    .profile-info {
        grid-template-columns: 1fr;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .results-container {
        padding: 15px;
        margin-top: 15px;
    }
    
    .client-profile-section,
    .products-section {
        padding: 15px;
    }
}

/* Estilo para dados JSON brutos (fallback) */
.api-result {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* Badges para categorias */
.category-badge {
    display: inline-block;
    padding: 4px 8px;
    background-color: #007bff;
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 8px;
}

.family-badge {
    display: inline-block;
    padding: 4px 8px;
    background-color: #17a2b8;
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 8px;
}