/**
 * AI Chat Widget Styles
 * Modern, responsive chat interface
 */

/* ============================================================================
   CHAT WIDGET CONTAINER
   ============================================================================ */

.aichat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================================================
   TOGGLE BUTTON
   ============================================================================ */

.aichat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    position: relative;
}

.aichat-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.aichat-toggle-btn:active {
    transform: scale(0.95);
}

.aichat-close-icon {
    font-size: 36px;
    line-height: 1;
    font-weight: 300;
}

/* ============================================================================
   CHAT WINDOW
   ============================================================================ */

.aichat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* ============================================================================
   HEADER
   ============================================================================ */

.aichat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

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

.aichat-avatar svg {
    width: 24px;
    height: 24px;
}

.aichat-assistant-name {
    font-weight: 600;
    font-size: 16px;
}

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

.aichat-minimize-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.aichat-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================================================
   MESSAGES AREA
   ============================================================================ */

.aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7f8fc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.aichat-messages::-webkit-scrollbar {
    width: 6px;
}

.aichat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.aichat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* ============================================================================
   MESSAGE BUBBLES
   ============================================================================ */

.aichat-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

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

.aichat-message-assistant {
    align-self: flex-start;
}

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

.aichat-message-system {
    align-self: center;
}

.aichat-message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aichat-message-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.aichat-message-content {
    max-width: 75%;
}

.aichat-message-user .aichat-message-content {
    max-width: 75%;
}

.aichat-message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    color: #2d3748;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.aichat-message-user .aichat-message-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.aichat-message-system .aichat-message-text {
    background: #e6fffa;
    color: #234e52;
    text-align: center;
    font-size: 13px;
    border: 1px solid #81e6d9;
}

.aichat-message-time {
    font-size: 11px;
    color: #718096;
    margin-top: 4px;
    padding: 0 4px;
}

.aichat-message-user .aichat-message-time {
    text-align: right;
}

/* ============================================================================
   TYPING INDICATOR
   ============================================================================ */

.aichat-typing {
    padding: 0 20px 10px 20px;
    display: flex;
    gap: 4px;
    align-items: center;
}

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

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

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

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

/* ============================================================================
   INPUT AREA
   ============================================================================ */

.aichat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
}

.aichat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.aichat-input:focus {
    border-color: #667eea;
}

.aichat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.aichat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.aichat-send-btn:active {
    transform: scale(0.95);
}

/* ============================================================================
   PRODUCT CARDS
   ============================================================================ */

.aichat-products {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.aichat-product-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 12px;
    transition: transform 0.2s;
}

.aichat-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.aichat-product-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.aichat-product-info {
    flex: 1;
    min-width: 0;
}

.aichat-product-name {
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.aichat-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}

.aichat-product-original-price {
    font-size: 13px;
    color: #a0aec0;
    text-decoration: line-through;
    margin-left: 6px;
    font-weight: 400;
}

.aichat-product-stock {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.aichat-product-stock.in-stock {
    color: #22543d;
    background: #c6f6d5;
}

.aichat-product-stock.out-of-stock {
    color: #742a2a;
    background: #fed7d7;
}

.aichat-product-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.aichat-btn-add-cart,
.aichat-btn-view {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
    white-space: nowrap;
}

.aichat-btn-add-cart {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.aichat-btn-add-cart:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.aichat-btn-add-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.aichat-btn-view {
    background: white;
    color: #667eea;
    border: 1px solid #667eea;
    display: block;
}

.aichat-btn-view:hover {
    background: #f7fafc;
}

/* ============================================================================
   RESPONSIVE - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
    .aichat-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .aichat-toggle-btn {
        width: 56px;
        height: 56px;
        position: fixed;
        bottom: 10px;
        right: 10px;
        left: auto;
    }

    .aichat-window {
        width: 100%;
        height: calc(100vh - 80px);
        bottom: 76px;
        right: 0;
        left: 0;
        max-height: 100vh;
        border-radius: 12px 12px 0 0;
    }

    .aichat-message-content {
        max-width: 85%;
    }

    .aichat-product-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .aichat-product-image {
        width: 100%;
        height: 150px;
    }

    .aichat-product-actions {
        flex-direction: row;
        width: 100%;
    }

    .aichat-btn-add-cart,
    .aichat-btn-view {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .aichat-window {
        height: calc(100vh - 70px);
        bottom: 66px;
    }

    .aichat-toggle-btn {
        width: 50px;
        height: 50px;
    }

    .aichat-header {
        padding: 12px;
    }

    .aichat-messages {
        padding: 12px;
        gap: 12px;
    }

    .aichat-input-area {
        padding: 12px;
    }
}

/* ============================================================================
   ANIMATIONS & TRANSITIONS
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
