/* assets/frontend.css */

.aichat-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 999999;
}

/* Widget positioning */
.aichat-widget.aichat-bottom-right {
    position: fixed;
    bottom: 20px;
    right: 20px;
}

.aichat-widget.aichat-bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
}

/* Chat bubble */
.aichat-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.aichat-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.aichat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
}

/* Chat window */
.aichat-window {
    position: fixed;
    bottom: 90px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aichat-bottom-right .aichat-window {
    right: 20px;
}

.aichat-bottom-left .aichat-window {
    left: 20px;
}

/* Header */
.aichat-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    flex-shrink: 0;
}

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

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

.aichat-header-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
	color: #ffffff;
}

.aichat-status {
    font-size: 12px;
    opacity: 0.9;
}

.aichat-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.aichat-close-btn:hover {
    opacity: 1;
}

/* Lead form */
.aichat-lead-form {
    padding: 24px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aichat-lead-content {
    width: 100%;
    max-width: 300px;
}

.aichat-lead-content h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
}

.aichat-lead-content p {
    margin: 0 0 24px 0;
    color: #666;
}

.aichat-lead-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.aichat-lead-form input:focus {
    outline: none;
    border-color: #007bff;
}

/* Messages */
.aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    min-height: 0; /* Important for flex overflow to work properly */
}

.aichat-message {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aichat-bot-message {
    flex-direction: row;
}

.aichat-user-message {
    flex-direction: row-reverse;
}

.aichat-message-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aichat-message-content {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
}

/* Formatted message content - steps and lists */
.aichat-message-content br {
    display: block;
    content: "";
    margin-top: 6px;
}

.aichat-message-content strong {
    font-weight: 600;
    color: inherit;
}

/* Clickable links in messages */
.aichat-message-content a.aichat-link {
    color: inherit;
    text-decoration: underline;
    word-break: break-all;
    cursor: pointer;
}

.aichat-message-content a.aichat-link:hover {
    opacity: 0.8;
}

.aichat-bot-message .aichat-message-content a.aichat-link {
    color: #007bff;
}

.aichat-user-message .aichat-message-content a.aichat-link {
    color: #ffffff;
}

.aichat-user-message .aichat-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.aichat-bot-message .aichat-message-content {
    border-bottom-left-radius: 4px;
}

/* Agent notice */
.aichat-agent-notice {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    border-top: 1px solid #c8e6c9;
    flex-shrink: 0;
}

/* Input area */
.aichat-input-area {
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    background: white;
    flex-shrink: 0;
}

.aichat-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.aichat-icon-btn:hover {
    background: #f0f0f0;
}

#aichat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    transition: border-color 0.2s;
}

#aichat-input:focus {
    outline: none;
    border-color: #007bff;
}

.aichat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.aichat-send-btn:hover {
    transform: scale(1.05);
}

.aichat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Fallback if SVG doesn't show */
.aichat-send-btn::after {
    content: '➤';
    font-size: 18px;
    color: white;
    display: none;
    line-height: 1;
}

.aichat-send-btn:empty::after {
    display: block;
}

/* Button */
.aichat-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.aichat-btn:hover {
    opacity: 0.9;
}

/* Typing indicator */
.aichat-typing {
    padding: 8px 16px;
    display: flex;
    gap: 4px;
    background: #f8f9fa;
    flex-shrink: 0;
}

.aichat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.aichat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.aichat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Typing cursor effect */
.aichat-typing-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

/* Mobile responsive */
@media (max-width: 480px) {
    .aichat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 90px;
    }
    
    .aichat-bottom-right .aichat-window,
    .aichat-bottom-left .aichat-window {
        right: 20px;
        left: 20px;
    }
}

/* Quick Actions */
.aichat-quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    flex-wrap: wrap;
    animation: slideIn 0.3s ease-out;
}

