#chat-icon {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    background-color: var(--primary-color, #539462);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, background 0.2s ease;
}

#chat-icon:hover {
    transform: scale(1.08);
    background-color: #43784f;
}

#chat-icon.pulse::before {
    content: '';
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(83, 148, 98, 0.35);
    animation: chat-pulse 1.8s ease-out;
    pointer-events: none;
}

@keyframes chat-pulse {
    0%   { transform: scale(1);   opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

#chat-icon-bubble {
    position: fixed;
    bottom: 94px;
    right: 28px;
    background: #fff;
    color: #2c3e50;
    border-radius: 14px 14px 4px 14px;
    padding: 9px 14px;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
    z-index: 9998;
    max-width: 200px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid #e8f5ec;
}

#chat-icon-bubble.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#chat-icon-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #e8f5ec;
    border-bottom: 1px solid #e8f5ec;
    transform: rotate(45deg);
    clip-path: polygon(0 0, 100% 100%, 100% 0);
}

#chat-box {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 340px;
    height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: none;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#chat-box.open {
    display: flex;
}

#chat-header {
    background-color: var(--primary-color, #539462);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

#chat-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
}

#chat-limit-badge {
    display: block;
    font-size: 0.68rem;
    font-weight: 400;
    opacity: 0.88;
    margin-top: 1px;
    letter-spacing: 0.01em;
    color: rgba(255, 255, 255, 0.92);
}

#chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    opacity: 0.85;
    transition: opacity 0.2s;
}

#chat-close:hover {
    opacity: 1;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7f9f7;
}

.chat-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-bubble.bot {
    background: #ffffff;
    color: #2c3e50;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.chat-bubble.bot a {
    color: #539462;
    text-decoration: underline;
    font-weight: 600;
}

.chat-bubble.user {
    background: var(--primary-color, #539462);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-bubble.typing {
    background: #ffffff;
    color: #888;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-style: italic;
    font-size: 0.85rem;
    padding: 8px 12px;
    width: fit-content;
    display: flex;
    align-items: center;
}

.typing-text {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    vertical-align: bottom;
    animation: reveal 2s ease-in-out infinite;
}

@keyframes reveal {
    0%, 10% { clip-path: inset(0 100% 0 0); }
    60%, 100% { clip-path: inset(0 0% 0 0); }
}

#chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

#chat-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#chat-input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.88rem;
    outline: none;
    transition: border 0.2s;
    box-sizing: border-box;
}

#chat-input:focus {
    border-color: var(--primary-color, #539462);
}

#chat-input:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
    opacity: 0.7;
}

#char-counter {
    font-size: 0.68rem;
    color: #718096;
    padding-left: 14px;
    transition: color 0.2s;
    min-height: 1em;
}

#chat-send {
    width: 36px;
    height: 36px;
    background: var(--primary-color, #539462);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
}

#chat-send:hover {
    background: #43784f;
}

#retry-message-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    70%  { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

#retry-message-btn:active {
    transform: scale(0.98) !important;
}

.loading-indicator {
    text-align: center;
    padding: 12px;
    color: #718096;
    font-size: 0.8rem;
    background: #f7f9f7;
    border-radius: 8px;
    margin: 5px 0;
}

.loading-indicator i {
    margin-right: 6px;
}

.chat-loading {
    text-align: center;
    padding: 20px;
    color: #718096;
}

/* ── Chat suggestions — always single-line, horizontally scrollable ── */
#chat-suggestions {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 8px 12px 10px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
    scrollbar-width: none;
    cursor: grab;
}

#chat-suggestions::-webkit-scrollbar {
    display: none;
}

.chat-suggestion-btn {
    background: #f0f7f2;
    color: #2d6a4f;
    border: 1px solid #b7e4c7;
    border-radius: 16px;
    padding: 5px 11px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.12s;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
    line-height: 1.4;
}

.chat-suggestion-btn:hover {
    background: #d8f3dc;
    border-color: #52b788;
    transform: translateY(-1px);
}

.chat-suggestion-btn:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    #chat-box {
        width: calc(100vw - 24px);
        height: calc(100dvh - 100px);
        right: 12px;
        bottom: 12px;
        border-radius: 14px;
    }

    #chat-icon {
        bottom: 20px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    #chat-icon.pulse::before {
        width: 50px;
        height: 50px;
    }

    #chat-icon-bubble {
        right: 14px;
        bottom: 82px;
        max-width: 175px;
        font-size: 0.78rem;
        padding: 8px 12px;
    }

    #chat-icon-bubble::after {
        right: 14px;
    }

    #chat-messages {
        padding: 12px;
        gap: 8px;
    }

    .chat-bubble {
        max-width: 88%;
        font-size: 0.85rem;
        padding: 9px 12px;
    }

    #chat-input-area {
        padding: 8px 10px;
    }

    #chat-input {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    #chat-suggestions {
        padding: 6px 10px 8px;
        gap: 5px;
    }

    .chat-suggestion-btn {
        font-size: 0.72rem;
        padding: 4px 10px;
    }

    #chat-name {
        font-size: 0.88rem;
    }

    #chat-limit-badge {
        font-size: 0.64rem;
    }

    #chat-header {
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    #chat-box {
        width: 100vw;
        height: calc(100dvh - 80px);
        right: 0;
        bottom: 0;
        border-radius: 16px 16px 0 0;
    }

    #chat-icon {
        bottom: 16px;
        right: 14px;
        width: 48px;
        height: 48px;
        font-size: 1.1rem;
    }

    #chat-icon.pulse::before {
        width: 48px;
        height: 48px;
    }

    #chat-icon-bubble {
        right: 12px;
        bottom: 76px;
        max-width: 160px;
        font-size: 0.75rem;
        padding: 7px 11px;
        border-radius: 12px 12px 4px 12px;
    }

    #chat-icon-bubble::after {
        right: 12px;
    }

    .chat-bubble {
        max-width: 92%;
    }

    #chat-suggestions {
        padding: 5px 8px 7px;
        gap: 4px;
    }

    .chat-suggestion-btn {
        font-size: 0.7rem;
        padding: 4px 9px;
    }
}

@media (max-width: 360px) {
    #chat-box {
        height: calc(100dvh - 70px);
    }

    #chat-icon {
        width: 44px;
        height: 44px;
        bottom: 14px;
        right: 12px;
        font-size: 1rem;
    }

    #chat-icon.pulse::before {
        width: 44px;
        height: 44px;
    }

    #chat-icon-bubble {
        max-width: 145px;
        font-size: 0.72rem;
        right: 10px;
        bottom: 70px;
    }
}