/* SalesFundaa live chat – scoped to #sf-chat-root so site-wide button CSS cannot override */
#sf-chat-root.sf-chat-root {
    --sf-chat-primary: #28a745;
    --sf-chat-primary-dark: #1e7e34;
    --sf-chat-width: 360px;
    --sf-chat-height: 560px;
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 99999;
    font-family: 'Lato', 'PT Sans', Arial, sans-serif;
}

#sf-chat-root .sf-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #28a745;
    background: var(--sf-chat-primary);
    color: #fff;
    font-size: 22px;
    line-height: 56px;
    padding: 0;
    text-transform: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sf-chat-root .sf-chat-toggle .fa,
#sf-chat-root .sf-chat-toggle-icon {
    color: #fff;
    fill: currentColor;
    width: 26px;
    height: 26px;
    max-width: 26px;
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}

#sf-chat-root .sf-chat-toggle:hover {
    background: #1e7e34;
    background: var(--sf-chat-primary-dark);
    color: #fff;
    border: none;
    transform: scale(1.05);
}

#sf-chat-root .sf-chat-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 68px;
    width: var(--sf-chat-width);
    max-width: calc(100vw - 24px);
    height: var(--sf-chat-height);
    max-height: calc(100vh - 84px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden;
}

#sf-chat-root .sf-chat-panel.sf-chat-open {
    display: flex;
}

#sf-chat-root .sf-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 14px;
    background: #28a745;
    background: var(--sf-chat-primary);
    color: #fff;
}

#sf-chat-root .sf-chat-title {
    font-size: 16px;
    display: block;
}

#sf-chat-root .sf-chat-subtitle {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 2px;
}

#sf-chat-root .sf-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#sf-chat-root .sf-chat-end-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.7);
    color: #fff;
    font-size: 11px;
    line-height: 1.2;
    padding: 4px 8px;
    border-radius: 12px;
    cursor: pointer;
    text-transform: none;
}

#sf-chat-root .sf-chat-end-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: #fff;
}

#sf-chat-root .sf-chat-feedback-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: bold;
    color: #222;
}

#sf-chat-root .sf-chat-stars {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

#sf-chat-root .sf-chat-star {
    background: transparent;
    border: none;
    color: #d1d5db;
    font-size: 22px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    text-transform: none;
}

#sf-chat-root .sf-chat-star.is-on,
#sf-chat-root .sf-chat-star:hover {
    color: #f5b301;
    background: transparent;
    border: none;
}

#sf-chat-root .sf-chat-skip-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 12px;
    padding: 6px 0;
    cursor: pointer;
    text-transform: none;
}

#sf-chat-root .sf-chat-skip-btn:hover {
    color: #111;
    background: transparent;
    border: none;
}

#sf-chat-root.sf-chat-root button.sf-chat-close {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: none;
    color: #fff;
    line-height: 1;
    cursor: pointer;
    text-transform: none;
    outline: none;
}

#sf-chat-root.sf-chat-root button.sf-chat-close svg {
    display: block;
    width: 14px;
    height: 14px;
    fill: currentColor;
    pointer-events: none;
}

#sf-chat-root.sf-chat-root button.sf-chat-close:hover,
#sf-chat-root.sf-chat-root button.sf-chat-close:focus {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
    border: none;
    box-shadow: none;
}

#sf-chat-root .sf-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f7f7f7;
    font-size: 13px;
}

#sf-chat-root .sf-chat-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

#sf-chat-root .sf-chat-row-user {
    align-items: flex-end;
}

#sf-chat-root .sf-chat-row-agent,
#sf-chat-root .sf-chat-row-typing {
    align-items: flex-start;
}

#sf-chat-root .sf-chat-row-system {
    align-items: center;
}

#sf-chat-root .sf-chat-msg {
    padding: 8px 10px;
    border-radius: 8px;
    max-width: 92%;
    word-wrap: break-word;
}

#sf-chat-root .sf-chat-meta {
    font-size: 11px;
    color: #6b7280;
    margin-top: 3px;
    padding: 0 4px;
    line-height: 1.2;
}

#sf-chat-root .sf-chat-msg-user {
    background: #dcf8c6;
    margin-left: auto;
    text-align: right;
}

