/* ============================================
   FABBOT CHATBOT - PREMIUM MODERN DESIGN
   Elegant Chat Interface for WooCommerce
   ============================================ */

:root {
    --fabbot-primary-color: #667eea;
    --fabbot-secondary-color: #764ba2;
    --fabbot-primary-dark: #5a67d8;
    --fabbot-primary-light: #818cf8;
    --fabbot-text-primary: #1f2937;
    --fabbot-text-secondary: #6b7280;
    --fabbot-text-muted: #9ca3af;
    --fabbot-bg-light: #f9fafb;
    --fabbot-bg-white: #ffffff;
    --fabbot-bg-chat: #ffffff;
    --fabbot-border: #e5e7eb;
    --fabbot-border-light: #f3f4f6;
    --fabbot-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --fabbot-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --fabbot-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --fabbot-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --fabbot-shadow-glow: 0 0 40px rgba(102, 126, 234, 0.3);
    --fabbot-radius-sm: 8px;
    --fabbot-radius-md: 12px;
    --fabbot-radius-lg: 16px;
    --fabbot-radius-xl: 24px;
    --fabbot-radius-full: 9999px;
    --fabbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   CHAT BUTTON (Floating Action Button)
   ============================================ */

#fabbot-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--fabbot-primary-color) 0%, var(--fabbot-secondary-color) 100%);
    border-radius: var(--fabbot-radius-full);
    border: none;
    cursor: pointer;
    z-index: 99999;
    box-shadow: var(--fabbot-shadow-xl), var(--fabbot-shadow-glow);
    transition: var(--fabbot-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 26px;
    outline: none;
    overflow: hidden;
}

#fabbot-chat-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    border-radius: inherit;
}

#fabbot-chat-button:hover {
    transform: scale(1.08) translateY(-4px);
    box-shadow: 0 24px 40px rgba(102, 126, 234, 0.4);
}

#fabbot-chat-button:active {
    transform: scale(0.95);
}

/* Stop pulse when chat is active */
#fabbot-chat-button.active::after {
    animation: none;
}

/* Pulse animation for attention */
#fabbot-chat-button::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: inherit;
    animation: fabbot-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    z-index: -1;
}

@keyframes fabbot-pulse {
    0%, 100% {
        opacity: 0;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(1.2);
    }
}

/* ============================================
   CHAT WINDOW (Main Container)
   ============================================ */

#fabbot-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 620px;
    max-height: calc(100vh - 48px);
    background: var(--fabbot-bg-white);
    border-radius: var(--fabbot-radius-xl);
    box-shadow: var(--fabbot-shadow-xl), 0 0 80px rgba(0, 0, 0, 0.08);
    display: none;
    flex-direction: column;
    z-index: 100000;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

#fabbot-chat-window.active {
    display: flex;
    animation: fabbot-slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fabbot-slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Position variants */
#fabbot-chat-window.fabbot-position-bottom-left,
#fabbot-chat-button.fabbot-position-bottom-left {
    right: auto;
    left: 24px;
}

/* Button icon toggle */
#fabbot-chat-button .fabbot-icon-chat,
#fabbot-chat-button .fabbot-icon-close {
    transition: var(--fabbot-transition);
    color: white;
}

#fabbot-chat-button .fabbot-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

#fabbot-chat-button.active .fabbot-icon-chat {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

#fabbot-chat-button.active .fabbot-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ============================================
   CHAT HEADER
   ============================================ */

#fabbot-chat-header {
    background: linear-gradient(135deg, var(--fabbot-primary-color) 0%, var(--fabbot-secondary-color) 100%);
    color: white;
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

#fabbot-chat-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

#fabbot-chat-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.fabbot-header-content {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    position: relative;
    z-index: 1;
}

.fabbot-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    border-radius: var(--fabbot-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fabbot-header-text {
    flex: 1;
}

.fabbot-header-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 3px 0;
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.fabbot-header-status {
    font-size: 13px;
    opacity: 0.95;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.fabbot-status-dot {
    width: 8px;
    height: 8px;
    background: #34d399;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
    animation: fabbot-status-pulse 2s ease-in-out infinite;
}

@keyframes fabbot-status-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
}

.fabbot-header-actions {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.fabbot-header-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--fabbot-radius-sm);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--fabbot-transition);
}

.fabbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.fabbot-header-btn:active {
    transform: scale(0.95);
}

.fabbot-header-btn svg {
    width: 18px;
    height: 18px;
    color: white;
    stroke: white;
}

/* ============================================
   CHAT MESSAGES
   ============================================ */

#fabbot-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    background: var(--fabbot-bg-chat);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
#fabbot-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#fabbot-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#fabbot-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--fabbot-radius-full);
}

#fabbot-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Message Wrapper */
.fabbot-message {
    display: flex;
    gap: 10px;
    animation: fabbot-message-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    align-items: flex-end;
}

