/* Chat Assistant - WhatsApp Theme */
.chat-assistant-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Chat Button */
.chat-assistant-button-container {
    position: fixed;
    z-index: 9999;
    transition: all 0.3s ease;
    width: fit-content;
}

.chat-assistant-button-container.desktop {
    right: 20px;
    bottom: 15px;
    left: auto;
    display: block;
}

.chat-assistant-button-container.mobile {
    display: none;
}

@media (max-width: 768px) {
    .chat-assistant-button-container.desktop {
        display: none;
    }
    
    .chat-assistant-button-container.mobile {
        display: block;
        left: 15px;
        bottom: 20px;
        right: auto;
    }
}

.chat-assistant-button {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    min-width: 180px;
    line-height: normal;
    transition: all 0.3s ease;
    position: relative;
}

.chat-assistant-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.35);
    background: linear-gradient(135deg, #25D366 0%, #075E54 100%);
}

.chat-assistant-icon {
    font-size: 18px;
}

.chat-assistant-live-dot {
    width: 8px;
    height: 8px;
    background: #25D366;
    border-radius: 50%;
    position: absolute;
    top: 12px;
    right: 12px;
    animation: chat-assistant-pulse 2s infinite;
}

.chat-assistant-unread-indicator {
    width: 10px;
    height: 10px;
    background: #FF3B30;
    border-radius: 50%;
    position: absolute;
    top: 8px;
    right: 8px;
    border: 2px solid white;
    display: none;
    animation: chat-assistant-pulse 1s infinite;
}

/* Status indicator colors */
.chat-assistant-widget[data-status="online"] .chat-assistant-live-dot {
    background: #25D366 !important;
}

.chat-assistant-widget[data-status="connecting"] .chat-assistant-live-dot {
    background: #2196F3 !important;
    animation: chat-assistant-pulse 1s infinite;
}

.chat-assistant-widget[data-status="faq_only"] .chat-assistant-live-dot {
    display: none !important;
}

@keyframes chat-assistant-pulse {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.7; }
}

/* Chat Window */
.chat-assistant-window {
    position: fixed;
    z-index: 999;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    border: 1px solid #e0e7ff;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.98);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-assistant-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Desktop - 360px × 420px */
.chat-assistant-window {
    width: 360px;
    max-height: 420px;
    height: 420px;
    right: 20px;
    bottom: 20px;
}

/* Mobile - Fixed above menu bar */
@media (max-width: 768px) {
    .chat-assistant-window {
        width: calc(100vw - 30px);
        max-height: 55vh;
        height: auto;
        left: 15px;
        right: auto;
        bottom: 80px;
    }
    
    .chat-assistant-window.active {
        bottom: 80px !important;
    }
}

/* Header */
.chat-assistant-header {
    background: linear-gradient(135deg, #075E54 0%, #128C7E 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-assistant-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-assistant-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-assistant-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.chat-assistant-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.chat-assistant-status-dot {
    width: 7px;
    height: 7px;
    background: #25D366;
    border-radius: 50%;
}

/* Status indicator colors in chat window */
.chat-assistant-status-indicator[data-status="connecting"] .chat-assistant-status-dot {
    background: #2196F3;
    animation: chat-assistant-pulse 1s infinite;
}

.chat-assistant-status-indicator[data-status="online"] .chat-assistant-status-dot {
    background: #25D366;
}

.chat-assistant-status-indicator[data-status="faq_only"] .chat-assistant-status-dot {
    background: #FF9800;
}

.chat-assistant-status-text {
    font-size: 11px;
    opacity: 0.9;
}

.chat-assistant-header-actions {
    display: flex;
    gap: 8px;
}

.chat-assistant-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.chat-assistant-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages */
.chat-assistant-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 150px;
}

.chat-assistant-message {
    max-width: 85%;
    min-width: 80px;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    animation: chat-assistant-fadeIn 0.2s ease;
    position: relative;
}

@keyframes chat-assistant-fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-assistant-message-bot {
    background: white;
    color: #1f2937;
    align-self: flex-start;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-assistant-message-user {
    background: #25D366;
    color: white;
    align-self: flex-end;
    box-shadow: 0 1px 2px rgba(37, 211, 102, 0.2);
}

/* FIXED: Word breaking issue - keep words together */
.chat-assistant-message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: keep-all;
    hyphens: manual;
    white-space: normal;
}

.chat-assistant-message-content a {
    color: #128C7E;
    text-decoration: underline;
    font-weight: 500;
    word-break: break-all;
}

.chat-assistant-message-content a:hover {
    color: #075E54;
}

/* WhatsApp-style Timestamps */
.chat-assistant-message-time {
    font-size: 11px;
    opacity: 0.7;
    position: absolute;
    white-space: nowrap;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0.3px;
}

.chat-assistant-message-bot .chat-assistant-message-time {
    color: #667781;
    bottom: 6px;
    right: 10px;
    background: none;
    padding: 0;
    border-radius: 0;
}

.chat-assistant-message-user .chat-assistant-message-time {
    color: rgba(255, 255, 255, 0.9);
    bottom: 6px;
    right: 10px;
    background: none;
    padding: 0;
    border-radius: 0;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.chat-assistant-message-user,
.chat-assistant-message-bot {
    padding-bottom: 20px;
    padding-right: 40px;
}

/* Simple Typing Indicator - 3 Wave Dots */
.chat-assistant-typing-indicator {
    padding: 12px 16px;
    background: transparent;
    border-top: 1px solid #e5e7eb;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 40px;
}

.chat-assistant-typing-indicator.active {
    display: flex;
}

.chat-assistant-typing-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 20px;
}

.chat-assistant-typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    display: inline-block;
    animation: chat-assistant-wave 1.4s infinite ease-in-out both;
}

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

