/* ========================================
   CORTEX S-3 CHAT INTERFACE
   ======================================== */

/* Botão CORTEX S-3 com Imagem */
.cortex-chat-trigger {
    position: relative;
    width: 280px;
    height: 280px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Borda eletrificada - Arco elétrico fino */
.cortex-chat-trigger::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    box-shadow:
        0 0 2px rgba(180, 165, 91, 0.8),
        0 0 4px rgba(139, 138, 92, 0.6),
        0 0 6px rgba(180, 165, 91, 0.4),
        inset 0 0 2px rgba(180, 165, 91, 0.5);
    animation: electricSpark 2s ease-in-out infinite;
    opacity: 0.8;
    z-index: -1;
}

/* Faíscas elétricas secundárias */
.cortex-chat-trigger::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background:
        conic-gradient(
            from 0deg,
            transparent 0deg,
            rgba(180, 165, 91, 0.6) 20deg,
            transparent 40deg,
            transparent 160deg,
            rgba(139, 138, 92, 0.5) 180deg,
            transparent 200deg,
            transparent 320deg,
            rgba(180, 165, 91, 0.7) 340deg,
            transparent 360deg
        );
    animation: electricRotate 3s linear infinite;
    opacity: 0.7;
    z-index: -2;
    filter: blur(1px);
}

.cortex-chat-trigger img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 12px 35px rgba(139, 138, 92, 0.4));
    transition: all 0.4s ease;
    position: relative;
    z-index: 1;
}

.cortex-chat-trigger:hover {
    transform: scale(1.08);
}

.cortex-chat-trigger:hover::before {
    box-shadow:
        0 0 3px rgba(180, 165, 91, 1),
        0 0 6px rgba(139, 138, 92, 0.8),
        0 0 9px rgba(180, 165, 91, 0.6),
        inset 0 0 3px rgba(180, 165, 91, 0.7);
    animation: electricSparkIntense 1.5s ease-in-out infinite;
}

.cortex-chat-trigger:hover::after {
    opacity: 1;
    filter: blur(0.5px);
}

.cortex-chat-trigger:hover img {
    filter: drop-shadow(0 18px 50px rgba(139, 138, 92, 0.6));
}

.cortex-chat-trigger:active {
    transform: scale(0.95);
}

/* Animação de pulso elétrico */
@keyframes electricSpark {
    0%, 100% {
        box-shadow:
            0 0 2px rgba(180, 165, 91, 0.8),
            0 0 4px rgba(139, 138, 92, 0.6),
            0 0 6px rgba(180, 165, 91, 0.4),
            inset 0 0 2px rgba(180, 165, 91, 0.5);
    }
    50% {
        box-shadow:
            0 0 3px rgba(180, 165, 91, 1),
            0 0 6px rgba(139, 138, 92, 0.8),
            0 0 9px rgba(180, 165, 91, 0.6),
            inset 0 0 3px rgba(180, 165, 91, 0.7);
    }
}

/* Animação intensa no hover */
@keyframes electricSparkIntense {
    0%, 100% {
        box-shadow:
            0 0 3px rgba(180, 165, 91, 1),
            0 0 6px rgba(139, 138, 92, 0.8),
            0 0 9px rgba(180, 165, 91, 0.6),
            inset 0 0 3px rgba(180, 165, 91, 0.7);
    }
    50% {
        box-shadow:
            0 0 4px rgba(180, 165, 91, 1),
            0 0 8px rgba(139, 138, 92, 1),
            0 0 12px rgba(180, 165, 91, 0.8),
            inset 0 0 4px rgba(180, 165, 91, 0.9);
    }
}

/* Rotação das faíscas */
@keyframes electricRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Overlay de fundo */
.cortex-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cortex-chat-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Container do Chat - Centralizado */
.cortex-chat-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 550px;
    height: 700px;
    background: var(--bg-primary);
    border: 2px solid var(--accent-gold);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(139, 138, 92, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cortex-chat-container.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: all;
}

/* Header do Chat - Cores Oliva */
.cortex-chat-header {
    padding: 24px;
    background: linear-gradient(135deg, #8b8a5c 0%, #6a7258 100%);
    border-radius: 17px 17px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--accent-gold);
    box-shadow: 0 4px 12px rgba(139, 138, 92, 0.2);
}

