/* ========================================
   AI CHAT WIDGET - OMNISBLUE
   ======================================== */

/* Container Principal */
.chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Poppins', sans-serif;
}

/* Botão Flutuante Toggle */
.chat-widget-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
    border: none;
    box-shadow: 0 4px 20px rgba(7, 42, 200, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    color: white;
    position: relative;
    overflow: hidden;
}

.chat-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(7, 42, 200, 0.5);
}

.chat-widget-toggle:active {
    transform: scale(0.95);
}

.chat-widget-toggle .chat-icon,
.chat-widget-toggle .close-icon {
    width: 28px;
    height: 28px;
    transition: all 0.3s ease;
    position: absolute;
}

.chat-widget-toggle .chat-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.chat-widget-toggle .close-icon {
    opacity: 0;
    transform: rotate(180deg) scale(0);
}

/* Estado do botão quando chat está aberto */
.chat-widget-container.active .chat-widget-toggle .chat-icon {
    opacity: 0;
    transform: rotate(-180deg) scale(0);
}

.chat-widget-container.active .chat-widget-toggle .close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Estado do botão quando chat está aberto */
.chat-widget-container.active .chat-widget-toggle {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

.chat-widget-container.active .chat-widget-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Janela do Chat */
.chat-widget-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow: hidden;
}

.chat-widget-container.active .chat-widget-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header do Chat */
.chat-widget-header {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
    padding: 8px;
    object-fit: contain;
}

.chat-header-text h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-close-btn svg {
    width: 20px;
    height: 20px;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Área de Mensagens */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--white-blue);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar customizada */
.chat-messages-area::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-area::-webkit-scrollbar-thumb {
    background: var(--blue);
    border-radius: 10px;
}

/* Mensagens */
.chat-message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    align-items: flex-end;
}

.assistant-message {
    align-self: flex-start;
    align-items: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
}

.user-message .message-content {
    background: var(--blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
    background: white;
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-content p {
    margin: 0 0 8px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    padding: 0 8px;
}

/* Preview de Áudio */
.audio-preview-container,
.file-preview-container {
    padding: 12px 20px;
    background: white;
    border-top: 1px solid var(--border);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.audio-preview-content,
.file-preview-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--muted);
    padding: 12px;
    border-radius: 12px;
}

.audio-icon,
.file-icon {
    width: 40px;
    height: 40px;
    color: var(--blue);
    flex-shrink: 0;
}

.audio-preview-info,
.file-preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.audio-preview-title,
.file-preview-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.file-preview-size {
    font-size: 12px;
    color: var(--muted-foreground);
    opacity: 0.7;
}

#audioPreviewPlayer {
    width: 100%;
    height: 32px;
    margin-top: 4px;
}

.audio-preview-cancel,
.file-preview-cancel {
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.audio-preview-cancel svg,
.file-preview-cancel svg {
    width: 20px;
    height: 20px;
}

.audio-preview-cancel:hover,
.file-preview-cancel:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #dc2626;
}

/* Área de Input */
.chat-input-area {
    border-top: 1px solid var(--border);
    background: white;
    padding: 16px 20px;
    border-radius: 0 0 20px 20px;
}

.chat-input-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Loading Indicator */
.chat-loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--muted);
    border-radius: 12px;
    font-size: 14px;
    color: var(--text);
    animation: slideUp 0.3s ease;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--blue-light);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Recording Indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
    color: white;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    animation: slideUp 0.3s ease;
}

.recording-pulse {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.stop-recording-btn {
    margin-left: auto;
    background: white;
    border: none;
    color: #DC2626;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.stop-recording-btn svg {
    width: 16px;
    height: 16px;
}

.stop-recording-btn:hover {
    transform: scale(1.1);
}

/* Input Container */
.chat-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.attach-btn-inside {
    position: absolute;
    left: 12px;
    background: transparent;
    border: none;
    color: var(--blue);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.attach-btn-inside svg {
    width: 20px;
    height: 20px;
}

.attach-btn-inside:hover {
    background: var(--muted);
    color: var(--blue-dark);
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: var(--blue);
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn svg {
    width: 22px;
    height: 22px;
}

.chat-action-btn:hover {
    background: var(--muted);
    color: var(--blue-dark);
}

.chat-action-btn:active {
    transform: scale(0.95);
}

/* Action Buttons Wrapper - Animação entre Audio e Send */
.action-buttons-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.audio-btn,
.send-btn {
    position: absolute;
    top: 0;
    right: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.audio-btn {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: all;
}

.send-btn {
    opacity: 0;
    transform: scale(0) rotate(180deg);
    pointer-events: none;
}

/* Quando há texto, inverter botões */
.chat-input-container.has-text .audio-btn {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    pointer-events: none;
}

.chat-input-container.has-text .send-btn {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: all;
}

.chat-input {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: 24px;
    padding: 12px 48px 12px 48px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--blue);
}

.chat-input::placeholder {
    color: var(--muted-foreground);
    opacity: 0.6;
}

.chat-send-btn {
    background: var(--blue);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(7, 42, 200, 0.3);
}

.chat-send-btn svg {
    width: 20px;
    height: 20px;
}

.chat-send-btn:hover {
    background: var(--blue-dark);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(7, 42, 200, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 16px;
        right: 16px;
    }

    .chat-widget-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 160px);
        max-height: 600px;
        bottom: 76px;
        right: -8px;
    }

    .chat-widget-toggle {
        width: 56px;
        height: 56px;
    }

    .chat-widget-toggle .chat-icon,
    .chat-widget-toggle .close-icon {
        width: 26px;
        height: 26px;
    }

    .chat-messages-area {
        padding: 16px;
    }

    .chat-message {
        max-width: 85%;
    }
}

/* Responsive - Tablet */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-widget-window {
        width: 360px;
        height: 550px;
    }
}