/* =============================================================================
   Sitewalk AI Chat Widget  —  sacw-*  BEM namespace
   All rules are scoped under .sacw-root for specificity over theme styles.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Keyframes
   --------------------------------------------------------------------------- */

@keyframes sacw-pulse {
    0%   { transform: scale(1);   opacity: 0.6; }
    70%  { transform: scale(1.9); opacity: 0;   }
    100% { transform: scale(1.9); opacity: 0;   }
}

@keyframes sacw-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0);   }
}

@keyframes sacw-bounce {
    0%, 80%, 100% { transform: translateY(0);   opacity: 0.4; }
    40%           { transform: translateY(-6px); opacity: 1;   }
}

/* ---------------------------------------------------------------------------
   Root
   --------------------------------------------------------------------------- */

.sacw-root {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a1a;
    box-sizing: border-box;
}

.sacw-root *,
.sacw-root *::before,
.sacw-root *::after {
    box-sizing: inherit;
}

/* ---------------------------------------------------------------------------
   Backdrop
   --------------------------------------------------------------------------- */

.sacw-root .sacw-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: transparent;
}

/* ---------------------------------------------------------------------------
   Panel
   --------------------------------------------------------------------------- */

.sacw-root .sacw-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 450px;
	height: 100%;
	min-height: 400px;
	max-height: calc(70vh - 120px);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    transition: opacity 240ms ease, transform 240ms ease;
    pointer-events: none;
}

.sacw-root.sacw-is-open .sacw-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */

.sacw-root .sacw-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9) 0%,
        var(--sacw-gradient-color2, #3b7bbf) 50%,
        var(--sacw-gradient-color3, #2c6aa0) 100%);
    color: #fff;
    min-height: 62px;
}

.sacw-root .sacw-header__logo {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
}

.sacw-root .sacw-header__logo-img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.5);
    display: block;
}

.sacw-root .sacw-header__logo-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.4);
    font-size: 18px;
    color: #fff;
}

.sacw-root .sacw-header__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sacw-root .sacw-header__title {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    color: #fff;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
}

.sacw-root .sacw-header__subtitle {
    font-size: 12px;
    opacity: 0.85;

    line-height: 1.3;
    color: #fff;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
}

.sacw-root .sacw-header__close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #fff;
    opacity: 0.8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 150ms, background 150ms;
    line-height: 1;
    box-shadow: none;
    text-shadow: none;
}

.sacw-root .sacw-header__close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ---------------------------------------------------------------------------
   Privacy screen
   --------------------------------------------------------------------------- */

.sacw-root .sacw-privacy {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /*justify-content: center;*/
    gap: 16px;
    padding: 24px 20px;
    overflow-y: auto;
    background: #fff;
}

.sacw-root .sacw-privacy__content {
    font-size: 13px;
    color: #555;
    line-height: 1.65;
    text-align: left;
    width: 100%;
}

.sacw-root .sacw-privacy__content a {
    color: var(--sacw-primary-color, #4a90d9);
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.sacw-root .sacw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: 24px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: filter 150ms, transform 100ms;
    text-decoration: none;
    box-shadow: none;
}

.sacw-root .sacw-btn:active {
    transform: scale(0.97);
}

.sacw-root .sacw-btn--primary {
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9),
        var(--sacw-gradient-color3, #2c6aa0));
    color: #fff;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.35);
}

.sacw-root .sacw-btn--primary:hover {
    filter: brightness(1.08);
    color: #fff;
    text-decoration: none;
}

/* ---------------------------------------------------------------------------
   Messages container
   --------------------------------------------------------------------------- */

.sacw-root .sacw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    min-height: 200px;
    max-height: calc(100vh - 280px);
    background: #fff;
}

.sacw-root .sacw-messages::-webkit-scrollbar {
    width: 4px;
}

.sacw-root .sacw-messages::-webkit-scrollbar-track {
    background: transparent;
}

.sacw-root .sacw-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* ---------------------------------------------------------------------------
   Message rows
   --------------------------------------------------------------------------- */

.sacw-root .sacw-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: sacw-msg-in 200ms ease both;
}

.sacw-root .sacw-message--user {
    flex-direction: row-reverse;
}

.sacw-root .sacw-message--assistant {
    flex-direction: row;
}

.sacw-root .sacw-message__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 78%;
}

.sacw-root .sacw-message--user .sacw-message__body {
    align-items: flex-end;
}

