@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

#kodee-chat-wrapper {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --primary-color: #2563eb;
    --primary-shadow: rgba(37, 99, 235, 0.25);
    --bg-color: rgba(255, 255, 255, 0.98);
    --user-text: #ffffff;
    --bot-bg: #f3f4f6;
    --bot-text: #1f2937;
    --radius-lg: 20px;
    --radius-md: 12px;
    box-sizing: border-box;
    position: fixed; bottom: 0; right: 0; z-index: 99999;
    pointer-events: none;
}

#kodee-chat-wrapper * { box-sizing: border-box; pointer-events: auto; }

/* Tlačítko */
.kodee-toggle-btn {
    position: fixed; bottom: 25px; right: 25px;
    background: var(--primary-gradient) !important; 
    color: white !important; border: none !important; 
    border-radius: 50px !important; padding: 14px 24px !important;
    font-size: 15px !important; font-weight: 600 !important; cursor: pointer;
    box-shadow: 0 4px 20px var(--primary-shadow) !important;
    display: flex; align-items: center; gap: 10px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); 
    z-index: 99999;
}
.kodee-toggle-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 25px var(--primary-shadow) !important; }
.kodee-toggle-btn i { font-size: 18px; }

/* Okno */
.kodee-widget {
    position: fixed; bottom: 90px; right: 25px;
    width: 380px; height: 600px; max-height: 80vh;
    background: var(--bg-color) !important;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 1); border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px -10px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.03);
    display: none; flex-direction: column; overflow: hidden;
    opacity: 0; transform: translateY(20px) scale(0.98);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.kodee-widget.open { opacity: 1; transform: translateY(0) scale(1); }

@media (max-width: 480px) {
    .kodee-widget { width: 92%; right: 4%; bottom: 85px; height: 75vh; }
}

