/**
 * AI Chat Widget uchun uslublar
 */

.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Chatni ochish tugmasi */
.ai-chat-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px var(--shadow);
}

.ai-chat-toggle .close-icon {
    display: none;
}

.ai-chat-toggle.open .chat-icon {
    display: none;
}

.ai-chat-toggle.open .close-icon {
    display: block;
}

/* Bildirishnoma */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--gradient-accent);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid var(--white);
}

/* Chat oynasi */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 16px 40px var(--shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10000;
}

/* Sudrab olib borganingizda z-index ni oshiramiz */
.ai-chat-window.dragging {
    z-index: 10001;
    transition: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
}

.ai-chat-widget.open .ai-chat-window {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Chat sarlavhasi */
.ai-chat-header {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    user-select: none;
}

.ai-chat-header:active {
    cursor: grabbing;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ai-chat-info {
    flex: 1;
}

.ai-chat-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-status {
    font-size: 12px;
    opacity: 0.9;
    color: var(--gold);
}

.ai-chat-clear,
.ai-chat-minimize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.ai-chat-clear:hover,
.ai-chat-minimize:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ai-chat-clear {
    margin-right: 4px;
}

.ai-chat-clear:hover {
    background: rgba(255, 59, 48, 0.2);
}

.ai-chat-clear:active {
    background: rgba(255, 59, 48, 0.3);
}

/* Xabarlar maydoni */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--light-gray);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-gray);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Xabarlar */
.ai-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.ai-message-content {
    flex: 1;
    background: var(--white);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    line-height: 1.5;
}

.ai-message-content p {
    margin: 0 0 8px 0;
}

.ai-message-content p:last-child {
    margin-bottom: 0;
}

.ai-message-content strong {
    font-weight: 600;
    color: var(--dark);
}

.ai-message-content a {
    color: var(--gold);
    text-decoration: none;
}

.ai-message-content a:hover {
    text-decoration: underline;
}

.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3 {
    margin: 12px 0 8px 0;
    line-height: 1.3;
}

.ai-message-content h1 {
    font-size: 20px;
    font-weight: 700;
}

.ai-message-content h2 {
    font-size: 18px;
    font-weight: 600;
}

.ai-message-content h3 {
    font-size: 16px;
    font-weight: 600;
}

.ai-message-content li {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 4px;
}

.ai-message-content ul {
    padding-left: 0;
    margin: 8px 0;
}

/* Foydalanuvchi xabarlari */
.user-message {
    flex-direction: row-reverse;
}

.user-message .ai-message-content {
    background: var(--gradient-primary);
    color: var(--white);
}

/* Salomlashish xabari */
.ai-welcome-message {
    display: flex;
    gap: 10px;
}

.ai-welcome-message .ai-message-content {
    background: var(--gradient-accent);
    color: var(--white);
}

/* Yozish indikatori */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Mahsulot havolalari tugmalari */
.product-link.product-button {
    display: inline-block;
    padding: 8px 16px;
    margin: 4px 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    text-decoration: none;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    cursor: pointer;
}

.product-link.product-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.product-link.product-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* Mahsulot popup ko'rinishi */
.product-popup {
    position: fixed;
    z-index: 10002;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 0;
    max-width: 350px;
    animation: popupSlideIn 0.2s ease;
    cursor: default;
    pointer-events: auto;
}

.product-popup:hover {
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.25);
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-popup-content {
    display: flex;
    flex-direction: column;
}

.product-popup-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
}

.product-popup-info {
    padding: 15px;
}

.product-popup-info h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
}

.product-popup-info p {
    margin: 6px 0;
    font-size: 14px;
    color: #4a5568;
}

.product-category {
    color: #718096;
    font-size: 13px;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin: 10px 0 !important;
}

.product-size, .product-color, .product-material {
    font-size: 13px;
    color: #718096;
}

.product-stock {
    font-weight: 600;
    margin-top: 10px !important;
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
}

.product-stock.in-stock {
    background: #d4edda;
    color: #155724;
}

.product-stock.out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

/* Chat bildirish nomalar */
.chat-notification {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    margin: 10px 0;
    animation: notificationSlideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mahsulot kartalari */
.product-card {
    margin: 10px 0;
    animation: messageSlideIn 0.3s ease;
}

.product-card-content {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.product-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.no-image {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #718096;
    font-size: 14px;
    font-weight: 500;
}

.product-card-info {
    padding: 12px;
}

.product-card-name {
    margin: 0 0 8px 0;
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.3;
}

.product-card-price {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin: 8px 0;
}

.product-card-size,
.product-card-color {
    font-size: 13px;
    color: #718096;
    margin: 4px 0;
}

.product-card-actions {
    margin-top: 12px;
}

.product-card-button {
    display: inline-block;
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    text-align: center;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.product-card-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Kiritish maydoni */
.ai-chat-input-wrapper {
    padding: 16px;
    background: var(--white);
    border-top: 1px solid var(--border-gray);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid var(--border-gray);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    max-height: 150px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--gold);
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow);
}

.ai-chat-send:active {
    transform: scale(0.95);
}

/* Moslashuvchanlik */
@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        max-height: 600px;
    }
}

@media (max-width: 360px) {
    .ai-chat-toggle {
        width: 50px;
        height: 50px;
    }
    
    .ai-chat-widget {
        bottom: 15px;
        right: 15px;
    }
}
