/**
 * Awa AI Chatbot - Dark Mode Styling
 * Moat Digital Brand Integration
 * Version: 3.1.0 - Dark Mode with #8A2BE2 Accents
 */

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(138, 43, 226, 0.4); 
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(138, 43, 226, 0); 
    }
}

@keyframes slideUp {
    from { 
        opacity: 0; 
        transform: translateY(20px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px rgba(138, 43, 226, 0.3); }
    50% { box-shadow: 0 0 20px rgba(138, 43, 226, 0.6); }
}

/* ========================================
   TOGGLE BUTTON - CENTER-BOTTOM POSITION
   ======================================== */
.awa-ai-toggle {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg,  0%, 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(138, 43, 226, 0.4);
    cursor: pointer;
    z-index: 999997;
    transition: all 0.3s ease;
    border: 3px solid #8A2BE2;
    animation: pulse 2s infinite;
}

.awa-ai-toggle:hover {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 10px 30px rgba(138, 43, 226, 0.6);
    background: linear-gradient(135deg, #FFFFFF 0%, #5B21B6 100%);
}

.awa-ai-badge {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #FFFFFF;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    border: 2px solid #8A2BE2;
    animation: float 3s ease-in-out infinite;
}

.awa-ai-badge img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.awa-ai-unread-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #EF4444;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    display: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    border: 2px solid #8A2BE2;
}

/* ========================================
   MODAL CONTAINER
   ======================================== */
.awa-ai-modal {
    display: none;
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 560px;
    background: #1E1B4B;
    border-radius: 24px;
    box-shadow: 0 15px 50px rgba(138, 43, 226, 0.3);
    z-index: 999996;
    overflow: hidden;
    animation: slideUp 0.4s ease;
    border: 2px solid #8A2BE2;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Open Sans', sans-serif;
}

/* ========================================
   HEADER
   ======================================== */
.awa-ai-header {
    background: linear-gradient(135deg, #6D28D9 0%, #4C1D95 100%);
    color: white;
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid #8A2BE2;
}

.awa-ai-header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.awa-ai-avatar {
    background: #FFFFFF;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid #8A2BE2;
    overflow: hidden;
}

.awa-ai-avatar img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.awa-ai-header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.awa-ai-title {
    font-weight: 700;
    font-size: 18px;
    margin: 0;
    line-height: 1.3;
}

.awa-ai-subtitle {
    font-size: 13px;
    opacity: 0.95;
    font-weight: 500;
    margin: 0;
    line-height: 1.3;
}

.awa-ai-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #8A2BE2;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    font-weight: 300;
    flex-shrink: 0;
}

.awa-ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
    border-color: #7C3AED;
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.5);
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */
.awa-ai-messages {
    height: calc(100% - 180px);
    overflow-y: auto;
    padding: 24px;
    background: #1A1740;
    display: flex;
    flex-direction: column;
    gap: 18px;
    border-top: 2px solid #8A2BE2;
    border-bottom: 2px solid #8A2BE2;
}

/* ========================================
   MESSAGE STYLES
   ======================================== */
.awa-ai-message {
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.6;
    font-size: 14px;
    max-width: 85%;
    word-wrap: break-word;
    font-family: inherit;
    position: relative;
}

.awa-ai-message.user {
    background: linear-gradient(135deg, #6D28D9 0%, #4C1D95 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 8px;
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.3);
    border: 2px solid #8A2BE2;
}

.awa-ai-message.ai {
    background: #25225A;
    color: #F3F4F6;
    border: 2px solid #8A2BE2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-bottom-left-radius: 8px;
}

.awa-ai-message a {
    color: #8A2BE2;
    text-decoration: underline;
    font-weight: 600;
}

.awa-ai-message a:hover {
    color: #7C3AED;
    text-decoration: none;
}

/* ========================================
   INPUT AREA
   ======================================== */
.awa-ai-input-area {
    padding: 20px 24px;
    background: #1E1B4B;
    border-top: 2px solid #8A2BE2;
    display: flex;
    gap: 12px;
    align-items: center;
}

.awa-ai-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #8A2BE2;
    border-radius: 18px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    font-family: inherit;
    line-height: 1.5;
    background: #1A1740;
    color: #F3F4F6;
}

.awa-ai-input:focus {
    border-color: #7C3AED;
    box-shadow: 0 0 0 4px rgba(138, 43, 226, 0.2);
    background: #171438;
}

