/* eCripto Help Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: var(--font-family);
}

.chat-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.chat-toggle:focus {
    outline: 3px solid var(--color-primary-light);
    outline-offset: 2px;
}

.chat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
}

.chat-window {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-window[hidden] {
    display: none;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--color-primary);
    color: white;
}

.chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-close:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.chat-message p {
    margin: 0;
}

.chat-message.bot {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    background: var(--color-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-message.loading {
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
}

.chat-message.loading::after {
    content: '...';
    animation: loading 1s infinite;
}

@keyframes loading {
    0%, 33% { content: '.'; }
    34%, 66% { content: '..'; }
    67%, 100% { content: '...'; }
}

.chat-form {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--color-border);
    gap: 8px;
}

.chat-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-form input:focus {
    border-color: var(--color-primary);
}

.chat-form button {
    padding: 12px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-form button:hover {
    background: var(--color-primary-dark);
}

.chat-form button:focus {
    outline: 3px solid var(--color-primary-light);
    outline-offset: 2px;
}

.chat-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 480px) {
    .chat-widget {
        bottom: 10px;
        right: 10px;
    }

    .chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 50px;
    }

    .chat-toggle {
        padding: 10px 16px;
    }

    .chat-label {
        display: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .chat-window {
        border: 2px solid black;
    }

    .chat-message.bot {
        border: 1px solid var(--color-text-primary);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .chat-toggle,
    .chat-form button,
    .chat-form input {
        transition: none;
    }

    .chat-message.loading::after {
        animation: none;
        content: '...';
    }
}
