/**
 * AI Auto Responder - Chat Widget Styles
 * Floating chat widget for live AI support
 */

/* ==========================================================================
   Chat Widget Container
   ========================================================================== */

#aiar-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chat Toggle Button */
.aiar-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    color: #fff;
    font-size: 28px;
}

.aiar-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.aiar-chat-toggle:active {
    transform: scale(0.95);
}

.aiar-chat-toggle.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Unread Badge */
.aiar-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid #fff;
}

/* ==========================================================================
   Chat Window
   ========================================================================== */

.aiar-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: aiar-slide-up 0.3s ease;
}

.aiar-chat-window.active {
    display: flex;
}

@keyframes aiar-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.aiar-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.aiar-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aiar-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: 20px;
}

.aiar-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.aiar-chat-title p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.aiar-chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.aiar-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Chat Messages
   ========================================================================== */

.aiar-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aiar-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.aiar-chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.aiar-chat-message {
    display: flex;
    gap: 10px;
    animation: aiar-fade-in 0.3s ease;
}

@keyframes aiar-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aiar-chat-message.user {
    flex-direction: row-reverse;
}

.aiar-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.aiar-chat-message.user .aiar-message-avatar {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
}

.aiar-message-content {
    /* max-width: 70%; */
    padding: 12px 16px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    line-height: 1.5;
}

.aiar-chat-message.user .aiar-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aiar-chat-message.ai .aiar-message-content {
    border-bottom-left-radius: 4px;
}

.aiar-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.aiar-chat-message.user .aiar-message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.aiar-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.aiar-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: aiar-typing 1.4s infinite;
}

.aiar-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.aiar-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aiar-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ==========================================================================
   Chat Input
   ========================================================================== */

.aiar-chat-input-wrapper {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.aiar-chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.aiar-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.aiar-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.aiar-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.aiar-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
}

.aiar-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Rate Limit Warning */
.aiar-rate-limit-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 480px) {
    #aiar-chat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .aiar-chat-window {
        width: 100%;
        right: auto;
        left: 0;
        bottom: 70px;
        height: calc(100vh - 100px);
        max-height: 600px;
    }

    .aiar-message-content {
        max-width: 80%;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.aiar-chat-toggle:focus,
.aiar-chat-close:focus,
.aiar-chat-send:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.aiar-chat-input:focus {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Screen Reader Only */
.aiar-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