@keyframes fabbot-message-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Bot Message */
.fabbot-message.bot {
    flex-direction: row;
}

.fabbot-message.bot .fabbot-message-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--fabbot-radius-sm);
    background: linear-gradient(135deg, var(--fabbot-primary-color), var(--fabbot-secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: var(--fabbot-shadow-md);
}

.fabbot-message.bot .fabbot-message-content {
    max-width: 80%;
}

.fabbot-message.bot .fabbot-message-bubble {
    background: var(--fabbot-bg-white);
    color: var(--fabbot-text-primary);
    padding: 14px 18px;
    border-radius: 4px var(--fabbot-radius-lg) var(--fabbot-radius-lg) var(--fabbot-radius-lg);
    box-shadow: var(--fabbot-shadow-sm);
    line-height: 1.55;
    font-size: 14px;
    border: 1px solid var(--fabbot-border-light);
}

/* User Message */
.fabbot-message.user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.fabbot-message.user .fabbot-message-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--fabbot-radius-sm);
    background: var(--fabbot-bg-light);
    border: 1px solid var(--fabbot-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fabbot-text-secondary);
    font-size: 16px;
    flex-shrink: 0;
}

.fabbot-message.user .fabbot-message-content {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.fabbot-message.user .fabbot-message-bubble {
    background: linear-gradient(135deg, var(--fabbot-primary-color), var(--fabbot-secondary-color));
    color: white;
    padding: 14px 18px;
    border-radius: var(--fabbot-radius-lg) 4px var(--fabbot-radius-lg) var(--fabbot-radius-lg);
    box-shadow: var(--fabbot-shadow-md);
    line-height: 1.55;
    font-size: 14px;
}

/* Message Timestamp */
.fabbot-message-time {
    font-size: 11px;
    color: var(--fabbot-text-muted);
    margin-top: 6px;
    padding: 0 6px;
    font-weight: 500;
}

/* Message Links */
.fabbot-message-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.fabbot-message.bot .fabbot-message-bubble a {
    color: var(--fabbot-primary-color);
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.fabbot-typing {
    display: flex;
    gap: 5px;
    padding: 16px 20px;
    background: var(--fabbot-bg-white);
    border-radius: 4px var(--fabbot-radius-lg) var(--fabbot-radius-lg) var(--fabbot-radius-lg);
    box-shadow: var(--fabbot-shadow-sm);
    width: fit-content;
    border: 1px solid var(--fabbot-border-light);
}

.fabbot-typing span {
    width: 8px;
    height: 8px;
    background: var(--fabbot-primary-color);
    border-radius: 50%;
    animation: fabbot-typing 1.4s ease-in-out infinite;
    opacity: 0.4;
}

.fabbot-typing span:nth-child(1) {
    animation-delay: 0s;
}

.fabbot-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.fabbot-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes fabbot-typing {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: translateY(0) scale(1);
    }
    30% {
        opacity: 1;
        transform: translateY(-6px) scale(1.1);
    }
}

/* ============================================
   PRODUCT CARDS
   ============================================ */

.fabbot-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.fabbot-product-card {
    background: var(--fabbot-bg-white);
    border: 1px solid var(--fabbot-border);
    border-radius: var(--fabbot-radius-md);
    padding: 14px;
    display: flex;
    gap: 14px;
    transition: var(--fabbot-transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.fabbot-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--fabbot-primary-color), var(--fabbot-secondary-color));
    opacity: 0;
    transition: opacity 0.2s;
}

.fabbot-product-card:hover {
    box-shadow: var(--fabbot-shadow-lg);
    transform: translateY(-2px);
    border-color: var(--fabbot-primary-light);
}

.fabbot-product-card:hover::before {
    opacity: 1;
}

.fabbot-product-image {
    width: 80px;
    height: 80px;
    border-radius: var(--fabbot-radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--fabbot-bg-light);
    border: 1px solid var(--fabbot-border-light);
}

.fabbot-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.fabbot-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--fabbot-text-primary);
    line-height: 1.35;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fabbot-product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--fabbot-primary-color);
    margin: 4px 0;
}

.fabbot-product-price del {
    color: var(--fabbot-text-muted);
    font-weight: 400;
    font-size: 13px;
    margin-right: 6px;
}

.fabbot-product-description {
    font-size: 12px;
    color: var(--fabbot-text-secondary);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.fabbot-product-stock {
    font-size: 11px;
    font-weight: 600;
    margin-top: auto;
    padding-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.fabbot-product-stock.in-stock {
    color: #059669;
}

.fabbot-product-stock.out-of-stock {
    color: #dc2626;
}

/* ============================================
   CHAT INPUT
   ============================================ */

#fabbot-chat-input-area {
    padding: 16px;
    background: var(--fabbot-bg-white);
    border-top: 1px solid var(--fabbot-border-light);
    flex-shrink: 0;
}

.fabbot-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--fabbot-bg-light);
    border: 2px solid var(--fabbot-border);
    border-radius: var(--fabbot-radius-lg);
    padding: 6px 6px 6px 16px;
    transition: var(--fabbot-transition);
}