.awa-ai-input::placeholder {
    color: #FFFFFF;
    opacity: 0.8;
}

.awa-ai-send-btn {
    background: linear-gradient(135deg, #3498db 0%, #3498db 100%);
    color: white;
    border: 2px solid #8A2BE2;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(138, 43, 226, 0.3);
    transition: all 0.2s;
    flex-shrink: 0;
}

.awa-ai-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(138, 43, 226, 0.5);
    background: linear-gradient(135deg, #7C3AED 0%, #5B21B6 100%);
    border-color: #7C3AED;
    animation: glow 1.5s ease-in-out infinite;
}

/* ========================================
   POWERED BY BADGE
   ======================================== */
.awa-ai-powered-by {
    padding: 16px 24px 24px 24px;
    text-align: center;
    font-size: 12px;
    color: #9CA3AF;
    font-weight: 600;
    background: #1E1B4B;
    border-top: 2px solid #8A2BE2;
}

.awa-ai-powered-text {
    background: linear-gradient(135deg, #6D28D9 0%, #4C1D95 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 4px 12px;
    border-radius: 14px;
    font-weight: 700;
    display: inline-block;
    letter-spacing: 0.3px;
    border: 1px solid #8A2BE2;
}

/* ========================================
   QUICK REPLY BUTTONS
   ======================================== */
.awa-ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 8px;
    border-top: 2px solid #8A2BE2;
}

.awa-ai-quick-reply-btn {
    background: #25225A;
    color: #8A2BE2;
    border: 2px solid #8A2BE2;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    line-height: 1.4;
}

.awa-ai-quick-reply-btn:hover {
    background: #1E1B4B;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(138, 43, 226, 0.3);
    color: #7C3AED;
    border-color: #7C3AED;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
.awa-ai-messages::-webkit-scrollbar {
    width: 8px;
}

.awa-ai-messages::-webkit-scrollbar-track {
    background: #171438;
    border-radius: 12px;
    margin: 4px 0;
    border: 1px solid #8A2BE2;
}

.awa-ai-messages::-webkit-scrollbar-thumb {
    background: #6D28D9;
    border-radius: 12px;
    border: 2px solid #8A2BE2;
}

.awa-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #7C3AED;
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
    .awa-ai-modal {
        width: 95%;
        max-width: 420px;
        bottom: 100px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        margin: 0 auto;
        height: 580px;
    }
    
    .awa-ai-toggle {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 65px;
        height: 65px;
    }
    
    .awa-ai-badge {
        width: 48px;
        height: 48px;
        border-width: 2px;
    }
    
    .awa-ai-badge img {
        width: 32px;
        height: 32px;
    }
    
    .awa-ai-message {
        max-width: 95%;
        padding: 14px 18px;
    }
    
    .awa-ai-header {
        padding: 18px 20px;
    }
    
    .awa-ai-avatar {
        width: 40px;
        height: 40px;
        border-width: 2px;
    }
    
    .awa-ai-avatar img {
        width: 26px;
        height: 26px;
    }
    
    .awa-ai-title {
        font-size: 16px;
    }
    
    .awa-ai-subtitle {
        font-size: 12px;
    }
    
    .awa-ai-messages {
        padding: 20px;
        gap: 16px;
    }
    
    .awa-ai-input-area {
        padding: 18px 20px;
    }
    
    .awa-ai-input {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .awa-ai-send-btn {
        width: 42px;
        height: 42px;
    }
    
    .awa-ai-powered-by {
        padding: 14px 20px 20px 20px;
        font-size: 11px;
    }
    
    .awa-ai-powered-text {
        padding: 3px 10px;
        font-size: 11px;
        border-radius: 12px;
    }
    
    .awa-ai-quick-reply-btn {
        padding: 8px 14px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .awa-ai-modal {
        width: 98%;
        max-width: 400px;
        bottom: 90px;
        height: 540px;
    }
    
    .awa-ai-toggle {
        bottom: 15px;
        width: 60px;
        height: 60px;
    }
    
    .awa-ai-badge {
        width: 44px;
        height: 44px;
        border-width: 2px;
    }
    
    .awa-ai-badge img {
        width: 28px;
        height: 28px;
    }
    
    .awa-ai-header {
        padding: 16px 18px;
    }
    
    .awa-ai-avatar {
        width: 36px;
        height: 36px;
        border-width: 2px;
    }
    
    .awa-ai-avatar img {
        width: 24px;
        height: 24px;
    }
    
    .awa-ai-title {
        font-size: 15px;
    }
    
    .awa-ai-close-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .awa-ai-messages {
        padding: 16px;
        gap: 14px;
    }
    
    .awa-ai-message {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .awa-ai-input-area {
        padding: 16px 18px;
        gap: 10px;
    }
    
    .awa-ai-input {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 16px;
    }
    
    .awa-ai-send-btn {
        width: 40px;
        height: 40px;
    }
    
    .awa-ai-powered-by {
        padding: 12px 18px 18px 18px;
        font-size: 10px;
    }
    
    .awa-ai-powered-text {
        padding: 2px 8px;
        font-size: 10px;
    }
}

/* ========================================
   HOVER EFFECTS & INTERACTIONS
   ======================================== */
.awa-ai-message.user::before {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(45deg, transparent, #8A2BE2, transparent);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.awa-ai-message.user:hover::before {
    opacity: 1;
}

.awa-ai-send-btn::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: linear-gradient(45deg, #6D28D9, #8A2BE2, #7C3AED, #8A2BE2);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.awa-ai-send-btn:hover::before {
    opacity: 1;
    animation: rotateGradient 2s linear infinite;
}

@keyframes rotateGradient {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================
   MESSAGE ANIMATIONS
   ======================================== */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.awa-ai-message {
    animation: messageSlideIn 0.3s ease-out;
}

.awa-ai-message.user {
    animation: messageSlideIn 0.3s ease-out;
    transform-origin: top right;
}

/* ========================================
   DARK MODE OPTIMIZATIONS
   ======================================== */
@media (prefers-color-scheme: dark) {
    .awa-ai-modal {
        background: #1E1B4B;
    }
    
    .awa-ai-messages {
        background: #1A1740;
    }
    
    .awa-ai-input-area,
    .awa-ai-powered-by {
        background: #1E1B4B;
    }
    
    .awa-ai-input {
        background: #1A1740;
        color: #F3F4F6;
    }
    
    .awa-ai-message.ai {
        background: #25225A;
        color: #F3F4F6;
    }
}


/* ========================================
   QUICK REPLY BUTTONS - HOVER EFFECTS
   ======================================== */
.awa-ai-quick-reply-btn {
    background: #3498db !important;
    color: white !important;
    border: 2px solid #2980b9 !important;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2) !important;
    transition: all 0.25s ease !important;
}

.awa-ai-quick-reply-btn:hover {
    background: #8A2BE2 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.4) !important;
    border-color: #3498db !important;
}

.awa-ai-quick-reply-btn:active {
    transform: translateY(0) scale(0.98) !important;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3) !important;
}

.awa-ai-quick-reply-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3) !important;
}


/* ========================================
   ENHANCED LINK STYLING FOR INTERNAL URLS
   ======================================== */
.awa-ai-message a {
    color: #ffffff !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
    display: inline-block !important;
    margin: 8px 0 !important;
    padding: 6px 12px !important;
    background: rgba(52, 152, 219, 0.08) !important;
    border-radius: 6px !important;
    transition: all 0.25s ease !important;
    border: 1px solid rgba(52, 152, 219, 0.2) !important;
    position: relative !important;
    overflow: hidden !important;
}

.awa-ai-message a:hover {
    background: rgba(52, 152, 219, 0.18) !important;
    border-color: rgba(52, 152, 219, 0.4) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.25) !important;
    text-decoration: none !important;
}

.awa-ai-message a:active {
    transform: translateY(0) scale(0.98) !important;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3) !important;
}

.awa-ai-message a:focus {
    outline: 2px solid rgba(52, 152, 219, 0.5) !important;
    outline-offset: 2px !important;
}

.awa-ai-message a::after {
    margin-left: 6px !important;
    display: inline-block !important;
    transition: transform 0.2s ease !important;
}

.awa-ai-message a:hover::after {
    transform: translateX(3px) !important;
}

/* Enhanced quick reply button hover effects */
.awa-ai-quick-reply-btn:hover {
    background: #2980b9 !important;
    border-color: #2573a7 !important;
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.35) !important;
}

.awa-ai-quick-reply-btn:active {
    transform: translateY(0) scale(0.98) !important;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3) !important;
}

.awa-ai-quick-reply-btn:focus {
    outline: 2px solid rgba(52, 152, 219, 0.4) !important;
    outline-offset: 2px !important;
}