/* ========================================
   MODAL DE SUPORTE FLUTUANTE (CHAT WIDGET)
   ======================================== */

.support-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999 !important; /* Z-index máximo */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Botão Flutuante */
.chat-toggle-btn {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer !important;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto !important;
    z-index: 1000000 !important;
}

.chat-toggle-btn *,
.chat-toggle-btn i,
.chat-toggle-btn .notification-badge,
.chat-toggle-btn > * {
    pointer-events: none !important;
}

.chat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

.chat-toggle-btn .notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    animation: pulse 2s infinite;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

/* Janela do Chat */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsivo: Mobile */
@media (max-width: 640px) {
    .chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

/* Responsivo: Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .chat-window {
        width: 400px;
        height: 650px;
    }
}

/* Regras para modo expandido movidas para baixo - ver linha ~240 */

[data-theme="dark"] .chat-window {
    background: #1f1f1f;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.chat-window.active {
    display: flex !important;
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
    visibility: visible !important;
}

/* Header do Chat */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.chat-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.status-online {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.status-online::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

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

.chat-menu-btn,
.chat-expand-btn,
.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
}

.chat-menu-btn:hover,
.chat-expand-btn:hover,
.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

.chat-menu-btn:active,
.chat-expand-btn:active,
.chat-close-btn:active {
    transform: scale(0.92);
}

/* ========================================
   MODO EXPANDIDO - VERSÃO FINAL LIMPA
   ======================================== */

.chat-window.expanded {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    transform: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 10000 !important;
}

/* Ícone do botão de expandir vira "sair de tela cheia" */
.chat-window.expanded .chat-expand-btn i::before {
    content: "\eb3d"; /* bx-exit-fullscreen */
}

/* Body ocupa toda a tela sem padding */
.chat-window.expanded .chat-body {
    flex: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Menu e Conversa devem ocupar 100% da largura */
.chat-window.expanded .chat-menu,
.chat-window.expanded .chat-conversation {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

/* Header da conversa com padding mínimo */
.chat-window.expanded .conversation-header {
    flex: 0 0 auto !important;
    padding: 16px 20px 12px 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Área de mensagens - SELETOR MAIS ESPECÍFICO */
.support-chat-widget .chat-window.expanded .chat-messages {
    flex: 1 1 auto !important;
    padding: 20px !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    margin: 0 !important;
}

/* Footer com padding mínimo */
.chat-window.expanded .chat-footer {
    flex: 0 0 auto !important;
    padding: 16px 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Menu com padding lateral */
.chat-window.expanded .chat-menu {
    padding: 20px !important;
    overflow-y: auto !important;
}

/* Body do Chat */
.chat-body {
    flex: 1;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    padding: 24px;
}

.chat-window.expanded .chat-body {
    padding: 0 !important; /* No padding on the body itself when expanded */
    margin: 0 !important;
}

@media (max-width: 480px) {
    .chat-body {
        padding: 18px;
    }
}

[data-theme="dark"] .chat-body {
    background: linear-gradient(135deg, #1a1a1a 0%, #141414 100%);
}

.chat-menu,
.chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    height: 100%;
}

.chat-menu {
    gap: 20px;
    padding: 0;
    padding-right: 8px;
    padding-bottom: 8px;
    overflow-y: auto;
}

.chat-conversation {
    gap: 0;
    padding: 0;
    overflow: hidden;
    position: relative;
}

@media (max-width: 480px) {
    .chat-menu {
        gap: 16px;
    }
}

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

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

.chat-menu::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.chat-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

[data-theme="dark"] .chat-menu::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.3);
}

[data-theme="dark"] .chat-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.5);
}

.chat-conversation {
    display: none;
}

.chat-body.show-menu .chat-menu {
    display: flex !important;
}

.chat-body.show-menu .chat-conversation {
    display: none !important;
}

.chat-body.show-conversation .chat-menu {
    display: none !important;
}

.chat-body.show-conversation .chat-conversation {
    display: flex !important;
}

.chat-menu-header {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 16px;
    padding: 18px 20px;
    margin: 0 20px 16px 20px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

@media (max-width: 768px) {
    .chat-menu-header {
        gap: 12px;
        padding: 14px 16px;
    }
}

@media (max-width: 480px) {
    .chat-menu-header {
        gap: 10px;
        padding: 12px 14px;
    }
}

[data-theme="dark"] .chat-menu-header {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.1) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(167, 139, 250, 0.2);
}

.menu-icon-circle {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    box-shadow: 0 8px 20px rgba(118, 75, 162, 0.25);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .menu-icon-circle {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .menu-icon-circle {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}

.chat-menu-header h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    color: #1f2937;
    font-weight: 700;
}

@media (max-width: 768px) {
    .chat-menu-header h3 {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .chat-menu-header h3 {
        font-size: 14px;
    }
}

.chat-menu-header p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .chat-menu-header p {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .chat-menu-header p {
        font-size: 11px;
    }
}

[data-theme="dark"] .chat-menu-header h3 {
    color: #f3f4f6;
}

[data-theme="dark"] .chat-menu-header p {
    color: #9ca3af;
}

/* Botões estilo Cida - Pills com cores IA Fundo */
.chat-menu-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 20px 20px 20px;
    margin-top: -8px;
}

.menu-option-btn {
    background: white;
    border: 1.5px solid #667eea;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 14px;
    color: #1f2937;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 500;
    width: 100%;
}

.menu-option-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: #764ba2;
    transform: translateX(4px);
}

.menu-option-btn:active {
    transform: scale(0.98);
}

@media (max-width: 480px) {
    .menu-option-btn {
        font-size: 13px;
        padding: 10px 16px;
    }
}

[data-theme="dark"] .menu-option-btn {
    background: #1a1a1a;
    border-color: #2a2a2a;
    color: #e5e7eb;
}

[data-theme="dark"] .menu-option-btn:hover {
    background: #2a2a2a;
    color: #f3f4f6;
}

[data-theme="dark"] .menu-description {
    color: #9ca3af;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 20px 12px 20px;
    width: 100%;
    flex-shrink: 0;
    border-bottom: 1px solid #e5e7eb;
}

@media (max-width: 480px) {
    .conversation-header {
        gap: 8px;
        padding: 12px 16px 10px 16px;
    }
}

.chat-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #4f46e5;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .chat-back-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

.chat-back-btn:hover {
    background: rgba(79, 70, 229, 0.08);
    border-color: #4f46e5;
}

[data-theme="dark"] .chat-back-btn {
    background: #111827;
    border-color: #1f2937;
    color: #c7d2fe;
}

[data-theme="dark"] .chat-back-btn:hover {
    background: rgba(99, 102, 241, 0.14);
    border-color: #6366f1;
}

.conversation-hint {
    font-size: 12px;
    color: #6b7280;
    margin-left: auto;
    text-align: right;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .conversation-hint {
        font-size: 11px;
        flex-basis: 100%;
        margin-left: 0;
        text-align: left;
    }
}

[data-theme="dark"] .conversation-hint {
    color: #9ca3af;
}

/* Mensagens do Chat - ESPECÍFICO DO WIDGET DE SUPORTE */
.support-chat-widget .chat-messages {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px !important;
    padding-bottom: 30px !important;
    min-height: 0 !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    scroll-behavior: smooth !important;
    scrollbar-gutter: stable !important;
}

@media (max-width: 768px) {
    .support-chat-widget .chat-messages {
        gap: 14px !important;
        padding: 16px !important;
    }
}

@media (max-width: 480px) {
    .support-chat-widget .chat-messages {
        gap: 12px !important;
        padding: 14px !important;
    }
}

.support-chat-widget .chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.support-chat-widget .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
}

