/**
 * Chat GPT Style - CSS
 * Tema dark inspirado no ChatGPT
 */

/* Variáveis CSS */
.chat-gpt-style-container {
    --primary-color: #10a37f;
    --primary-hover: #0d8f6b;
    --bg-primary: #212121;
    --bg-secondary: #2f2f2f;
    --bg-tertiary: #3c3c3c;
    --bg-quaternary: #4a4a4a;
    --bg-input: #40414f;
    --bg-user: var(--primary-color);
    --bg-bot: #444654;
    --border-color: #565869;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --text-muted: #8e8ea0;
    --text-user: #ffffff;
    --text-bot: #ececf1;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2), 0 4px 6px rgba(0, 0, 0, 0.15);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Container Principal */
.chat-gpt-style-container {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-family: var(--font-family);
    color: var(--text-primary);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: relative;
    /* Adicionado para garantir que o container principal seja responsivo */
    max-width: 100%;
    box-sizing: border-box;
}

/* Header do Chat */
.chat-gpt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    min-height: 64px;
}

.chat-gpt-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-gpt-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.chat-gpt-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-gpt-status {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 500;
}

.chat-gpt-header-actions {
    display: flex;
    gap: 8px;
}

.chat-gpt-action-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.chat-gpt-action-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Área de Mensagens */
.chat-gpt-messages {
    /* flex: 1; */ /* Removido para permitir que o conteúdo inicial defina a altura mínima */
    flex-grow: 1; /* Adicionado para permitir que ocupe o espaço restante quando houver mais conteúdo */
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    background: var(--bg-primary);
}

.chat-gpt-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-gpt-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

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

/* Seção de Boas-vindas */
.chat-gpt-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    max-width: 600px;
    margin: auto; /* Alterado de '0 auto' para 'auto' para centralização vertical e horizontal */
}

.chat-gpt-welcome-avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.chat-gpt-welcome-content h4 {
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-gpt-welcome-content p {
    margin: 0;
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Mensagens */
.chat-gpt-message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.chat-gpt-message.user {
    flex-direction: row-reverse;
}

.chat-gpt-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.chat-gpt-message.bot .chat-gpt-message-avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
}

.chat-gpt-message.user .chat-gpt-message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-gpt-message-content {
    flex: 1;
    min-width: 0;
}

.chat-gpt-message-bubble {
    background: var(--bg-bot);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    color: var(--text-bot);
    border: 1px solid var(--border-color);
}

.chat-gpt-message.user .chat-gpt-message-bubble {
    background: var(--bg-user);
    color: var(--text-user);
    border-color: var(--primary-color);
}

.chat-gpt-message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

.chat-gpt-message.user .chat-gpt-message-time {
    text-align: left;
}

/* Imagens nas mensagens */
.chat-gpt-message-image {
    /* Alterações para preenchimento de 100% e manutenção de proporção */
    width: 100%;
    height: 100%;
    object-fit: contain; /* Garante que a imagem caiba no contêiner sem ser cortada, mantendo a proporção */
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
    margin-top: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.chat-gpt-message-image:hover {
    /* Removido o transform: scale(1.02) para evitar problemas de layout ao usar 100% */
    box-shadow: var(--shadow-md);
}

/* Indicador de Digitação */
.chat-gpt-typing {
    padding: 0 20px 20px;
}

.chat-gpt-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-bot);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    width: fit-content;
}

.chat-gpt-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.chat-gpt-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.chat-gpt-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.chat-gpt-typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Área de Input */
.chat-gpt-input-area {
    padding: 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.chat-gpt-input-container {
    max-width: 100%;
}

/* Preview de Arquivo */
.chat-gpt-file-preview {
    margin-bottom: 12px;
}

.chat-gpt-file-item {
    position: relative;
    display: inline-block;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 8px;
    border: 1px solid var(--border-color);
}

.chat-gpt-file-image {
    max-width: 120px;
    max-height: 120px;
    border-radius: var(--radius-sm);
    display: block;
}

.chat-gpt-file-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border: 2px solid var(--bg-secondary);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.chat-gpt-file-remove:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Wrapper do Input */
.chat-gpt-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    transition: var(--transition);
}

.chat-gpt-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.chat-gpt-file-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-gpt-file-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.chat-gpt-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-family);
    resize: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
    padding: 6px 0;
}

.chat-gpt-input::placeholder {
    color: var(--text-muted);
}

.chat-gpt-send-btn {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-gpt-send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.chat-gpt-send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Footer do Input */
.chat-gpt-input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.chat-gpt-char-count {
    font-weight: 500;
}

.chat-gpt-powered {
    opacity: 0.7;
}

/* Estados de Erro */
.chat-gpt-style-login-required,
.chat-gpt-style-permission-denied {
    padding: 20px;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 14px;
}

/* Responsividade */
@media (max-width: 768px) {
    .chat-calculator-wrapper {
        flex-direction: column; /* Empilhamento em mobile */
    }

    .chat-panel {
        width: 100%;
        height: auto;
    }

    .calculators-panel {
        width: 100%;
        height: auto;
    }

    .chat-gpt-header {
        padding: 12px 16px;
    }

    .chat-gpt-header-info h3 {
        font-size: 15px;
    }

    .chat-gpt-messages {
        padding: 15px;
    }

    .chat-gpt-message {
        margin-bottom: 20px;
    }

    .chat-gpt-message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chat-gpt-input-area {
        padding: 15px;
    }

    .chat-gpt-input-wrapper {
        padding: 8px;
    }

    .chat-gpt-input {
        font-size: 15px;
    }
}

/* Estilos para a calculadora (se houver) */
.calculators-panel {
    /* ... estilos da calculadora ... */
}

.chat-calculator-wrapper {
    /* ... estilos do wrapper ... */
}

/* Estilos para o modal de imagem */
.chat-gpt-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-gpt-image-modal.active {
    opacity: 1;
    visibility: visible;
}

.chat-gpt-image-modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.chat-gpt-image-modal-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
}

.chat-gpt-image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.chat-gpt-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.4);
}