.aichat-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    border: 2px solid #007bff;
    color: #007bff;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.aichat-quick-btn:hover {
    background: #007bff;
    color: white;
}

.aichat-quick-btn svg {
    flex-shrink: 0;
}

/* Contact Card */
.aichat-contact-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    margin: 8px 0;
    animation: slideIn 0.3s ease-out;
}

.aichat-contact-card h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.aichat-contact-card p {
    margin: 8px 0;
    font-size: 14px;
    color: #555;
}

.aichat-contact-card strong {
    color: #333;
}

.aichat-contact-card a {
    color: #007bff;
    text-decoration: none;
}

.aichat-contact-card a:hover {
    text-decoration: underline;
}

/* Contact Details */
.aichat-contact-details {
    margin: 12px 0;
}

.aichat-contact-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 10px 0;
    font-size: 13px;
    color: #555;
    line-height: 1.4;
}

.aichat-contact-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.aichat-contact-item a {
    color: #007bff;
    text-decoration: none;
    word-break: break-all;
}

.aichat-contact-item a:hover {
    text-decoration: underline;
}

/* Social Media Links */
.aichat-social-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #eee;
}

.aichat-social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f5;
    color: #555;
    text-decoration: none;
    transition: all 0.2s;
}

.aichat-social-icon:hover {
    background: #007bff;
    color: white;
    transform: translateY(-2px);
}

.aichat-social-icon svg {
    width: 18px;
    height: 18px;
}

