/* ==========================================
   AGENT.CSS - AI CHAT WIDGET STYLES
   ACCESSIBLE VERSION
   ========================================== */

.ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9995;
    font-family: 'Inter', sans-serif;
}

/* --- Toggle Button --- */
.chat-toggle-btn {
    width: 50px;
    height: 50px;
    background: var(--darker);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.chat-toggle-btn:hover {
    transform: translateY(-3px);
    background: var(--primary);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.3);
}

.chat-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--beige);
}

/* --- Chat Window --- */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0);
    transform-origin: bottom right;
    transition: all 0.3s ease;
    opacity: 0;
    border: 1px solid rgba(0,0,0,0.05);
}

.chat-window.active {
    transform: scale(1);
    opacity: 1;
}

/* Header */
.chat-header {
    background: var(--darker);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

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

.agent-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    padding: 5px;
}

.agent-avatar img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #10B981;
    border-radius: 50%;
    border: 2px solid var(--darker);
}

.agent-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ACCESSIBILITY FIX: Using span instead of h4 */
.agent-name {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    color: #fff;
}

.agent-role {
    font-size: 0.75rem;
    opacity: 0.7;
}

.close-chat {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: 0.2s;
    min-height: auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-chat:hover { 
    opacity: 1; 
    background: rgba(255,255,255,0.1);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    background: var(--beige);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.message.bot { align-self: flex-start; }
.message.user { align-self: flex-end; align-items: flex-end; }

.message-content {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message.bot .message-content {
    background: #fff;
    color: var(--darker);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.message.user .message-content {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.message-time {
    font-size: 0.7rem;
    color: rgba(0,0,0,0.4);
    margin-top: 4px;
}

/* Typing Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: #fff;
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce { 
    0%, 80%, 100% { transform: scale(0); } 
    40% { transform: scale(1); } 
}

/* Input Area */
.chat-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.05);
}

#chatForm { 
    display: flex; 
    gap: 10px; 
}

/* ACCESSIBILITY: Visually hidden label */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#chatInput {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #eee;
    border-radius: 25px;
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    min-height: auto;
}

#chatInput:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.send-btn {
    background: var(--darker);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    min-height: auto;
    flex-shrink: 0;
}

.send-btn:hover { 
    background: var(--primary); 
}

.send-btn:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.branding {
    text-align: center;
    font-size: 0.7rem;
    color: #999;
    margin-top: 8px;
}

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
    .ai-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .chat-toggle-btn {
        width: 45px;
        height: 45px;
    }
    
    .chat-toggle-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .notification-badge {
        width: 16px;
        height: 16px;
        font-size: 0.65rem;
        top: -3px;
        right: -3px;
    }
    
    .chat-window {
        bottom: 65px;
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        position: fixed;
        z-index: 10000;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .ai-chat-widget {
            bottom: max(20px, env(safe-area-inset-bottom));
            right: max(20px, env(safe-area-inset-right));
        }
    }
}