:root {
    --sl-primary: #1a6ed8;
    --sl-primary-dk: #155bbf;
    --sl-radius: 16px;
    --sl-shadow: 0 8px 40px rgba(0, 0, 0, .18);
    --sl-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --sl-bg: #ffffff;
    --sl-bg2: #f4f7fb;
    --sl-text: #1a1a2e;
    --sl-text-muted: #6b7280;
    --sl-border: #e5e7eb;
    --sl-bot-bubble: #f0f4ff;
    --sl-user-bubble: var(--sl-primary);
    --sl-w: 370px;
    --sl-h: 540px;
}

/* ---- Tooltip ---- */
#starline-tooltip {
    position: fixed;
    bottom: 108px;
    right: 20px;
    width: 300px;
    background: linear-gradient(135deg, var(--sl-tt-color1, #6a85d8) 0%, var(--sl-tt-color2, #8b5cbf) 100%);
    border-radius: 18px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .22), 0 4px 16px rgba(100, 80, 200, .25);
    z-index: 999997;
    font-family: var(--sl-font);
    overflow: visible;
    animation: slTooltipFloat 3s ease-in-out infinite;
}

/* Avatar overlapping from top-left */
#starline-tooltip-avatar {
    position: absolute;
    top: -22px;
    left: -10px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--sl-primary, #1a6ed8);
    border: 3px solid #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

#starline-tooltip-avatar svg {
    width: 100%;
    height: 100%;
}

/* Header bar with title + close */
#starline-tooltip-header {
    background: rgba(0, 0, 0, .18);
    border-radius: 18px 18px 0 0;
    padding: 10px 12px 10px 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
}

#starline-tooltip-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .3px;
}

#starline-tooltip-close {
    background: rgba(255, 255, 255, .22);
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
    line-height: 1;
    padding: 0;
}

#starline-tooltip-close:hover {
    background: rgba(255, 255, 255, .4);
}

/* Body text */
#starline-tooltip-body {
    padding: 14px 16px 10px;
    background: var(--sl-tt-body-bg, transparent);
}

#starline-tooltip-text {
    font-size: 13.5px;
    color: var(--sl-tt-body-text, rgba(255, 255, 255, .92));
    line-height: 1.55;
    display: block;
}

/* Quick action buttons row */
#starline-tooltip-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 16px 16px;
}

.sl-tooltip-btn {
    background: rgba(255, 255, 255, .18);
    border: 1.5px solid rgba(255, 255, 255, .4);
    color: #fff;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-family: var(--sl-font);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
    white-space: nowrap;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

.sl-tooltip-btn:hover {
    background: rgba(255, 255, 255, .32);
    border-color: rgba(255, 255, 255, .7);
    transform: translateY(-1px);
}

.sl-tooltip-btn:active {
    transform: translateY(0);
}

/* Floating up-down animation */
@keyframes slTooltipFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-7px);
    }
}

@keyframes slFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Entrance animation applied on show */
#starline-tooltip.sl-tooltip-visible {
    animation: slFadeIn .35s ease forwards, slTooltipFloat 3s ease-in-out 0.35s infinite;
}


/* ---- Toggle button ---- */
#starline-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--sl-toggle, var(--sl-primary));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--sl-shadow);
    z-index: 999999;
    transition: transform .2s, background .2s, filter .2s;
    -moz-animation: ws-pulse 2s infinite;
    -webkit-animation: ws-pulse 2s infinite;
    animation: ws-pulse 2s infinite;
}

#starline-toggle:hover {
    background: var(--sl-toggle, var(--sl-primary));
    filter: brightness(0.88);
    transform: scale(1.07);
}

#starline-toggle:active {
    transform: scale(.95);
}

/* Stop pulse animation when chat is open */
#starline-chat-wrapper.sl-open #starline-toggle {
    -moz-animation: none;
    -webkit-animation: none;
    animation: none;
}

/* Close icon stroke color — controlled via Toggle Button Color settings */
#starline-icon-close {
    color: var(--sl-close-icon, #ffffff);
}

@keyframes ws-pulse {

    0% {
        box-shadow: 0 0 0 0 rgba(88, 120, 243, 1);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(88, 120, 243, 0);
    }

    100% {
        box-shadow: 0 0 0 50px rgba(88, 120, 243, 0);
    }
}

#starline-unread-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--sl-font);
}

/* ---- Chat box ---- */
#starline-chat-box {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: var(--sl-w);
    max-width: calc(100vw - 32px);
    height: var(--sl-h);
    max-height: calc(100vh - 110px);
    background: var(--sl-bg);
    border-radius: var(--sl-radius);
    box-shadow: var(--sl-shadow);
    display: flex;
    flex-direction: column;
    z-index: 999998;
    overflow: hidden;
    font-family: var(--sl-font);
    animation: slSlideIn .25s ease;
}

@keyframes slSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