/* FAQ Buttons - Initial vertical layout */
.aichat-faq-buttons {
    display: block;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 8px 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* FAQ Mini Bar - Horizontal slider after first click */
.aichat-faq-mini-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

/* Hide scrollbar but keep functionality */
.aichat-faq-mini-bar::-webkit-scrollbar {
    height: 4px;
}

.aichat-faq-mini-bar::-webkit-scrollbar-track {
    background: transparent;
}

.aichat-faq-mini-bar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.aichat-faq-mini-bar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Mini FAQ chips */
.aichat-faq-chip {
    display: block;
    width: 100%;
    align-items: center;
    padding: 6px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aichat-faq-chip:hover {
    background: #007bff;
    color: white;
    border-color: #007bff;
    transform: translateY(-1px);
}

.aichat-faq-chip:active {
    transform: translateY(0);
}

/* FAQ label in mini bar */
.aichat-faq-mini-label {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.aichat-faq-title {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aichat-faq-btn {
    display: block;
    width: 100%;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 14px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    line-height: 1.4;
    /* Fix for long questions overflowing button */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    box-sizing: border-box;
    margin: 8px 0;
}

.aichat-faq-btn:hover {
    background: #f0f7ff;
	color: #000;
    border-color: #007bff;
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0,123,255,0.1);
}

.aichat-faq-btn:active {
    transform: translateX(0);
}

/* ===========================
   FOOTER CREDIT
   =========================== */

.aichat-widget .aichat-footer,
#aichat-window .aichat-footer,
.aichat-footer {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 12px !important;
    background: #ffffff !important;
    border-top: 1px solid #e5e5e5 !important;
    font-size: 11px !important;
    color: #999 !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    margin-top: auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 0 0 12px 12px !important;
}

.aichat-widget .aichat-footer a,
#aichat-window .aichat-footer a,
.aichat-footer a {
    color: #666 !important;
    text-decoration: none !important;
    transition: color 0.2s !important;
}

.aichat-widget .aichat-footer a:hover,
#aichat-window .aichat-footer a:hover,
.aichat-footer a:hover {
    color: #007bff !important;
    text-decoration: underline !important;
}

.aichat-widget .aichat-footer-divider,
#aichat-window .aichat-footer-divider,
.aichat-footer-divider {
    color: #ddd !important;
    font-size: 10px !important;
}

/* ===========================
   WIDGET THEMES
   =========================== */

/* Modern Theme (Default) */
.aichat-theme-modern .aichat-window {
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.aichat-theme-modern .aichat-message-content {
    border-radius: 12px;
}

/* Minimal Theme */
.aichat-theme-minimal .aichat-window {
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.aichat-theme-minimal .aichat-bubble {
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.aichat-theme-minimal .aichat-message-content {
    border-radius: 4px;
}

.aichat-theme-minimal #aichat-input {
    border-radius: 4px;
}

.aichat-theme-minimal .aichat-send-btn {
    border-radius: 4px;
}

/* Rounded Theme */
.aichat-theme-rounded .aichat-window {
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.aichat-theme-rounded .aichat-message-content {
    border-radius: 18px;
}

.aichat-theme-rounded #aichat-input {
    border-radius: 30px;
}

.aichat-theme-rounded .aichat-lead-form input {
    border-radius: 20px;
}

.aichat-theme-rounded .aichat-btn {
    border-radius: 20px;
}

/* Compact Theme */
.aichat-theme-compact .aichat-window {
    width: 320px;
    height: 500px;
    border-radius: 10px;
}

.aichat-theme-compact .aichat-header {
    padding: 12px;
}

.aichat-theme-compact .aichat-avatar {
    width: 30px;
    height: 30px;
}

.aichat-theme-compact .aichat-header-text h4 {
    font-size: 14px;
}

.aichat-theme-compact .aichat-status {
    font-size: 11px;
}

.aichat-theme-compact .aichat-messages {
    padding: 12px;
}

.aichat-theme-compact .aichat-message-content {
    font-size: 13px;
    padding: 8px 12px;
}

.aichat-theme-compact .aichat-bubble {
    width: 50px;
    height: 50px;
}

@media (max-width: 480px) {
    .aichat-theme-compact .aichat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
    }
}

/* ===========================
   WIDGET ANIMATIONS
   =========================== */

/* Slide Animation (Default) */
.aichat-animation-slide .aichat-window {
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade Animation */
.aichat-animation-fade .aichat-window {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Bounce Animation */
.aichat-animation-bounce .aichat-window {
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* No Animation */
.aichat-animation-none .aichat-window {
    animation: none;
}

/* Custom Avatar Support */
.aichat-custom-avatar .aichat-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Chat Bubble Bounce Animation */
@keyframes bubbleBounce {
    0%, 100% {
        transform: scale(1);
    }
    10%, 30% {
        transform: scale(1.15);
    }
    20%, 40% {
        transform: scale(1.05);
    }
}

.aichat-bubble.bounce-notification {
    animation: bubbleBounce 0.6s ease-in-out;
}

/* Pulse animation for unread badge */
@keyframes pulseBadge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 4px rgba(255, 68, 68, 0);
    }
}

.aichat-unread-badge.has-unread {
    animation: pulseBadge 2s infinite;
}

/* Custom Bubble Logo */
.aichat-bubble-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    background: white;
    padding: 8px;
    box-sizing: border-box;
}

.aichat-bubble.has-custom-logo {
    padding: 7px;
    overflow: visible;
    box-sizing: border-box;
}

/* ===========================
   OFFLINE STATE STYLES
   =========================== */

/* Offline bubble indicator */
.aichat-bubble.aichat-offline::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #9ca3af;
    border-radius: 50%;
    border: 2px solid white;
}

/* Offline notice in chat */
.aichat-offline-notice {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
    border: 1px solid #d1d5db;
}

.aichat-offline-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.aichat-offline-notice h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    line-height: 1.5;
}

.aichat-next-available {
    margin: 12px 0 0 0;
    font-size: 13px;
    color: #6b7280;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
}

.aichat-next-available strong {
    color: #059669;
}

.aichat-offline-hint {
    margin: 12px 0 0 0;
    font-size: 12px;
    color: #9ca3af;
}

/* Online indicator (when available) */
.aichat-bubble:not(.aichat-offline)::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse-online 2s infinite;
}

@keyframes pulse-online {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}