:root {
    --widget-primary-color: #667eea;
    --widget-secondary-color: #764ba2;
    --widget-button-start: #667eea;
    --widget-button-end: #764ba2;
    --widget-primary-gradient: linear-gradient(135deg, var(--widget-primary-color) 0%, var(--widget-secondary-color) 100%);
    --widget-button-gradient: linear-gradient(135deg, var(--widget-button-start) 0%, var(--widget-button-end) 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--widget-primary-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: var(--widget-primary-gradient);
    color: white;
    padding: 20px;
    border-radius: 0;
    position: relative;
}

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

.reload-chat-btn {
    position: absolute;
    top: 27%;
    right: 7px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.reload-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) rotate(180deg);
}

.reload-chat-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.reload-chat-btn i {
    transition: transform 0.3s ease;
}

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

.proizvodTipka {
    white-space: nowrap !important;
}

.header-info h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 5px;
}

.status {
    font-size: 14px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-anchor: auto; /* Enable scroll anchoring to reduce jank */
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 70%;
    animation: fadeInUp 0.3s ease-out;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.message.assistant .message-avatar {
    background: var(--widget-primary-gradient);
    color: white;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.message-content ul {
        padding-left: 30px;
    margin: 10px 0;
}

.message.user .message-content {
    align-items: flex-end;
}

.typing-text {
    font-style: italic;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    min-height: 20px; /* Prevent layout shift when content starts streaming */
}

/* Ensure HTML content renders properly in assistant messages */
.message.assistant .message-bubble {
    white-space: normal;
    overflow-wrap: break-word;
    will-change: contents; /* Optimize rendering during streaming */
    contain: layout; /* Reduce layout thrashing */
}

.message.assistant .message-bubble * {
    max-width: 100%;
}

.message.assistant .message-bubble {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 6px;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message-time {
    font-size: 12px;
    color: #64748b;
    padding: 0 4px;
}

/* Enhanced styling for assistant response times */
.message.assistant .message-time {
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

/* Response time color coding */
.message-time.fast-response {
    color: #059669 !important; /* Green for fast responses < 2s */
}

.message-time.medium-response {
    color: #d97706 !important; /* Orange for medium responses 2-5s */
}

.message-time.slow-response {
    color: #dc2626 !important; /* Red for slow responses > 5s */
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.4;
}

#messageInput:focus {
    border-color: #667eea;
}

#messageInput:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
}

.send-button {
    width: 44px;
    height: 44px;
    background: var(--widget-button-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: #64748b;
    font-size: 14px;
}

.typing-indicator.visible {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typingDots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

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

.error-message {
    background: #fee2e2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #dc2626;
    font-size: 14px;
}

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

/* Product card styling */
.singleProduct {
    border-left: 3px solid var(--primary-color, #3498db) !important;
    padding: 12px !important;
    margin-bottom: 12px !important;
    margin-top: 12px !important;
    background: #f8f9fa !important;
    border-radius: 4px;
}

.singleProduct .add_to_cart_button, .singleProduct .viewDetails {
    background-color: #982A2A;
    color: white !important;
    border-radius: 10px !important;
    padding: 10px 10px;
    width: 100%;
    display: block;
    text-align: center;
    text-decoration: none !important;
    margin-bottom: 10px;
} 

.reduziertBis {
        display: block;
    text-align: center;
    margin: 10px 0;
    padding: 5px 10px;
    background-color: #B98118;
    color: white;
    border-radius: 10px;
    font-weight: bold;
}

/* #greetingText {
padding: 0 10px;
} */

#greetingText h3#grafit-consent-title {
margin-bottom: 10px;
padding-bottom: 5px;
border-bottom: 1px solid #dcdcdc;
}

#greetingText #agreeToTerms {
margin-top: 15px;
display: inline-block;
background-color: #059669;
color: white;
border: none;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
}
#greetingText #agreeToTerms:hover {
    background-color: #0f6e50;
}

#greetingText ul {
/* padding-left: 20px; */
margin-top: 15px;
margin-bottom: 15px;
list-style-type: none;
}

#greetingText ul li {
margin-bottom: 3px;
padding-bottom: 3px;
border-bottom: 1px dotted #dcdcdc;
}

.viewDetailsLinkTitle {
    line-height: 1.2em;
}

.price {
    background-color: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 5px;
    display: inline-block;
    padding: 5px 10px;
    margin: 10px 0;
}

.saleBadge {
    background-color: #ffffff;
    border: 1px solid #187832;
    color: #187832;
    padding: 10px;
    border-radius: 10px;
    margin-top: 20px;
    font-weight: bold;
    text-align: center;
}

.stockStatus {
display: block;
color: green;
margin: 15px 0;
}

.singleProduct .add_to_cart_button {
background-color: #187832 !important;
}

.singleProduct a {
    color: var(--primary-color, #3498db);
    text-decoration: none;
}

.singleProduct a:hover {
    text-decoration: underline;
}

/* Animation for product sections appearing during streaming */
.singleProduct.product-appear {
    animation: fadeInUp 0.3s ease-out;
}


/* Timing breakdown styling */
.message-time {
    font-size: 11px;
    color: #999;
    word-break: break-word;
}

.fast-response {
    color: #27ae60 !important;
}

.medium-response {
    color: #f39c12 !important;
}

.slow-response {
    color: #e74c3c !important;
}

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

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .chat-container {
        height: calc(100vh - 20px);
        border-radius: 15px;
    }
    
    .chat-header {
        padding: 15px;
        border-radius: 0;
    }
    
    .header-info h1 {
        font-size: 20px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-input-container {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 90%;
    }
    
    .bot-avatar,
    .message-avatar {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .header-content .bot-avatar {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
}

/* Add to Cart Button States */
.ajax_add_to_cart {
    position: relative;
    transition: all 0.3s ease;
}

.ajax_add_to_cart.loading {
    opacity: 0.6;
    pointer-events: none;
    background: #999 !important;
}

.ajax_add_to_cart.loading::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.ajax_add_to_cart.added {
    background: #28a745 !important;
    border-color: #28a745 !important;
}

.ajax_add_to_cart.added::before {
    content: "✓ ";
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}