.fabbot-input-wrapper:focus-within {
    border-color: var(--fabbot-primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: var(--fabbot-bg-white);
}

#fabbot-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
    color: var(--fabbot-text-primary);
}

#fabbot-chat-input:focus {
    outline: none;
}

#fabbot-chat-input::placeholder {
    color: var(--fabbot-text-muted);
}

.fabbot-input-actions {
    display: flex;
    gap: 6px;
}

.fabbot-input-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--fabbot-radius-md);
    background: transparent;
    color: var(--fabbot-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--fabbot-transition);
    flex-shrink: 0;
}

.fabbot-input-btn:hover {
    color: var(--fabbot-text-secondary);
    background: var(--fabbot-border-light);
}

#fabbot-send-button {
    background: linear-gradient(135deg, var(--fabbot-primary-color), var(--fabbot-secondary-color));
    color: white;
    box-shadow: var(--fabbot-shadow-md);
}

#fabbot-send-button svg {
    color: white;
    stroke: white;
}

#fabbot-send-button:hover {
    transform: scale(1.05);
    box-shadow: var(--fabbot-shadow-lg);
}

#fabbot-send-button:active {
    transform: scale(0.95);
}

#fabbot-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#fabbot-send-button svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   POWERED BY FOOTER
   ============================================ */

.fabbot-powered-by {
    text-align: center;
    padding: 10px 16px;
    font-size: 11px;
    color: var(--fabbot-text-muted);
    background: var(--fabbot-bg-white);
    border-top: 1px solid var(--fabbot-border-light);
}

.fabbot-powered-by a {
    color: var(--fabbot-primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.fabbot-powered-by a:hover {
    color: var(--fabbot-secondary-color);
}

/* ============================================
   QUICK REPLIES / SUGGESTIONS
   ============================================ */

#fabbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
    background: var(--fabbot-bg-chat);
}

.fabbot-quick-reply {
    background: var(--fabbot-bg-white);
    border: 1px solid var(--fabbot-border);
    border-radius: var(--fabbot-radius-full);
    padding: 8px 16px;
    font-size: 13px;
    color: var(--fabbot-text-primary);
    cursor: pointer;
    transition: var(--fabbot-transition);
    white-space: nowrap;
    font-weight: 500;
}

.fabbot-quick-reply:hover {
    background: var(--fabbot-primary-color);
    color: white;
    border-color: var(--fabbot-primary-color);
    transform: translateY(-2px);
    box-shadow: var(--fabbot-shadow-md);
}

/* ============================================
   ERROR STATE
   ============================================ */

.fabbot-error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--fabbot-radius-md);
    padding: 14px;
    color: #dc2626;
    font-size: 13px;
    line-height: 1.5;
}

.fabbot-error-message a {
    color: #dc2626;
    font-weight: 600;
}

/* ============================================
   LOADING STATE
   ============================================ */

.fabbot-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
}

.fabbot-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--fabbot-border);
    border-top-color: var(--fabbot-primary-color);
    border-radius: 50%;
    animation: fabbot-spin 0.8s linear infinite;
}

@keyframes fabbot-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   WELCOME MESSAGE SPECIAL STYLE
   ============================================ */

.fabbot-welcome-message .fabbot-message-bubble {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 480px) {
    #fabbot-chat-window {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }
    
    #fabbot-chat-button {
        bottom: 20px;
        right: 20px;
        width: 58px;
        height: 58px;
        font-size: 24px;
    }
    
    #fabbot-chat-header {
        padding: 16px;
        border-radius: 0;
    }
    
    .fabbot-avatar {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }
    
    .fabbot-header-title {
        font-size: 16px;
    }
    
    #fabbot-chat-messages {
        padding: 16px 12px;
    }
    
    .fabbot-message.bot .fabbot-message-content,
    .fabbot-message.user .fabbot-message-content {
        max-width: 85%;
    }
    
    .fabbot-product-card {
        padding: 12px;
    }
    
    .fabbot-product-image {
        width: 70px;
        height: 70px;
    }
}

/* ============================================
   ANIMATIONS - ENTRANCE EFFECTS
   ============================================ */

@keyframes fabbot-bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --fabbot-text-primary: #f9fafb;
        --fabbot-text-secondary: #d1d5db;
        --fabbot-text-muted: #9ca3af;
        --fabbot-bg-light: #1f2937;
        --fabbot-bg-white: #111827;
        --fabbot-bg-chat: #0f172a;
        --fabbot-border: #374151;
        --fabbot-border-light: #1f2937;
    }
}

/* Print styles - hide chatbot */
@media print {
    #fabbot-chat-button,
    #fabbot-chat-window {
        display: none !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    #fabbot-chat-button::after {
        animation: none;
    }
}
