/* WhatsApp Web - Variáveis CSS para Temas */
:root {
    /* Cores principais WhatsApp Web Dark (padrão) */
    --wa-bg-primary: #111b21;
    --wa-bg-secondary: #202c33;
    --wa-bg-tertiary: #2a3942;
    --wa-text-primary: #e9edef;
    --wa-text-secondary: #8696a0;
    --wa-text-tertiary: #667781;
    --wa-accent: #00a884;
    --wa-accent-hover: #06cf9c;
    --wa-user-bubble: #005c4b;
    --wa-bot-bubble: #202c33;
    --wa-border: #2a3942;
    --wa-error: #f15c6d;
    --wa-success: #00a884;
    
    /* Safe area insets para mobile */
    --safe-area-inset-top: env(safe-area-inset-top);
    --safe-area-inset-bottom: env(safe-area-inset-bottom);
    --safe-area-inset-left: env(safe-area-inset-left);
    --safe-area-inset-right: env(safe-area-inset-right);
    
    /* Variáveis de personalização */
    --font-size-multiplier: 1;
    --animation-speed: 1;
}

/* Tema Claro */
[data-theme="light"] {
    --wa-bg-primary: #f0f2f5;
    --wa-bg-secondary: #ffffff;
    --wa-bg-tertiary: #e9edef;
    --wa-text-primary: #111b21;
    --wa-text-secondary: #667781;
    --wa-text-tertiary: #8696a0;
    --wa-accent: #00a884;
    --wa-accent-hover: #06cf9c;
    --wa-user-bubble: #d9fdd3;
    --wa-bot-bubble: #ffffff;
    --wa-border: #e9edef;
    --wa-error: #f15c6d;
    --wa-success: #00a884;
}

/* Temas Personalizados */
[data-theme="blue"] {
    --wa-accent: #0084ff;
    --wa-accent-hover: #0073e6;
    --wa-user-bubble: #0084ff;
}

[data-theme="purple"] {
    --wa-accent: #8b5cf6;
    --wa-accent-hover: #7c3aed;
    --wa-user-bubble: #8b5cf6;
}

[data-theme="green"] {
    --wa-accent: #10b981;
    --wa-accent-hover: #059669;
    --wa-user-bubble: #10b981;
}

/* Tamanhos de fonte ajustáveis */
[data-font-size="small"] {
    --font-size-multiplier: 0.85;
}

[data-font-size="normal"] {
    --font-size-multiplier: 1;
}

[data-font-size="large"] {
    --font-size-multiplier: 1.15;
}

[data-font-size="extra-large"] {
    --font-size-multiplier: 1.3;
}

/* Reset e configurações base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--wa-bg-primary);
    color: var(--wa-text-primary);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height */
    overflow: hidden;
    font-size: calc(14px * var(--font-size-multiplier));
    /* Evitar scroll bounce no iOS */
    overscroll-behavior: none;
}

/* Container principal */
.whatsapp-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height para mobile */
    width: 100%;
    max-width: 100%;
    background-color: var(--wa-bg-primary);
    position: relative;
    overflow: hidden;
}

/* Header */
.chat-header {
    background-color: var(--wa-bg-secondary);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--wa-border);
    min-height: 60px;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    /* Performance otimizada */
    will-change: transform;
    transform: translateZ(0);
}

/* Header mobile adjustments */
@media (max-width: 768px) {
    .chat-header {
        padding: 8px 12px;
        min-height: 56px;
    }
    
    .contact-name {
        font-size: 14px;
        line-height: 1.2;
    }
    
    .contact-name-wrapper {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .contact-status {
        font-size: 12px;
    }
    
    .avatar {
        width: 36px;
        height: 36px;
    }
    
    .avatar-container {
        width: 36px;
        height: 36px;
    }
    
    .header-badges {
        gap: 2px;
    }
    
    .badge {
        font-size: 9px;
        padding: 1px 4px;
        white-space: nowrap;
    }
    
    .badge.verified {
        font-size: 10px;
        padding: 2px 4px;
    }
}

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

.avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #25d366;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #25d366;
    border-radius: 50%;
    border: 2px solid #202c33;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.contact-info {
    flex: 1;
}