.cortex-chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cortex-chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(196, 184, 150, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--accent-gold);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cortex-chat-avatar svg {
    width: 24px;
    height: 24px;
    color: var(--accent-gold);
}

.cortex-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.cortex-chat-title {
    display: flex;
    flex-direction: column;
}

.cortex-chat-title h3 {
    font-size: 18px;
    font-weight: 700;
    color: #FFFFFF;
    margin: 0;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cortex-chat-title span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.cortex-chat-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cortex-chat-close:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.cortex-chat-close svg {
    width: 20px;
    height: 20px;
    color: #FFFFFF;
}

/* Área de Mensagens */
.cortex-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-secondary);
}

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

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

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

.cortex-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}

/* Mensagem */
.chat-message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

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

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

.chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}

.chat-message.assistant .chat-message-avatar {
    background: linear-gradient(135deg, #8b8a5c 0%, #6a7258 100%);
    color: var(--bg-primary);
    font-weight: 700;
}

.chat-message.user .chat-message-avatar {
    background: var(--accent-gold);
    color: var(--bg-primary);
    font-weight: 700;
}

.chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.assistant .chat-message-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-message.user .chat-message-content {
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}

.chat-message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
}

/* Indicador de digitando */
.chat-typing-indicator {
    display: flex;
    gap: 12px;
    padding: 12px 0;
}

.chat-typing-indicator .chat-message-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #8b8a5c 0%, #6a7258 100%);
    color: var(--bg-primary);
}

.typing-dots {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-gold);
    animation: typingBounce 1.4s infinite;
}

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

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

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

/* Input Area */
.cortex-chat-input-area {
    padding: 16px 20px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 14px 14px;
}

.cortex-chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.cortex-chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: all 0.2s ease;
}

.cortex-chat-input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(196, 184, 150, 0.1);
}

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

.cortex-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gold);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(139, 138, 92, 0.3);
}

.cortex-chat-send:hover:not(:disabled) {
    background: var(--military-green-light);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(139, 138, 92, 0.4);
}

.cortex-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cortex-chat-send svg {
    width: 20px;
    height: 20px;
    color: var(--bg-primary);
}

/* Suggestions */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chat-suggestion-chip {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-suggestion-chip:hover {
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-color: var(--accent-gold);
}

/* Action Buttons em Mensagens */
.chat-action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chat-action-btn {
    padding: 10px 16px;
    background: var(--accent-gold);
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(139, 138, 92, 0.2);
}

.chat-action-btn:hover {
    background: var(--military-green-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 138, 92, 0.3);
}

.chat-action-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.chat-action-btn.secondary:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* Welcome Screen */
.cortex-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.cortex-welcome-icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cortex-welcome-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(139, 138, 92, 0.3));
}

.cortex-welcome-icon svg {
    width: 40px;
    height: 40px;
    color: var(--accent-gold);
}

.cortex-welcome h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.cortex-welcome p {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Markdown Formatting in Chat */
.chat-message-content strong {
    font-weight: 700;
    color: var(--accent-gold);
}

.chat-message-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.chat-message-content ul.chat-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.chat-message-content ul.chat-list li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 6px;
    line-height: 1.5;
}

.chat-message-content ul.chat-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent-gold);
    font-weight: bold;
}

/* User messages - different styling for markdown */
.chat-message.user .chat-message-content strong {
    color: var(--bg-primary);
    font-weight: 700;
}

.chat-message.user .chat-message-content ul.chat-list li::before {
    color: var(--bg-primary);
}

/* Typing Cursor Animation (ChatGPT style) */
.typing-cursor {
    display: inline-block;
    color: var(--accent-gold);
    animation: cursorBlink 0.8s ease-in-out infinite;
    font-weight: 400;
    margin-left: 2px;
}

@keyframes cursorBlink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Message text container */
.chat-message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Action container spacing */
.chat-action-container:not(:empty) {
    margin-top: 12px;
}

/* Responsivo */
@media (max-width: 768px) {
    .cortex-chat-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 150px);
        right: 16px;
        bottom: 100px;
    }

    .cortex-chat-trigger {
        bottom: 20px;
        right: 20px;
        width: 100px;
        height: 100px;
    }

    .cortex-chat-trigger img {
        width: 100%;
        height: 100%;
    }
}