/* Hlavička */
.kodee-header {
    padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; 
    background: rgba(255,255,255,0.95); border-bottom: 1px solid #f1f5f9; flex-shrink: 0;
}
.kodee-title-group { display: flex; align-items: center; gap: 10px; }
.kodee-status-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
.kodee-title { font-weight: 700; font-size: 16px; color: #0f172a; }
.kodee-actions { display: flex; gap: 8px; }
.kodee-action-btn { color: #94a3b8; cursor: pointer; padding: 8px; border-radius: 50%; transition: all 0.2s; font-size: 14px; }
.kodee-action-btn:hover { color: var(--primary-color); background: #f0f9ff; }

/* Body */
.kodee-body { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; scroll-behavior: smooth; position: relative; background: #fff; }
.kodee-body::-webkit-scrollbar { width: 4px; }
.kodee-body::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }

/* Uvítání */
.kodee-welcome { text-align: center; margin-top: 30px; animation: fadeIn 0.5s ease; }
.kodee-logo {
    width: 60px; height: 60px; background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary-color); border-radius: 20px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 26px; margin-bottom: 16px; box-shadow: 0 8px 20px rgba(37, 99, 235, 0.1);
}
.kodee-greeting h3 { margin: 0 0 6px 0; font-size: 18px; color: #1e293b; font-weight: 700; }
.kodee-greeting p { color: #64748b; margin: 0 0 25px 0; font-size: 14px; line-height: 1.5; }

/* Rychlé akce */
.quick-action {
    display: flex; align-items: center; text-align: left; background: white; border: 1px solid #e2e8f0;
    padding: 10px 14px; border-radius: 12px; margin-bottom: 8px; cursor: pointer; transition: all 0.2s;
    color: #475569; font-size: 13px; font-weight: 500;
}
.quick-action:hover { background: #f8fafc; border-color: #cbd5e1; transform: translateX(2px); color: var(--primary-color); }
.quick-action i { margin-right: 10px; font-size: 14px; color: #94a3b8; transition: color 0.2s; }
.quick-action:hover i { color: var(--primary-color); }

/* Zprávy */
.message { max-width: 85%; margin-bottom: 20px; line-height: 1.6; position: relative; animation: slideUp 0.3s ease forwards; word-wrap: break-word; font-size: 14px; }
.message.user {
    align-self: flex-end; background: var(--primary-gradient); color: var(--user-text);
    padding: 12px 16px; border-radius: 18px 18px 4px 18px; 
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.15);
}
.message.bot { align-self: flex-start; width: 100%; max-width: 100%; }

/* Bot prvky */
.bot-info { display: flex; align-items: center; margin-bottom: 6px; gap: 8px; margin-left: 2px; }
.bot-avatar {
    width: 26px; height: 26px; background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary-color); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.bot-name { font-weight: 600; font-size: 12px; color: #64748b; }
.bot-bubble { 
    background: var(--bot-bg); color: var(--bot-text); padding: 14px 18px; 
    border-radius: 4px 18px 18px 18px; display: inline-block; width: fit-content; max-width: 92%;
}
.bot-message-content p { margin: 0 0 8px 0; } .bot-message-content p:last-child { margin: 0; }
.bot-message-content a { color: var(--primary-color); text-decoration: none; font-weight: 600; }
.bot-message-content ul { padding-left: 18px; margin: 6px 0; }

/* --- NOVÝ STYL NAČÍTÁNÍ (UVNITŘ BUBLINY) --- */
.message.loading .bot-bubble {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    background: #f8fafc; border: 1px solid #e2e8f0;
    transition: border-color 0.3s;
    animation: pulseBorder 2s infinite;
}

@keyframes pulseBorder {
    0% { border-color: #e2e8f0; }
    50% { border-color: #94a3b8; }
    100% { border-color: #e2e8f0; }
}

.loading-dots { display: flex; align-items: center; gap: 4px; }
.loading-dot { 
    width: 5px; height: 5px; background: #94a3b8; border-radius: 50%; 
    animation: typingPulse 1.4s infinite ease-in-out both; 
}
.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

.loading-text { 
    font-size: 13px; color: #64748b; font-style: italic; 
    min-width: 60px; transition: opacity 0.3s ease; white-space: nowrap;
}

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

/* Produktové karty (Vertikální seznam) */
.product-stack { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; width: 100%; }
.product-card {
    display: flex; flex-direction: row; background: #ffffff; border: 1px solid #e2e8f0;
    border-radius: 14px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    transition: all 0.2s ease; text-decoration: none; width: 100%; align-items: center; position: relative;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.06); border-color: var(--primary-color); }
.pc-image-wrapper {
    width: 85px; height: 85px; flex-shrink: 0; background: #f8fafc;
    display: flex; align-items: center; justify-content: center; padding: 6px; border-right: 1px solid #f1f5f9;
}
.pc-image-wrapper img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.pc-content { padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; flex-grow: 1; min-width: 0; }
.pc-badge {
    position: absolute; top: 6px; left: 6px; background: var(--primary-gradient);
    color: white; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 6px; z-index: 2;
}
.pc-title { font-size: 13px; font-weight: 600; color: #1e293b; margin-bottom: 4px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-price { font-size: 14px; font-weight: 700; color: var(--primary-color); margin-bottom: 4px; }
.pc-cta { font-size: 11px; font-weight: 600; color: #64748b; display: flex; align-items: center; gap: 4px; margin-top: auto; }
.product-card:hover .pc-cta i { transform: translateX(3px); color: var(--primary-color); }

/* Hodnocení */
.message-rating { display: flex; gap: 12px; margin-top: 6px; margin-left: 2px; opacity: 0; transition: opacity 0.2s; }
.message.bot:hover .message-rating { opacity: 1; }
.message-rating i { cursor: pointer; font-size: 14px; color: #cbd5e1; transition: all 0.2s; }
.message-rating i:hover { color: var(--primary-color); transform: scale(1.1); }
.message-rating i.active { color: var(--primary-color); }

/* Patička */
.kodee-footer { padding: 14px 20px 20px 20px; background: rgba(255,255,255,0.9); border-top: 1px solid #f1f5f9; flex-shrink: 0; }
.input-wrapper {
    position: relative; border: 1px solid #e2e8f0 !important; border-radius: 24px !important; background: white !important;
    display: flex !important; align-items: center !important; padding: 6px 6px 6px 18px !important; min-height: 48px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02) !important; transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrapper:focus-within { border-color: var(--primary-color) !important; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1) !important; }
.input-wrapper textarea {
    border: none !important; box-shadow: none !important; background: transparent !important;
    margin: 0 !important; padding: 0 !important; resize: none !important; width: 100% !important;
    outline: none !important; font-family: 'Inter', sans-serif !important; font-size: 14px !important;
    line-height: 20px !important; color: #334155 !important; max-height: 100px !important;
}
.send-btn {
    background: var(--primary-gradient) !important; border: none !important; width: 36px !important; height: 36px !important;
    border-radius: 50% !important; color: white !important; cursor: pointer !important; display: flex !important; align-items: center !important;
    justify-content: center !important; transition: all 0.3s !important; margin-left: 8px !important; flex-shrink: 0 !important;
    opacity: 0.5; pointer-events: none; transform: scale(0.9); box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.send-btn.active { opacity: 1; pointer-events: all; transform: scale(1); }

/* Powered by */
.kodee-powered {
    display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px;
    font-size: 10px; color: #cbd5e1; font-weight: 500; user-select: none;
}
.kodee-powered img.powered-logo { height: 14px; width: auto; opacity: 0.5; filter: grayscale(100%); transition: opacity 0.2s; }
.kodee-powered:hover img.powered-logo { opacity: 1; filter: grayscale(0%); }
.hidden { display: none !important; }

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



/* --- STYLY PRO OPERÁTORA (Human Takeover) --- */
.message.operator .bot-avatar {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%); /* Růžovo-červený podklad */
    color: #db2777; /* Barva ikony */
}

.message.operator .bot-name {
    color: #db2777;
    font-weight: 700;
}

.message.operator .bot-bubble {
    background: #fdf2f8; /* Světlé pozadí bubliny */
    border: 1px solid #fce7f3;
    color: #831843;
}

/* Jemná animace pro novou zprávu operátora */
.message.operator {
    animation: slideInOperator 0.4s ease forwards;
}

@keyframes slideInOperator {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


/* --- STYLY PRO OPERÁTORA (Human Takeover) --- */
.message.operator .bot-avatar {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%); /* Růžovo-červený podklad */
    color: #db2777; /* Barva ikony */
}

.message.operator .bot-name {
    color: #db2777;
    font-weight: 700;
}

.message.operator .bot-bubble {
    background: #fdf2f8; /* Velmi světlé růžové pozadí */
    border: 1px solid #fce7f3;
    color: #831843;
}

/* Animace pro operátora */
.message.operator {
    animation: slideInOperator 0.4s ease forwards;
}

@keyframes slideInOperator {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- SYSTÉMOVÁ HLÁŠKA (Operátor se připojil) --- */
.system-message-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    text-align: center;
}

.system-message-divider span {
    background: #f1f5f9;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* --- PROAKTIVNÍ BUBLINA (Greeting Bubble) --- */
.kodee-proactive-bubble {
    position: fixed;
    bottom: 90px;
    right: 25px;
    width: 300px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    padding: 16px;
    z-index: 99998;
    display: none;
    flex-direction: column;
    animation: kodeePopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: bottom right;
}

.kodee-proactive-bubble.visible {
    display: flex;
}

/* Šipka dolů */
.kodee-proactive-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 35px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    transform: rotate(45deg);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
}

/* Tlačítko zavřít */
.kodee-pb-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    font-size: 12px;
    transition: all 0.2s;
    border: 1px solid #f1f5f9;
}
.kodee-pb-close:hover { color: #ef4444; transform: scale(1.1); }

/* Obsah bubliny */
.kodee-pb-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.kodee-pb-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.kodee-pb-text {
    font-size: 14px;
    color: #1e293b;
    line-height: 1.4;
    font-weight: 500;
}

/* Tlačítka v bublině */
.kodee-pb-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}
.kodee-pb-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--primary-color);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kodee-pb-btn:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateX(2px);
}
.kodee-pb-btn i { font-size: 10px; opacity: 0.6; }

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

@media (max-width: 480px) {
    .kodee-proactive-bubble { width: 260px; right: 20px; bottom: 85px; }
}