* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #ffffff;
    color: var(--color-text);
    overflow-x: hidden;
    /* Alinhado dinamicamente com a altura real do .top-header via
       js/header-height.js (--header-height). Não precisa mais medir
       e travar um valor fixo em pixel aqui. */
    padding-top: var(--header-height, 84px);
    min-height: 100vh;
}

/* ===== Top Purple Header ===== */
/* Estilos compartilhados em css/header-shared.css — aqui só ajustes específicos */
.logo-icon img {
    height: 42px;
}

/* ===== Back Button == */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 0.75rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    animation: slideInRight 0.6s ease;
}

.back-button:hover {
    background-color: white;
    color: var(--color-primary);
    transform: translateX(-5px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

.back-button svg {
    transition: transform 0.3s ease;
}

.back-button:hover svg {
    transform: translateX(-3px);
}

.container {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ===== Animated Background ===== */
/* ===== Animated Background ===== */
.background-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.triangle-1 {
    top: 0;
    left: 0;
    border-width: 200px 200px 0 0;
    border-color: var(--color-primary) transparent transparent transparent;
}

.triangle-2 {
    top: 0;
    right: 0;
    border-width: 0 200px 200px 0;
    border-color: transparent var(--color-primary) transparent transparent;
}

.triangle-3 {
    bottom: 0;
    left: 0;
    border-width: 200px 0 0 200px;
    border-color: transparent transparent transparent var(--color-primary);
    transform: translateY(-130px);
}

.triangle-4 {
    bottom: 0;
    right: 0;
    border-width: 0 0 200px 200px;
    border-color: transparent transparent var(--color-primary) transparent;
    transform: translateY(-130px);
}

.triangle-5 {
    top: 30%;
    left: 0;
    border-width: 100px 100px 0 0;
    border-color: var(--color-primary-light) transparent transparent transparent;
}

.triangle-6 {
    bottom: 30%;
    right: 0;
    border-width: 0 0 100px 100px;
    border-color: transparent transparent var(--color-primary-light) transparent;
}

/* ===== Main Content ===== */
.main-content {
    position: relative;
    z-index: 10;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ===== Header ===== */
.page-header {
    text-align: center;
    padding-top: 3rem;
    padding-bottom: 1.5rem;
}

.subtitle {
    font-size: 1.4rem;
    color: #4b5563;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    animation: logo-appear 0.5s ease-out;
}

@keyframes logo-appear {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.logo {
    width: 128px;
    height: 128px;
    object-fit: contain;
}

.title {
    font-size: 1.875rem;
    font-weight: bold;
    color: var(--color-text);
}

/* ===== Content Area ===== */
.content-area {
    flex: 1;
    max-width: 64rem;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem;
    padding-bottom: 10rem;
}

/* ===== Prompts Grid ===== */
.prompts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.prompt-card {
    background-color: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: justify;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: prompt-appear 0.4s ease-out forwards;
    opacity: 0;
    display: flex;
    align-items: start;
    transform: translateY(20px);
}

.prompt-card div p {
    font-size: 19px;
}

.prompt-card:nth-child(1) { animation-delay: 0s; }
.prompt-card:nth-child(2) { animation-delay: 0.1s; }
.prompt-card:nth-child(3) { animation-delay: 0.2s; }
.prompt-card:nth-child(4) { animation-delay: 0.3s; }

@keyframes prompt-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.prompt-card:hover {
    background-color: #f3f4f6;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: scale(1.02);
}

.prompt-card:active {
    transform: scale(0.98);
}

.prompt-content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.prompt-icon {
    width: 32px;
    height: 32px;
    background-color: var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    color: white;
}

.prompt-card:hover .prompt-icon {
    transform: scale(1.1);
}

.prompt-content p {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #374151;
}

.prompts-grid.hidden {
    display: none;
}

/* ===== Messages Container ===== */
.messages-container {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}

.messages-container.visible {
    display: flex;
}

.message {
    display: flex;
    animation: message-appear 0.3s ease-out;
}

@keyframes message-appear {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.ai {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    border-radius: 1rem;
    padding: 1rem 1.5rem;
}

.message.user .message-bubble {
    background-color: var(--color-primary);
    color: white;
}

.message.ai .message-bubble {
    background-color: #f3f4f6;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.message-text {
    font-size: 0.875rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message.ai .message-time {
    color: var(--color-text-muted);
}

/* ===== Input Area ===== */
.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    border-top: 1px solid var(--color-border);
    padding: 1.5rem;
    z-index: 20;
}

.input-wrapper {
    max-width: 64rem;
    margin: 0 auto;
}

.input-label {
    font-size: 0.875rem;
    color: #4b5563;
    margin-bottom: 0.75rem;
}

.input-controls {
    display: flex;
    gap: 0.75rem;
}

.message-input {
    flex: 1;
    background-color: var(--color-surface-soft);
    color: var(--color-text);
    border: 1px solid #d1d5db;
    border-radius: var(--radius-pill);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.message-input::placeholder {
    color: #9ca3af;
}

.message-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(106, 62, 167, 0.1);
}

.send-button {
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.send-button:hover:not(:disabled) {
    background-color: #5a2e97;
    transform: scale(1.05);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .prompts-grid {
        grid-template-columns: 1fr;
    }

    .header {
        padding-top: 2rem;
    }

    .title {
        font-size: 1.5rem;
    }

    .logo {
        width: 96px;
        height: 96px;
    }

    .content-area {
        padding-bottom: 12rem;
    }

    .message-bubble {
        max-width: 90%;
    }
}

/* No celular, o header desta página tem 3 botões (Histórico,
   Voltar, tema) além do logo — texto demais pra caber em ~390px.
   Abaixo de 480px, os botões viram só ícone (mantendo aria-label
   para leitores de tela), evitando o header estourar a tela. */
@media (max-width: 480px) {
    .history-button,
    .back-button {
        padding: 0.65rem;
        gap: 0;
    }

    .history-button span,
    .back-button span {
        display: none;
    }

    .logo-text {
        font-size: 1.05rem;
    }
}

.prompt-card.selected {
    border: 2px solid var(--color-primary);
    background-color: #ede9fe;
}

#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    padding-bottom: 7px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* quando aparecer */
#backToTop.show {
    opacity: 1;
    pointer-events: auto;
}

/* hover */
#backToTop:hover {
    transform: scale(1.1);
}

/* ===== Loading container (bolha da IA) ===== */
.message.ai.loading .message-bubble {
    background: linear-gradient(270deg, var(--color-primary), #8b5cf6, var(--color-primary));
    background-size: 400% 400%;
    animation: gradientFlow 3s ease infinite;
    color: white;
}

/* animação do gradiente */
@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== Texto fixo ===== */
.loading-text {
    display: inline-block;
}

/* ===== Pontinhos separados (não cresce o fundo) ===== */
.loading-dots {
    display: inline-block;
    width: 20px; /* espaço fixo pros pontos */
    text-align: left;
}

/* animação dos pontos */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
    0%   { content: ''; }
    33%  { content: '.'; }
    66%  { content: '..'; }
    100% { content: '...'; }
}

.loading-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px; /* espaço entre texto e pontinhos */
}

/* texto */
.loading-text {
    display: inline-block;
}

/* pontinhos */
.loading-dots {
    display: inline-block;
    width: 24px; /* espaço fixo pra evitar mexer o layout */
}

/* ===== History Sidebar ===== */
.history-sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100vh;
    background-color: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-sidebar.open {
    left: 0;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background-color: var(--color-surface-soft);
}

.history-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.close-sidebar-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-sidebar-btn:hover {
    background-color: var(--color-border);
    color: var(--color-text);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    margin: 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    background-color: #5a2e97;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(106, 62, 167, 0.3);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
}

.history-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    gap: 0.75rem;
}

.history-item:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

.history-item.active {
    background-color: #ede9fe;
    border-color: var(--color-primary);
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.history-item-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.delete-history-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.delete-history-btn:hover {
    background-color: var(--color-danger-dark)42;
    color: var(--color-danger-dark);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.history-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 0.75rem 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-pill);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    animation: slideInRight 0.6s ease;
}

.history-button:hover {
    background-color: white;
    color: var(--color-primary);
    transform: translateX(-5px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

.history-button:active {
    transform: translateY(0);
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.back-button-container a button, .back-button-container button {
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-button-container a {
    text-decoration: none;
}