#s41-chatbot-widget {
    --s41-primary: #1e40af;
    --s41-primary-dark: #1e3a8a;
    --s41-bg-light: #f8fafc;
    --s41-border: #e2e8f0;
    --s41-msg-bot: #e2e8f0;
    --s41-text: #111;
    --s41-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

#s41-chatbot-widget *, #s41-chatbot-widget *::before, #s41-chatbot-widget *::after {
    box-sizing: border-box;
    margin: 0;
}

/* ── Toggle button ── */
#s41-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--s41-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 99998;
    animation: s41-pulse 3s ease-in-out 2s 3;
}

#s41-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(30, 64, 175, 0.45);
}

#s41-chatbot-toggle svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}

@keyframes s41-pulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(30, 64, 175, 0.35); }
    50% { box-shadow: 0 4px 24px rgba(30, 64, 175, 0.6); }
}

/* ── Chat window ── */
#s41-chatbot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 520px;
    max-height: calc(100dvh - 40px);
    background: #fff;
    border-radius: var(--s41-radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    animation: s41-slideUp 0.25s ease-out;
}

@keyframes s41-slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
#s41-chatbot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--s41-primary);
    color: #fff;
    flex-shrink: 0;
}

.s41-chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.s41-chatbot-header-info {
    flex: 1;
    min-width: 0;
}

.s41-chatbot-header-info strong {
    display: block;
    font-size: 15px;
}

.s41-chatbot-header-info span {
    font-size: 12px;
    opacity: 0.85;
}

#s41-chatbot-phone {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: #22c55e;
    border-radius: 50%;
    animation: s41-fadeIn 0.3s ease;
    flex-shrink: 0;
}

#s41-chatbot-phone svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

#s41-chatbot-phone:hover {
    background: #16a34a;
}

#s41-chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    margin-left: 8px;
    opacity: 0.8;
    transition: opacity 0.15s;
}

#s41-chatbot-close:hover {
    opacity: 1;
}

/* ── Messages ── */
#s41-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--s41-bg-light);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.s41-msg {
    display: flex;
    animation: s41-fadeIn 0.2s ease;
}

@keyframes s41-fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.s41-msg p {
    padding: 10px 16px;
    border-radius: 16px;
    max-width: 82%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.s41-msg-bot {
    justify-content: flex-start;
}

.s41-msg-bot p {
    background: var(--s41-msg-bot);
    color: var(--s41-text);
    border-bottom-left-radius: 4px;
}

.s41-msg-user {
    justify-content: flex-end;
}

.s41-msg-user p {
    background: var(--s41-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── City link button ── */
.s41-city-link {
    display: inline-block;
    padding: 8px 16px;
    background: var(--s41-primary);
    color: #fff;
    border-radius: 16px;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
    cursor: pointer;
}

.s41-city-link:hover {
    background: var(--s41-primary-dark);
    color: #fff;
}

/* ── Locate button ── */
.s41-locate-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #22c55e;
    color: #fff;
    border: none;
    border-radius: 16px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.s41-locate-btn:hover {
    background: #16a34a;
}

.s41-locate-btn:disabled {
    background: #94a3b8;
    cursor: wait;
}

/* ── Typing indicator ── */
.s41-typing-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.s41-typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--s41-msg-bot);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

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

.s41-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.s41-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes s41-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-5px); }
}

.s41-typing-label {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

/* ── Input area ── */
#s41-chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--s41-border);
    background: #fff;
    flex-shrink: 0;
}

#s41-chatbot-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 16px;
    font-family: inherit;
    color: #111;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
}

#s41-chatbot-input:focus {
    border-color: var(--s41-primary);
}

#s41-chatbot-input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
}

#s41-chatbot-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--s41-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

#s41-chatbot-send:hover {
    background: var(--s41-primary-dark);
}

#s41-chatbot-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

#s41-chatbot-send svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* ── Lock page scroll when chat open (mobile only) ── */
@media (max-width: 480px) {
    body.s41-chat-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        top: var(--s41-scroll-top, 0px);
    }
}

/* ── Hidden ── */
.s41-hidden {
    display: none !important;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    #s41-chatbot-window {
        inset: 0;
        width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        overscroll-behavior: none;
    }

    #s41-chatbot-toggle {
        bottom: 16px;
        right: 16px;
    }

    .s41-msg p {
        max-width: 88%;
    }
}