#sf-chat-root .sf-chat-msg-agent {
    background: #fff;
    border: 1px solid #dfe7e2;
    margin-right: auto;
    text-align: left;
    white-space: normal;
}

#sf-chat-root .sf-chat-md p {
    margin: 0 0 8px;
}

#sf-chat-root .sf-chat-md p:last-child,
#sf-chat-root .sf-chat-md ul:last-child,
#sf-chat-root .sf-chat-md ol:last-child,
#sf-chat-root .sf-chat-md pre:last-child,
#sf-chat-root .sf-chat-md table:last-child,
#sf-chat-root .sf-chat-md blockquote:last-child {
    margin-bottom: 0;
}

#sf-chat-root .sf-chat-md h1,
#sf-chat-root .sf-chat-md h2,
#sf-chat-root .sf-chat-md h3,
#sf-chat-root .sf-chat-md h4 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

#sf-chat-root .sf-chat-md ul,
#sf-chat-root .sf-chat-md ol {
    margin: 0 0 8px;
    padding-left: 1.25em;
}

#sf-chat-root .sf-chat-md li {
    margin: 0 0 4px;
}

#sf-chat-root .sf-chat-md code {
    font-family: Consolas, Menlo, monospace;
    font-size: 12px;
    background: #eef3ef;
    padding: 1px 4px;
    border-radius: 3px;
}

#sf-chat-root .sf-chat-md pre {
    margin: 0 0 8px;
    padding: 8px;
    background: #eef3ef;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
}

#sf-chat-root .sf-chat-md pre code {
    padding: 0;
    background: none;
}

#sf-chat-root .sf-chat-md blockquote {
    margin: 0 0 8px;
    padding: 4px 0 4px 10px;
    border-left: 3px solid #28a745;
    color: #444;
}

#sf-chat-root .sf-chat-md table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 8px;
    font-size: 12px;
}

#sf-chat-root .sf-chat-md th,
#sf-chat-root .sf-chat-md td {
    border: 1px solid #dfe7e2;
    padding: 4px 6px;
    text-align: left;
}

#sf-chat-root .sf-chat-md hr {
    border: 0;
    border-top: 1px solid #dfe7e2;
    margin: 8px 0;
}

#sf-chat-root .sf-chat-msg-agent strong,
#sf-chat-root .sf-chat-md b {
    font-weight: 700;
}

#sf-chat-root .sf-chat-msg-agent em,
#sf-chat-root .sf-chat-md i {
    font-style: italic;
}

#sf-chat-root .sf-chat-link {
    color: #1e7e34;
    text-decoration: underline;
    word-break: break-all;
}

#sf-chat-root .sf-chat-link:hover {
    color: #145c26;
}

#sf-chat-root .sf-chat-msg-system {
    background: #e9ecef;
    color: #555;
    font-size: 12px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

#sf-chat-root .sf-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 52px;
    padding: 10px 14px;
}

#sf-chat-root .sf-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #28a745;
    opacity: 0.35;
    animation: sf-chat-typing 1.2s infinite ease-in-out;
}

#sf-chat-root .sf-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
#sf-chat-root .sf-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sf-chat-typing {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

#sf-chat-root .sf-chat-body {
    padding: 10px 12px 12px;
    border-top: 1px solid #eee;
    background: #fff;
}

#sf-chat-root .sf-chat-input,
#sf-chat-root .sf-chat-textarea {
    width: 100%;
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    resize: vertical;
    text-transform: none;
}

#sf-chat-root .sf-chat-primary-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #28a745;
    background: var(--sf-chat-primary);
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-transform: none;
}

#sf-chat-root .sf-chat-primary-btn:hover {
    background: #1e7e34;
    background: var(--sf-chat-primary-dark);
    color: #fff;
    border: none;
}

#sf-chat-root .sf-chat-primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#sf-chat-root .sf-chat-alert {
    padding: 8px 12px;
    font-size: 12px;
    color: #842029;
    background: #f8d7da;
    border-top: 1px solid #f5c2c7;
}

@media (max-width: 480px) {
    #sf-chat-root.sf-chat-root {
        right: 10px;
        bottom: 10px;
    }

    #sf-chat-root .sf-chat-panel {
        width: calc(100vw - 20px);
        height: 80vh;
    }
}
