:root {
    --chat-primary: #75ac1d;
    --chat-primary-rgb: 117, 172, 29;
    --chat-primary-hover: color-mix(in srgb, var(--chat-primary) 88%, #000);
    --chat-primary-deep: color-mix(in srgb, var(--chat-primary) 55%, #000);
    --chat-primary-link: color-mix(in srgb, var(--chat-primary) 68%, #000);
    --chat-primary-tint: color-mix(in srgb, var(--chat-primary) 28%, #fff);
    --chat-primary-tint-mid: color-mix(in srgb, var(--chat-primary) 12%, #fff);
    --chat-primary-tint-soft: color-mix(in srgb, var(--chat-primary) 5%, #fff);
}

#proxy-iframe {
    border: none;
    position: absolute;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
}

/* Spouštěč chatu */
#chat-widget-button {
    position: fixed; bottom: 32px; right: 32px;
    width: 48px; height: 48px; padding: 0;
    border: none; border-radius: 50%;
    background-color: var(--chat-primary); color: #fff;
    cursor: pointer;
    box-shadow: rgba(0, 0, 0, 0.06) 0 1px 6px, rgba(0, 0, 0, 0.16) 0 2px 32px;
    z-index: 1001;
    opacity: 0;
    transform: translateY(18px) scale(0.4);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.7s cubic-bezier(0.34, 1.6, 0.64, 1), box-shadow 0.2s ease;
}
#chat-widget-button.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
#chat-widget-button.is-visible:hover {
    transform: scale(1.08);
}
#chat-widget-button.is-visible::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: 50%;
    pointer-events: none;
    animation: chat-launcher-ping 1s ease-out 0.45s 2;
}
@keyframes chat-launcher-ping {
    0% { box-shadow: 0 0 0 0 rgba(var(--chat-primary-rgb), 0.5); }
    100% { box-shadow: 0 0 0 16px rgba(var(--chat-primary-rgb), 0); }
}
.chat-launcher-icon {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.16s linear, transform 0.16s linear;
}
.chat-launcher-icon-open svg { width: 28px; height: 28px; }
.chat-launcher-icon-close {
    opacity: 0;
    transform: rotate(-30deg) scale(0.5);
}
.chat-launcher-icon-close svg { width: 24px; height: 24px; }
#chat-widget-button.is-open .chat-launcher-icon-open {
    opacity: 0;
    transform: rotate(30deg) scale(0.4);
}
#chat-widget-button.is-open .chat-launcher-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}
.chat-icon-dot { fill: var(--chat-primary); }

/* Chatovací okno */
#chat-window {
    display: none; position: fixed; bottom: 96px; right: 32px;
    width: 400px; height: min(680px, calc(100vh - 140px));
    background: #fff; color: #1c1c1c;
    border-radius: 16px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.04);
    flex-direction: column;
    font-family: "Segoe UI", system-ui, sans-serif;
    z-index: 1000;
}
#chat-window, #chat-window * { box-sizing: border-box; }
#chat-window.is-open { animation: chat-window-in 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes chat-window-in {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
#chat-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 14px 16px;
    background: linear-gradient(180deg, var(--chat-primary-tint) 0%, var(--chat-primary-tint-mid) 58%, var(--chat-primary-tint-soft) 100%);
}
.chat-header-avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    background: var(--chat-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7);
}
.chat-header-text { min-width: 0; }
.chat-header-title {
    font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2;
}
.chat-header-status {
    margin-top: 3px; font-size: 13px; font-weight: 500; color: var(--chat-primary-deep);
    display: flex; align-items: center; gap: 6px;
}
.chat-header-status::before {
    content: ""; width: 8px; height: 8px; border-radius: 50%;
    background: var(--chat-primary); box-shadow: 0 0 0 3px rgba(var(--chat-primary-rgb), 0.22);
}
#chat-close {
    margin-left: auto; width: 32px; height: 32px; flex-shrink: 0;
    border: none; border-radius: 50%; background: transparent;
    color: #2a2a2a; font-size: 22px; line-height: 1; cursor: pointer;
}
#chat-close:hover { background: rgba(0, 0, 0, 0.06); }
#chat-messages {
    flex: 1; padding: 8px 16px 16px;
    overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
    background: linear-gradient(180deg, var(--chat-primary-tint-soft) 0%, #fff 72px);
    scrollbar-width: thin; scrollbar-color: #d5d8d0 transparent;
}
#chat-messages::-webkit-scrollbar { width: 8px; }
#chat-messages::-webkit-scrollbar-thumb { background: #d5d8d0; border-radius: 8px; }
.message {
    padding: 10px 14px; max-width: 84%;
    font-size: 14.5px; line-height: 1.45;
    overflow-wrap: anywhere;
}
.user-msg {
    background: var(--chat-primary); color: #fff;
    align-self: flex-end; border-radius: 16px 16px 4px 16px;
}
.bot-msg {
    background: #fff; color: #1c1c1c; align-self: flex-start;
    border-radius: 4px 16px 16px 16px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.message p { margin: 0 0 8px; }
.message p:last-child { margin-bottom: 0; }
.message h1, .message h2, .message h3 { font-size: 15px; line-height: 1.3; margin: 0 0 6px; }
.message ul { margin: 4px 0 8px; padding-left: 18px; }
.message hr { border: none; border-top: 1px solid rgba(0, 0, 0, 0.08); margin: 10px 0; }
.user-msg hr { border-top-color: rgba(255, 255, 255, 0.35); }
.is-thinking { display: flex; align-items: center; gap: 8px; color: #4b5563; }
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
    width: 6px; height: 6px; border-radius: 50%; background: var(--chat-primary);
    animation: thinking-bounce 1s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinking-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
    40% { transform: translateY(-3px); opacity: 1; }
}
#chat-input-area {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px 14px; background: #fff;
    border-top: 1px solid #eef0ea;
}
#chat-input {
    flex: 1; min-width: 0;
    border: 1px solid #e4e6e0; background: #fbfbfa;
    border-radius: 22px; padding: 11px 16px;
    font: inherit; font-size: 14.5px; color: #1c1c1c; outline: none;
}
#chat-input::placeholder { color: #8b9186; }
#chat-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(var(--chat-primary-rgb), 0.18);
}
#send-btn {
    width: 40px; height: 40px; flex-shrink: 0; padding: 0;
    border: none; border-radius: 50%;
    background: var(--chat-primary); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
#send-btn:hover { background: var(--chat-primary-hover); }
.message img { max-width: 100%; border-radius: 12px; margin-top: 8px; display: block; }
.message a { color: var(--chat-primary-link); text-decoration: underline; font-weight: 600; }
.user-msg a { color: #fff; }
@media (max-width: 480px) {
    #chat-window {
        width: calc(100vw - 24px); right: 12px;
        height: min(640px, calc(100vh - 110px)); bottom: 88px;
    }
}
