/* Chat Widget Modal - Estilos para o widget de chat no e-commerce */

.chat-widget-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: none;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    animation: slideUp 0.3s ease-out;
}

.chat-widget-container.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header do Chat Widget */
.chat-widget-header {
    background: #166e8c;
    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);
}

.chat-widget-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-widget-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-widget-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

.chat-widget-status-dot.offline {
    background: #6b7280;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chat-widget-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}


.chat-widget-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    line-height: 1;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Área de Mensagens */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.chat-widget-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.chat-widget-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chat-widget-welcome h4 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #374151;
}

.chat-widget-welcome p {
    font-size: 14px;
    line-height: 1.5;
}

/* Mensagens */
.chat-widget-message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-widget-message.sent {
    justify-content: flex-end;
}

.chat-widget-message.received {
    justify-content: flex-start;
}

.chat-widget-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.chat-widget-message.sent .chat-widget-message-bubble {
    background: #166e8c;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-widget-message.received .chat-widget-message-bubble {
    background: #ffffff;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.chat-widget-message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
}

.chat-widget-message-status {
    font-size: 11px;
    margin-left: 4px;
    opacity: 0.7;
}

/* Indicador de digitação */
.chat-widget-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: #6b7280;
    font-size: 13px;
    font-style: italic;
}

.chat-widget-typing-dots {
    display: flex;
    gap: 4px;
}

.chat-widget-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.chat-widget-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-widget-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Indicador de gravação */
.chat-widget-recording-indicator {
    padding: 12px 16px;
    background: #fee2e2;
    border-top: 1px solid #fecaca;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #dc2626;
    font-size: 14px;
}

.chat-widget-recording-dot {
    width: 12px;
    height: 12px;
    background: #dc2626;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Área de Input */
.chat-widget-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    position: relative;
}

/* Menu de opções */
.chat-widget-menu-container {
    position: relative !important;
    flex-shrink: 0 !important;
    z-index: 1 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
}

.chat-widget-menu-btn {
    background: #f3f4f6 !important;
    border: none !important;
    color: #6b7280 !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
    font-size: 20px !important;
    font-weight: 300 !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.chat-widget-menu-btn svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    stroke: currentColor !important;
}

.chat-widget-menu-btn:hover {
    background: #e5e7eb !important;
    color: #166e8c !important;
    transform: rotate(45deg) !important;
}

.chat-widget-menu-btn:active {
    transform: rotate(45deg) scale(0.95) !important;
}

.chat-widget-menu-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    padding: 8px;
    display: none;
    flex-direction: column;
    z-index: 10001;
    border: 1px solid #e5e7eb;
}

.chat-widget-menu-dropdown.active {
    display: flex;
}

.chat-widget-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.chat-widget-menu-item:hover {
    background: #f3f4f6;
    color: #166e8c;
}

.chat-widget-menu-item svg {
    flex-shrink: 0;
    color: #6b7280;
}

.chat-widget-menu-item:hover svg {
    color: #166e8c;
}

/* Emoji Picker */
.chat-widget-emoji-picker {
    position: fixed;
    bottom: 80px;
    left: auto;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    margin-bottom: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    display: none;
    flex-direction: column;
    z-index: 10002 !important;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    visibility: visible;
    opacity: 1;
}

.chat-widget-emoji-picker[style*="flex"],
.chat-widget-emoji-picker[style*="block"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-widget-emoji-categories {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
}

.chat-widget-emoji-category-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-widget-emoji-category-btn:hover {
    background: #f3f4f6;
}

.chat-widget-emoji-category-btn.active {
    background: #166e8c;
}

.chat-widget-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 8px;
    overflow-y: auto;
    max-height: 250px;
}

.chat-widget-emoji-item {
    background: transparent;
    border: none;
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-emoji-item:hover {
    background: #f3f4f6;
    transform: scale(1.2);
}

.chat-widget-input-container {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 8px 12px;
}

.chat-widget-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: #374151;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    font-family: inherit;
    outline: none;
}

.chat-widget-input::placeholder {
    color: #9ca3af;
}

.chat-widget-mic-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-widget-mic-btn:hover {
    background: rgba(22, 110, 140, 0.1);
    color: #166e8c;
}

.chat-widget-mic-btn:active {
    background: rgba(22, 110, 140, 0.2);
    transform: scale(0.95);
}

.chat-widget-send-btn {
    background: linear-gradient(135deg, #166e8c 0%, #1a8aaa 100%);
    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;
    flex-shrink: 0;
}

.chat-widget-send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(22, 110, 140, 0.4);
}

.chat-widget-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-widget-send-btn svg,
.chat-widget-mic-btn svg {
    width: 18px;
    height: 18px;
}

/* Badge de notificação no botão flutuante */
.chat-float.has-notification::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