.contact-name-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.badges-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.connections-counter {
    background-color: #25d366;
    color: #111b21;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    animation: pulse-green 2s infinite;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@keyframes pulse-green {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.connections-text {
    display: flex;
    align-items: center;
    gap: 2px;
}

.contact-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--wa-text-primary);
    margin: 0;
}

.contact-status {
    font-size: 13px;
    color: var(--wa-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator {
    color: var(--wa-accent);
    font-weight: 500;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.header-right {
    display: flex;
    align-items: center;
}

.header-badges {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.badge {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.connections-count.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    margin: 0 2px;
}

.badge.verified {
    background-color: #1da1f2;
    color: white;
    font-size: 12px;
    padding: 3px 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.badge.secure {
    background-color: #8696a0;
    color: #202c33;
    font-size: 14px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Área de chat */
.chat-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: var(--wa-bg-primary);
    /* Performance otimizada */
    will-change: scroll-position;
    transform: translateZ(0);
}

.chat-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill-opacity='0.03'%3E%3Cpolygon fill='%23ffffff' points='50 0 60 40 100 50 60 60 50 100 40 60 0 50 40 40'/%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.1;
    pointer-events: none;
}

.messages-container {
    height: 100%;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(37, 211, 102, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(37, 211, 102, 0.02) 0%, transparent 50%);
}

/* Scrollbar personalizada - compatibilidade universal */
/* Removido scrollbar-width e scrollbar-color para melhor compatibilidade */
/* Usando apenas -webkit-scrollbar que funciona em Chrome, Safari e Edge */

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

.messages-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: #2a3942;
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: content-box;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: #3a4952;
}

.messages-container::-webkit-scrollbar-corner {
    background: transparent;
}

/* Mensagens */
.message {
    display: flex;
    margin-bottom: 8px;
    animation: messageSlideIn 0.3s ease-out;
}

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

/* Animações laterais mais realistas */
@keyframes messageSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes messageSlideInRight {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.message.user-message {
    justify-content: flex-end;
    animation: messageSlideInRight 0.4s ease-out;
}

.message.bot-message {
    justify-content: flex-start;
    animation: messageSlideInLeft 0.4s ease-out;
}

.message-content {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-message .message-content {
    background-color: var(--wa-user-bubble);
    color: var(--wa-text-primary);
    border-bottom-right-radius: 2px;
    /* Performance otimizada */
    will-change: transform;
    transform: translateZ(0);
}

.bot-message .message-content {
    background-color: var(--wa-bot-bubble);
    color: var(--wa-text-primary);
    border-bottom-left-radius: 2px;
    /* Performance otimizada */
    will-change: transform;
    transform: translateZ(0);
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    color: var(--wa-text-secondary);
    align-self: flex-end;
    margin-top: 4px;
}

/* Animação de digitação */
.typing-animation {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 8px;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #8696a0;
    animation: typingDots 1.4s infinite ease-in-out;
}

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

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

/* Botões de resposta rápida */
.quick-replies {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background-color: var(--wa-bg-primary);
    border-top: 1px solid var(--wa-border);
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
    animation: slideUp 0.3s ease-out;
    /* Performance otimizada */
    will-change: transform;
    transform: translateZ(0);
}

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

/* Mobile quick replies adjustments */
@media (max-width: 768px) {
    .quick-replies {
        padding: 8px 12px;
        gap: 6px;
        max-height: 150px;
    }
    
    .quick-reply-btn {
        font-size: 13px;
        padding: 8px 12px;
        min-height: 36px;
    }
    
    .connections-counter {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .badge {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
    
    /* Mensagens mobile */
    .message-content {
        max-width: 85%;
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .message-text {
        font-size: 14px;
        line-height: 1.3;
    }
    
    .message-time {
        font-size: 10px;
        margin-top: 2px;
    }
}

.quick-reply-btn {
    background-color: var(--wa-bg-secondary);
    color: var(--wa-text-primary);
    border: 1px solid var(--wa-border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
    /* Performance otimizada */
    will-change: transform, background-color;
    transform: translateZ(0);
}

.quick-reply-btn:hover {
    background-color: var(--wa-bg-tertiary);
    border-color: var(--wa-accent);
    transform: translateY(-2px) translateZ(0);
    box-shadow: 0 4px 12px rgba(0, 168, 132, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-reply-btn:active {
    transform: translateY(-1px) translateZ(0) scale(0.98);
    background-color: var(--wa-accent);
    color: var(--wa-bg-primary);
    box-shadow: 0 2px 8px rgba(0, 168, 132, 0.25);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Efeito ripple nos botões */
.quick-reply-btn {
    position: relative;
    overflow: hidden;
}

.quick-reply-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 168, 132, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.quick-reply-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Área de input */
.input-area {
    background-color: var(--wa-bg-secondary);
    padding: 12px 16px;
    border-top: 1px solid var(--wa-border);
    flex-shrink: 0;
    transition: all 0.3s ease;
    /* Performance otimizada */
    will-change: transform, opacity;
    transform: translateZ(0);
}

/* Esconder input quando há quick replies */
.input-area {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition: all 0.3s ease;
}

.input-area.hidden-for-replies {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

/* Mobile input adjustments */
@media (max-width: 768px) {
    .input-area {
        padding: 8px 12px;
        /* Ajuste para teclado virtual no iOS */
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    .text-input-wrapper {
        padding: 6px 12px;
    }
    
    .message-input {
        font-size: 16px; /* Evita zoom no iOS */
        min-height: 20px;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
    }
    
    .send-button svg {
        width: 20px;
        height: 20px;
    }
}

.input-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: var(--wa-bg-tertiary);
    border-radius: 24px;
    padding: 8px 16px;
    gap: 8px;
    transition: all 0.2s ease;
    /* Performance otimizada */
    will-change: background-color;
    transform: translateZ(0);
}

.text-input-wrapper:focus-within {
    background-color: var(--wa-bg-tertiary);
    /* Removido box-shadow para não mostrar borda */
}

.message-input:focus {
    outline: none;
    border: none;
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--wa-text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
}

.message-input::placeholder {
    color: var(--wa-text-secondary);
}

.message-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--wa-accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    /* Performance otimizada */
    will-change: transform, background-color;
    transform: translateZ(0);
    /* Acessibilidade */
    -webkit-tap-highlight-color: transparent;
}

.send-button:hover:not(:disabled) {
    background-color: var(--wa-accent-hover);
    transform: scale(1.05) translateZ(0);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95) translateZ(0);
}

.send-button:disabled {
    background-color: var(--wa-bg-tertiary);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(17, 27, 33, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    /* Performance otimizada */
    will-change: opacity;
    transform: translateZ(0);
}

.loading-spinner {
    text-align: center;
    color: var(--wa-text-primary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--wa-border);
    border-top: 3px solid var(--wa-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
    /* Performance otimizada */
    will-change: transform;
    transform: translateZ(0);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    font-size: 14px;
    color: var(--wa-text-secondary);
}

/* Responsividade */
@media (max-width: 768px) {
    .header-badges {
        display: none;
    }
    
    .contact-name {
        font-size: 15px;
    }
    
    .contact-status {
        font-size: 12px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .quick-reply-btn {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .message-input {
        font-size: 16px; /* Evita zoom no iOS */
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 8px 12px;
    }
    
    .messages-container {
        padding: 8px 12px;
    }
    
    .input-area {
        padding: 8px 12px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 6px 10px;
    }
    
    .message-text {
        font-size: 13px;
    }
    
    .avatar {
        width: 36px;
        height: 36px;
    }
    
    .avatar-container {
        width: 36px;
        height: 36px;
    }
}

/* Theme Controls */
.theme-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-btn, .settings-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
}

.theme-btn:hover, .settings-btn:hover {
    background-color: var(--wa-bg-tertiary);
    color: var(--wa-text-primary);
    transform: scale(1.05);
}

.theme-btn:active, .settings-btn:active {
    transform: scale(0.95);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background-color: var(--wa-bg-secondary);
    border-left: 1px solid var(--wa-border);
    z-index: 1000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.settings-panel.open {
    right: 0;
}

.settings-content {
    padding: 20px;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--wa-border);
}

.settings-header h3 {
    color: var(--wa-text-primary);
    font-size: 20px;
    font-weight: 500;
}

.close-settings {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--wa-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-settings:hover {
    background-color: var(--wa-bg-tertiary);
    color: var(--wa-text-primary);
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h4 {
    color: var(--wa-text-primary);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
}

.theme-options, .color-options {
    display: flex;
    gap: 12px;
}

.theme-option, .color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    background: transparent;
    border: 2px solid var(--wa-border);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--wa-text-secondary);
    font-size: 12px;
}

.theme-option:hover, .color-option:hover {
    border-color: var(--wa-accent);
    background-color: var(--wa-bg-tertiary);
}

.theme-option.active, .color-option.active {
    border-color: var(--wa-accent);
    background-color: var(--wa-accent);
    color: white;
}

.theme-preview, .color-preview {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--wa-border);
}

/* Color preview styles */
.color-option[data-color="green"] .color-preview {
    background-color: #00a884;
}

.color-option[data-color="blue"] .color-preview {
    background-color: #0084ff;
}

.color-option[data-color="purple"] .color-preview {
    background-color: #8b5cf6;
}

.dark-preview {
    background: linear-gradient(135deg, #111b21 0%, #202c33 100%);
}

.light-preview {
    background: linear-gradient(135deg, #f0f2f5 0%, #ffffff 100%);
}

.font-size-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.font-size-option {
    padding: 12px 16px;
    border-radius: 8px;
    background: transparent;
    border: 2px solid var(--wa-border);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--wa-text-secondary);
    font-size: 14px;
}

.font-size-option:hover {
    border-color: var(--wa-accent);
    background-color: var(--wa-bg-tertiary);
}

.font-size-option.active {
    border-color: var(--wa-accent);
    background-color: var(--wa-accent);
    color: white;
}

/* Mobile adjustments for settings */
@media (max-width: 768px) {
    .settings-panel {
        width: 100vw;
        right: -100vw;
    }
    
    .theme-controls {
        gap: 4px;
    }
    
    .theme-btn, .settings-btn {
        width: 32px;
        height: 32px;
    }
}

/* Acessibilidade */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles para navegação por teclado */
.quick-reply-btn:focus,
.send-button:focus,
.message-input:focus {
    outline: 2px solid var(--wa-accent);
    outline-offset: 2px;
}

/* Focus visível apenas para navegação por teclado */
.quick-reply-btn:focus:not(:focus-visible),
.send-button:focus:not(:focus-visible) {
    outline: none;
}

.quick-reply-btn:focus-visible,
.send-button:focus-visible {
    outline: 2px solid var(--wa-accent);
    outline-offset: 2px;
}

/* Estados de erro para validação */
.input-error {
    border-color: var(--wa-error) !important;
    box-shadow: 0 0 0 2px rgba(241, 92, 109, 0.3) !important;
}

.error-message {
    color: var(--wa-error);
    font-size: 12px;
    margin-top: 4px;
    animation: shake 0.5s ease-in-out;
    /* Acessibilidade: role e aria-live devem ser definidos no HTML, não CSS */
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Animação typewriter */
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 2s steps(40, end);
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

/* Melhorias de performance */
.message-content,
.quick-reply-btn,
.send-button {
    will-change: transform;
}

/* Fix para layout mobile - evitar que header suma e espaço embaixo apareça */
@media screen and (max-width: 768px) {
    .whatsapp-container {
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height para mobile */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        overflow: hidden;
    }
    
    .chat-header {
        position: sticky;
        top: 0;
        z-index: 100;
        flex-shrink: 0;
    }
    
    .messages-container {
        flex: 1;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .input-area {
        position: sticky;
        bottom: 0;
        flex-shrink: 0;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--wa-bg-secondary);
        border-top: 1px solid var(--wa-border);
    }
    
    /* Evitar zoom no input em iOS */
    .message-input {
        font-size: 16px !important;
        transform-origin: left top;
        transform: scale(1);
    }
    
    /* Melhorar área tocável dos botões */
    .quick-reply-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .send-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Suporte para temas do sistema */
@media (prefers-color-scheme: light) {
    /* Mantém o tema dark independente da preferência do sistema */
}

/* Scrollbar customizado - compatível com todos os navegadores */
.messages-container {
    /* Garante que o scroll funcione em todos os navegadores */
    overflow-y: auto;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: #2a3942;
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: content-box;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: #3a4952;
}

.messages-container::-webkit-scrollbar-corner {
    background: transparent;
}