.sacw-root .sacw-message--assistant .sacw-message__body {
    align-items: flex-start;
}

/* ---------------------------------------------------------------------------
   Avatars
   --------------------------------------------------------------------------- */

.sacw-root .sacw-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    align-self: flex-end;
    margin-bottom: 2px;
}

.sacw-root .sacw-avatar__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sacw-root .sacw-avatar__fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9),
        var(--sacw-gradient-color3, #2c6aa0));
    color: #fff;
    font-size: 13px;
}

.sacw-root .sacw-avatar--user {
    background: linear-gradient(135deg, #6c757d, #495057);
}

.sacw-root .sacw-avatar--user .el-icon-user {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Chat bubbles
   --------------------------------------------------------------------------- */

.sacw-root .sacw-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    background-clip: unset;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
}

.sacw-root .sacw-message--assistant .sacw-bubble {
    background: #f0f2f5;
    color: #1a1a1a;
    border-radius: 18px 18px 18px 4px;
}

.sacw-root .sacw-message--user .sacw-bubble {
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9),
        var(--sacw-gradient-color3, #2c6aa0));
    color: #fff;
    border-radius: 18px 4px 18px 18px;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

/* Reset any theme text-gradient tricks inside bubbles */
.sacw-root .sacw-message--assistant .sacw-bubble * {
    -webkit-text-fill-color: unset;
    background-clip: unset;
    -webkit-background-clip: unset;
}

.sacw-root .sacw-message--assistant .sacw-bubble p { color: #1a1a1a; margin: 0 0 8px 0; }
.sacw-root .sacw-message--assistant .sacw-bubble p:first-child { margin-top: 0; }
.sacw-root .sacw-message--assistant .sacw-bubble p:last-child  { margin-bottom: 0; }
.sacw-root .sacw-message--assistant .sacw-bubble li { margin-bottom: 3px; }
.sacw-root .sacw-message--assistant .sacw-bubble a { color: var(--sacw-primary-color, #4a90d9)!important; }
.sacw-root .sacw-message--assistant .sacw-bubble ul,
.sacw-root .sacw-message--assistant .sacw-bubble ol {
    padding-left: 18px;
    margin: 4px 0;
    color: #1a1a1a;
}

.sacw-root .sacw-message--user .sacw-bubble * {
    color: #fff;
    -webkit-text-fill-color: #fff;
}

/* ---------------------------------------------------------------------------
   Typing indicator bubble
   --------------------------------------------------------------------------- */

.sacw-root .sacw-bubble--typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    background: #f0f2f5;
    border-radius: 18px 18px 18px 4px;
    width: fit-content;
}

.sacw-root .sacw-bubble--typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #888;
    animation: sacw-bounce 1.2s ease-in-out infinite;
}

.sacw-root .sacw-bubble--typing span:nth-child(1) { animation-delay: 0s;    }
.sacw-root .sacw-bubble--typing span:nth-child(2) { animation-delay: 0.18s; }
.sacw-root .sacw-bubble--typing span:nth-child(3) { animation-delay: 0.36s; }

.sacw-root .sacw-message--typing {
    animation: none;
}

/* ---------------------------------------------------------------------------
   Snippet chips
   --------------------------------------------------------------------------- */

.sacw-root .sacw-snippets {
    max-width: 100%;
}

.sacw-root .sacw-snippets__scroll {
    display: flex;
    gap: 6px;
	flex-wrap: wrap;
    overflow-x: auto;
    padding-bottom: 2px;
}

.sacw-root .sacw-snippets__scroll::-webkit-scrollbar { display: none; }

.sacw-root .sacw-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 20px;
    border: 1.5px solid #d8dde5;
    background: #fff;
    color: #444;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 150ms, box-shadow 150ms, transform 120ms;
    cursor: pointer;
}

.sacw-root .sacw-chip:hover {
    border-color: var(--sacw-primary-color, #4a90d9)!important;
    color: var(--sacw-primary-color, #4a90d9)!important;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.18)!important;
    text-decoration: none!important;
}

.sacw-root .sacw-chip__icon {
    font-size: 13px;
    opacity: 0.7;
}

/* ---------------------------------------------------------------------------
   New chat / link button
   --------------------------------------------------------------------------- */

.sacw-root .sacw-new-chat {
    text-align: center;
    padding: 4px 0 6px;
}

.sacw-root .sacw-link-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 150ms, background 150ms;
    box-shadow: none;
}

.sacw-root .sacw-link-btn:hover {
    color: var(--sacw-primary-color, #4a90d9);
    background: #f5f7fa;
}

.sacw-root .sacw-link-btn i {
    font-size: 13px;
}

/* ---------------------------------------------------------------------------
   Input area
   --------------------------------------------------------------------------- */

.sacw-root .sacw-input-area {
    flex-shrink: 0;
    padding: 10px 12px 14px;
    background: #fff;
    border-top: 1px solid #eef0f3;
}

.sacw-root .sacw-input-pill {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    background: #f5f7fa;
    border: 1.5px solid #e4e7ed;
    border-radius: 24px;
    padding: 5px 5px 5px 8px;
    transition: border-color 200ms, box-shadow 200ms;
}

.sacw-root .sacw-input-pill:focus-within {
    border-color: var(--sacw-primary-color, #4a90d9);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.12);
    background: #fff;
}

.sacw-root .sacw-input-pill__textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: #1a1a1a;
    padding: 5px 4px;
    min-height: 34px;
    max-height: 110px;
    overflow-y: auto;
    box-shadow: none;
	margin: 0;
}

.sacw-root .sacw-input-pill__textarea::placeholder {
    color: #b0b8c4;
}

.sacw-root .sacw-input-pill__btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 150ms, color 150ms, transform 100ms;
    align-self: flex-end;
    box-shadow: none;
    text-shadow: none;
    line-height: 1;
}

.sacw-root .sacw-input-pill__btn:active {
    transform: scale(0.92);
}

.sacw-root .sacw-input-pill__btn--mic {
    background: transparent;
    color: #888;
}

.sacw-root .sacw-input-pill__btn--mic:hover {
    background: #eef0f3;
    color: #555;
}

.sacw-root .sacw-input-pill__btn--mic.sacw-input-pill__btn--active {
    background: #fee2e2;
    color: #dc2626;
}

.sacw-root .sacw-input-pill__btn--send {
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9),
        var(--sacw-gradient-color3, #2c6aa0));
    color: #fff;
    box-shadow: 0 2px 6px rgba(74, 144, 217, 0.35);
}

.sacw-root .sacw-input-pill__btn--send:hover:not(:disabled) {
    filter: brightness(1.1);
    color: #fff;
}

.sacw-root .sacw-input-pill__btn--send:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
    filter: none;
}

/* ---------------------------------------------------------------------------
   FAB — Floating Action Button
   --------------------------------------------------------------------------- */

.sacw-root .sacw-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10001;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9),
        var(--sacw-gradient-color3, #2c6aa0));
    color: #fff;
    box-shadow: 0 4px 16px rgba(74, 144, 217, 0.45), 0 2px 4px rgba(0,0,0,0.12);
    transition: transform 200ms ease, box-shadow 200ms ease, filter 150ms;
    padding: 0;
    margin: 0;
    text-shadow: none;
    outline: none;
}

.sacw-root .sacw-fab:hover {
    filter: brightness(1.1);
    box-shadow: 0 6px 20px rgba(74, 144, 217, 0.55), 0 2px 6px rgba(0,0,0,0.14);
    transform: translateY(-2px);
    color: #fff;
    background: linear-gradient(135deg,
        var(--sacw-primary-color, #4a90d9),
        var(--sacw-gradient-color3, #2c6aa0));
}

.sacw-root .sacw-fab:active {
    transform: scale(0.94);
}

/* Icon crossfade */
.sacw-root .sacw-fab__icon {
    position: absolute;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 200ms ease, transform 200ms ease;
    color: #fff;
    line-height: 1;
}

.sacw-root .sacw-fab__icon--chat {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.sacw-root .sacw-fab__icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.sacw-root .sacw-fab--open .sacw-fab__icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.sacw-root .sacw-fab--open .sacw-fab__icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Pulse ring */
.sacw-root .sacw-fab__pulse-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--sacw-primary-color, #4a90d9);
    opacity: 0;
    pointer-events: none;
}

.sacw-root .sacw-fab--pulse .sacw-fab__pulse-ring {
    animation: sacw-pulse 2s ease-out 3;
}

/* ---------------------------------------------------------------------------
   Responsive — mobile
   --------------------------------------------------------------------------- */

@media (max-width: 440px) {
    .sacw-root .sacw-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 84px;
        border-radius: 16px;
    }

    .sacw-root .sacw-fab {
        right: 16px;
        bottom: 16px;
    }
}