.support-chat-widget .chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Scrollbar no modo expandido */
.chat-window.expanded .chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.chat-window.expanded .chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.2);
    border-radius: 10px;
}

.chat-window.expanded .chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.4);
}

.chat-messages:empty::before {
    content: 'Selecione uma das opções do menu ou digite sua pergunta.';
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
    padding-top: 32px;
    margin: auto;
    align-self: center;
}

[data-theme="dark"] .chat-messages:empty::before {
    color: #6b7280;
}

.support-chat-widget .chat-message {
    display: flex !important;
    gap: 10px !important;
    animation: messageSlide 0.3s ease-out !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.user .message-avatar {
    background: #10b981;
}

.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .message-content {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .message-content {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 12px;
    }
}

[data-theme="dark"] .message-content {
    background: #1a1a1a;
    border-color: #333;
    color: #e5e5e5;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.message-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    max-width: fit-content;
}

[data-theme="dark"] .message-loading {
    background: #1a1a1a;
    border-color: #333;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typingAnimation 1.4s infinite;
}

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

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

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

/* Footer do Chat */
.chat-footer {
    padding: 14px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .chat-footer {
        padding: 12px 14px;
    }
}

[data-theme="dark"] .chat-footer {
    background: #1f1f1f;
    border-color: #2a2a2a;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
}

.chat-input-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

@media (max-width: 480px) {
    .chat-input-form {
        gap: 8px;
    }
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    background: #f9fafb;
    color: #374151;
    transition: all 0.3s ease;
    min-width: 0;
    font-family: inherit;
}

@media (max-width: 480px) {
    .chat-input {
        padding: 10px 14px;
        font-size: 13px;
    }
}

[data-theme="dark"] .chat-input {
    background: #0a0a0a;
    border-color: #2a2a2a;
    color: #e5e5e5;
}

.chat-input:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .chat-input:focus {
    background: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

@media (max-width: 480px) {
    .chat-send-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: scale(0.9);
}

.chat-footer-info {
    text-align: center;
    margin-top: 10px;
}

.chat-footer-info small {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
}

@media (max-width: 480px) {
    .chat-footer-info small {
        font-size: 10px;
    }
}

[data-theme="dark"] .chat-footer-info small {
    color: #6b7280;
}

/* Responsividade */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 20px;
    }

    .support-chat-widget {
        bottom: 15px;
        right: 15px;
    }
}