#starline-header-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, .2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}

#starline-header-avatar svg {
    width: 100%;
    height: 100%;
}

#starline-header-name {
    font-size: 15px;
    font-weight: 600;
}

#starline-header-status {
    font-size: 11px;
    opacity: .85;
    margin-top: 1px;
}

#starline-close-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    opacity: .8;
}

#starline-close-btn:hover {
    opacity: 1;
}

/* ---- Messages ---- */
#starline-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--sl-bg2);
    scroll-behavior: smooth;
}

#starline-messages::-webkit-scrollbar {
    width: 4px;
}

#starline-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.sl-bubble-wrap {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    max-width: 88%;
}

.sl-bubble-wrap.sl-bot {
    align-self: flex-start;
}

.sl-bubble-wrap.sl-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.sl-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sl-primary);
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 2px;
    overflow: hidden;
}

.sl-avatar svg {
    width: 100%;
    height: 100%;
}

.sl-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--sl-text);
    white-space: pre-wrap;
    word-break: break-word;
}

.sl-bot .sl-bubble {
    background: var(--sl-bot-bubble);
    border-bottom-left-radius: 4px;
}

.sl-user .sl-bubble {
    background: var(--sl-user-bubble);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Clickable links inside bot replies (phone, email, URL) */
.sl-bubble .sl-link {
    color: var(--sl-primary);
    text-decoration: underline;
    word-break: break-all;
    font-weight: 500;
}

.sl-bubble .sl-link:hover {
    opacity: .8;
}

/* Typing */
.sl-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: var(--sl-bot-bubble);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.sl-dot {
    width: 7px;
    height: 7px;
    background: var(--sl-primary);
    border-radius: 50%;
    animation: slBounce 1.2s infinite ease-in-out;
    opacity: .7;
}

.sl-dot:nth-child(2) {
    animation-delay: .2s;
}

.sl-dot:nth-child(3) {
    animation-delay: .4s;
}

@keyframes slBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }
}

/* ---- Lead form ---- */
#starline-lead-form {
    padding: 12px 14px;
    background: #fffbeb;
    border-top: 1px solid #fde68a;
    flex-shrink: 0;
}

#starline-lead-intro {
    font-size: 13px;
    color: #92400e;
    margin: 0 0 10px;
    font-weight: 500;
}

#starline-lead-form input {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 7px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--sl-font);
    box-sizing: border-box;
    outline: none;
    transition: border .15s;
}

#starline-lead-form input:focus {
    border-color: var(--sl-primary);
}

#starline-lead-form input.sl-error {
    border-color: #ef4444;
    background: #fff5f5;
}

#sl-lead-error {
    font-size: 12px;
    color: #ef4444;
    margin: 2px 0 6px;
}

.sl-btn-primary {
    padding: 8px 20px;
    background: var(--sl-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: var(--sl-font);
    transition: background .15s;
}

.sl-btn-primary:hover {
    background: var(--sl-primary-dk);
}

.sl-btn-primary:disabled {
    background: #9ca3af;
    cursor: default;
}

/* ---- Input row ---- */
#starline-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--sl-border);
    background: var(--sl-bg);
    flex-shrink: 0;
}

#starline-input {
    flex: 1;
    border: 1px solid var(--sl-border);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--sl-font);
    resize: none;
    outline: none;
    max-height: 110px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border .15s;
}

#starline-input:focus {
    border-color: var(--sl-primary);
}

#starline-input:disabled {
    background: #f3f4f6;
}

#starline-send {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--sl-primary);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
}

#starline-send:hover {
    background: var(--sl-primary-dk);
}

#starline-send:active {
    transform: scale(.93);
}

#starline-send:disabled {
    background: #9ca3af;
    cursor: default;
}

#starline-footer {
    text-align: center;
    font-size: 10px;
    color: var(--sl-text-muted);
    padding: 4px 0 6px;
    background: var(--sl-bg);
    flex-shrink: 0;
}

/* ---- Extra Phone Numbers Toggle ---- */
.sl-more-trigger {
    color: var(--sl-primary);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    margin-left: 4px;
    display: inline-block;
    transition: color 0.15s ease;
}

.sl-more-trigger:hover {
    color: var(--sl-primary-dk);
}

.sl-extra-phone {
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    #starline-chat-box {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    #starline-toggle {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    #starline-tooltip {
        right: 20px;
        transform: translateX(50%);
        bottom: 92px;
        width: calc(100vw - 40px);
        max-width: 300px;
    }

    #starline-tooltip.sl-tooltip-visible {
        animation: slFadeIn .35s ease forwards, slTooltipFloat 3s ease-in-out 0.35s infinite;
    }

    /* Hide floating toggle button on mobile when chat is open
       so it doesn't overlap the input row */
    #starline-chat-wrapper.sl-open #starline-toggle {
        display: none !important;
    }
}