/* Simple wave animation */
@keyframes chat-assistant-wave {
    0%, 80%, 100% { 
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* Input */
.chat-assistant-input-area {
    border-top: 1px solid #e5e7eb;
    background: white;
    padding: 16px;
    flex-shrink: 0;
}

.chat-assistant-input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: flex-end;
}

#chat-assistant-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    background: white;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.5;
    transition: border-color 0.2s;
    -ms-overflow-style: none;  /* Hide scrollbar for IE and Edge */
    scrollbar-width: none;      /* Hide scrollbar for Firefox */
}

#chat-assistant-input::-webkit-scrollbar {
    display: none;             /* Hide scrollbar for Chrome, Safari, Opera */
}

#chat-assistant-input:focus {
    border-color: #25D366;
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.1);
}

#chat-assistant-input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.chat-assistant-send-button {
    background: #25D366;
    color: white;
    border: none;
    padding: 0 20px;
    height: 44px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    min-width: 70px;
    transition: background 0.2s;
}

.chat-assistant-send-button:hover:not(:disabled) {
    background: #128C7E;
}

.chat-assistant-send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Footer */
.chat-assistant-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #f1f3f5;
}

.chat-assistant-branding {
    color: #6b7280;
    font-size: 11px;
    font-weight: 500;
}

/* Scrollbar */
.chat-assistant-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-assistant-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-assistant-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-assistant-messages {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

/* Admin bar adjustment */
.admin-bar .chat-assistant-button-container.desktop {
    bottom: 52px;
}

.admin-bar .chat-assistant-window {
    bottom: 32px;
}

@media (max-width: 782px) {
    .admin-bar .chat-assistant-button-container.desktop {
        bottom: 66px;
    }
    
    .admin-bar .chat-assistant-button-container.mobile {
        bottom: 86px;
    }
    
    .admin-bar .chat-assistant-window {
        bottom: 106px;
    }
    
    .admin-bar .chat-assistant-window.active {
        bottom: 106px;
    }
}

.chat-assistant-hidden {
    display: none !important;
}

/* Prevent text selection on chat elements */
.chat-assistant-button,
.chat-assistant-minimize,
.chat-assistant-send-button {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Better responsive handling for very small screens */
@media (max-width: 380px) {
    .chat-assistant-window {
        width: calc(100vw - 20px);
        left: 10px;
        right: 10px;
    }
    
    .chat-assistant-button {
        min-width: 160px;
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Edge case for very long words - FIXED */
.chat-assistant-message-content {
    /* Keep existing properties */
    word-wrap: break-word;
    overflow-wrap: break-word;
    /* NEW FIX: Prevent hyphenation and keep words together */
    word-break: keep-all;
    hyphens: manual;
    /* Allow breaking only at spaces */
    white-space: normal;
}

/* Special handling for URLs in messages */
.chat-assistant-message-content a {
    word-break: break-all; /* URLs can break */
}

/* THE ONLY FIX: Prevent chat button from interfering with mini-cart buttons */
.chat-assistant-button-container {
    /* Prevent the container from creating invisible overlay */
    width: fit-content;
}

.chat-assistant-button {
    /* Ensure button doesn't expand beyond its content */
    display: inline-flex;
    width: auto;
}