/* Responsivo */
@media (max-width: 768px) {
    .chat-widget-container {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chat-widget-header {
        border-radius: 0;
    }
}

/* Loading state */
.chat-widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.chat-widget-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #166e8c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Arquivos */
.chat-widget-file-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f3f4f6;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.chat-widget-file-message:hover {
    background: #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chat-widget-message.sent .chat-widget-file-message {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.35);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.chat-widget-message.sent .chat-widget-file-message:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-widget-file-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #166e8c 0%, #1a8aaa 100%);
    color: white;
    border-radius: 12px;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(22, 110, 140, 0.25);
    transition: all 0.2s ease;
}

.chat-widget-file-message:hover .chat-widget-file-icon {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(22, 110, 140, 0.35);
}

.chat-widget-message.sent .chat-widget-file-icon {
    background: rgba(255, 255, 255, 0.35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-widget-file-info {
    flex: 1;
    min-width: 0;
}

.chat-widget-file-name {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.chat-widget-message.sent .chat-widget-file-name {
    color: white;
}

.chat-widget-file-size {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.chat-widget-message.sent .chat-widget-file-size {
    color: rgba(255, 255, 255, 0.85);
}

.chat-widget-file-download {
    color: #166e8c;
    text-decoration: none;
    font-size: 20px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    width: 36px;
    height: 36px;
}

.chat-widget-file-download:hover {
    background: rgba(22, 110, 140, 0.1);
    transform: scale(1.1) rotate(-5deg);
}

.chat-widget-message.sent .chat-widget-file-download {
    color: white;
}

.chat-widget-message.sent .chat-widget-file-download:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Áudio - Design Melhorado */
.chat-widget-file-message audio {
    max-width: 100%;
    width: 100%;
    height: 48px;
    margin-top: 8px;
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
}

.chat-widget-file-message audio:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Estilização do player de áudio nativo */
.chat-widget-file-message audio::-webkit-media-controls-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 8px;
    padding: 4px;
}

.chat-widget-file-message audio::-webkit-media-controls-play-button {
    background-color: #166e8c;
    border-radius: 50%;
    margin-right: 8px;
}

.chat-widget-file-message audio::-webkit-media-controls-timeline {
    background-color: #e5e7eb;
    border-radius: 4px;
    height: 4px;
    margin: 0 8px;
}

.chat-widget-file-message audio::-webkit-media-controls-current-time-display,
.chat-widget-file-message audio::-webkit-media-controls-time-remaining-display {
    color: #374151;
    font-size: 12px;
    font-weight: 500;
}

.chat-widget-file-message audio::-webkit-media-controls-volume-slider {
    background-color: #166e8c;
    border-radius: 2px;
    height: 4px;
}

.chat-widget-file-message audio::-webkit-media-controls-mute-button {
    background-color: #6b7280;
    border-radius: 4px;
}

/* Para mensagens enviadas */
.chat-widget-message.sent .chat-widget-file-message audio::-webkit-media-controls-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
    backdrop-filter: blur(10px);
}

.chat-widget-message.sent .chat-widget-file-message audio::-webkit-media-controls-play-button {
    background-color: rgba(255, 255, 255, 0.9);
}

.chat-widget-message.sent .chat-widget-file-message audio::-webkit-media-controls-timeline {
    background-color: rgba(255, 255, 255, 0.3);
}

.chat-widget-message.sent .chat-widget-file-message audio::-webkit-media-controls-current-time-display,
.chat-widget-message.sent .chat-widget-file-message audio::-webkit-media-controls-time-remaining-display {
    color: rgba(255, 255, 255, 0.95);
}

.chat-widget-message.sent .chat-widget-file-message audio::-webkit-media-controls-volume-slider {
    background-color: rgba(255, 255, 255, 0.6);
}

/* Layout melhorado para áudios */
.chat-widget-file-message.audio-message {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px;
    gap: 10px;
    position: relative;
    min-width: 260px;
}

.chat-widget-file-message.audio-message > .chat-widget-file-icon {
    position: absolute;
    top: 14px;
    left: 14px;
    animation: audioIconPulse 2s ease-in-out infinite;
}

@keyframes audioIconPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(22, 110, 140, 0.25);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(22, 110, 140, 0.4);
    }
}

.chat-widget-file-message.audio-message > .chat-widget-file-info {
    margin-left: 58px;
    width: calc(100% - 58px);
}

.chat-widget-file-message.audio-message > audio {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
}

/* Melhorias visuais para o container de áudio */
.chat-widget-message-bubble.audio-message-bubble {
    padding: 14px 16px;
    max-width: 85%;
}

.chat-widget-message-bubble .chat-widget-file-message.audio-message {
    position: relative;
    width: 100%;
}

