/**
 * CADTEC Shop - Chat Widget
 * Agentic Commerce - Verkaufsassistent
 */

/* Chat Button */
.chat-widget-button {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    z-index: 9999;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
}

.chat-widget-button.has-unread::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
}

/* Chat Window */
.chat-widget-window {
    position: fixed;
    bottom: 100px;
    right: 25px;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    animation: chatSlideIn 0.3s ease;
}

.chat-widget-window.open {
    display: flex;
}

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

/* Chat Header */
.chat-widget-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.chat-widget-title {
    flex: 1;
}

.chat-widget-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.chat-widget-title span {
    font-size: 0.8rem;
    opacity: 0.9;
}

.chat-widget-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
}

.chat-widget-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
}

.chat-widget-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-widget-close:hover {
    opacity: 1;
}

/* Chat Messages */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: #f9fafb;
}

.chat-message {
    max-width: 85%;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.from-agent {
    align-self: flex-start;
}

.chat-message.from-user {
    align-self: flex-end;
}

.chat-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.chat-message.from-agent .chat-message-content {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message.from-user .chat-message-content {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-time {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 5px;
}

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

/* Typing Indicator */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions */
.chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chat-quick-action {
    background: #e0e7ff;
    color: #4338ca;
    border: none;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-quick-action:hover {
    background: #c7d2fe;
}

/* Product Card in Chat */
.chat-product-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-top: 10px;
}

.chat-product-card-header {
    display: flex;
    gap: 12px;
}

.chat-product-card-image {
    width: 60px;
    height: 60px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.chat-product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-product-card-info {
    flex: 1;
}

.chat-product-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1f2937;
    margin-bottom: 4px;
}

.chat-product-card-price {
    color: #6366f1;
    font-weight: 700;
    font-size: 1rem;
}

.chat-product-card-price .original {
    color: #9ca3af;
    text-decoration: line-through;
    font-weight: 400;
    font-size: 0.85rem;
    margin-left: 8px;
}

.chat-product-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.chat-product-card-actions button {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-product-card-actions .btn-primary {
    background: #6366f1;
    color: white;
    border: none;
}

.chat-product-card-actions .btn-primary:hover {
    background: #4f46e5;
}

.chat-product-card-actions .btn-secondary {
    background: white;
    color: #6366f1;
    border: 1px solid #6366f1;
}

/* Offer Card */
.chat-offer-card {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #6ee7b7;
    border-radius: 12px;
    padding: 15px;
    margin-top: 10px;
}

.chat-offer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chat-offer-badge {
    background: #065f46;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.chat-offer-valid {
    font-size: 0.8rem;
    color: #065f46;
}

.chat-offer-total {
    font-size: 1.3rem;
    font-weight: 700;
    color: #065f46;
    margin: 10px 0;
}

.chat-offer-discount {
    font-size: 0.85rem;
    color: #047857;
}

/* Chat Input */
.chat-widget-input {
    padding: 15px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
}

.chat-widget-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-widget-input input:focus {
    border-color: #6366f1;
}

.chat-widget-input button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.chat-widget-input button:hover {
    transform: scale(1.05);
}

.chat-widget-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chat-widget-window {
        width: calc(100% - 20px);
        height: calc(100% - 120px);
        right: 10px;
        bottom: 80px;
        border-radius: 12px;
    }
    
    .chat-widget-button {
        width: 55px;
        height: 55px;
        right: 15px;
        bottom: 15px;
    }
}
