/* ==========================================================================
   SensoChat Widget — Standalone CSS (no UIkit / jQuery dependency)
   Variables --sensochat-* are injected dynamically by the plugin.
   ========================================================================== */

:root {
    --sensochat-primary: #2e75b6;
    --sensochat-primary-rgb: 46, 117, 182;
    --sensochat-secondary: #f0f0f0;
    --sensochat-radius: 12px;
    --sensochat-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    --sensochat-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --sensochat-bottom: 20px;
    --sensochat-icon-size: 56px;
    --sensochat-avatar-size: 48px;
}

/* ---- Container ---- */

#sensochat-widget {
    position: fixed;
    z-index: 99999;
    font-family: var(--sensochat-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

#sensochat-widget *,
#sensochat-widget *::before,
#sensochat-widget *::after {
    box-sizing: border-box;
}

#sensochat-widget.bottom-right {
    bottom: var(--sensochat-bottom);
    right: 20px;
}

#sensochat-widget.bottom-left {
    bottom: var(--sensochat-bottom);
    left: 20px;
}

/* ---- Floating button ---- */

#sensochat-button {
    width: var(--sensochat-icon-size);
    height: var(--sensochat-icon-size);
    border-radius: 50%;
    background: var(--sensochat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    padding: 0;
    animation: sc-ripple 2s ease-out infinite;
}

#sensochat-widget.sc-chat-open #sensochat-button {
    animation: none;
    box-shadow: var(--sensochat-shadow);
}

#sensochat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.2);
}

#sensochat-button svg {
    width: 62%;
    height: 62%;
    fill: currentColor;
}

/* ---- Chat window ---- */

#sensochat-window {
    display: none;
    position: absolute;
    bottom: calc(var(--sensochat-icon-size) + 16px);
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 120px);
    border-radius: var(--sensochat-radius);
    background: #fff;
    box-shadow: var(--sensochat-shadow);
    flex-direction: column;
    overflow: hidden;
}

#sensochat-widget.bottom-right #sensochat-window {
    right: 0;
}

#sensochat-widget.bottom-left #sensochat-window {
    left: 0;
}

#sensochat-window.open {
    display: flex;
}

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

.sc-header {
    background: var(--sensochat-primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sc-header-avatar {
    width: var(--sensochat-avatar-size, 32px);
    height: var(--sensochat-avatar-size, 32px);
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* ---- Welcome bubble ---- */

.sc-welcome-bubble {
    position: absolute;
    bottom: calc(var(--sensochat-icon-size) + 10px);
    width: calc(100vw - 20px);
    max-width: 320px;
    background: #fff;
    box-shadow: var(--sensochat-shadow);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    z-index: 1;
    animation: sc-bubble-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#sensochat-widget.bottom-right .sc-welcome-bubble {
    right: 0;
    border-radius: var(--sensochat-radius) var(--sensochat-radius) 0 var(--sensochat-radius);
    transform-origin: bottom right;
}

#sensochat-widget.bottom-left .sc-welcome-bubble {
    left: 0;
    border-radius: var(--sensochat-radius) var(--sensochat-radius) var(--sensochat-radius) 0;
    transform-origin: bottom left;
}

.sc-welcome-bubble .sc-bubble-avatar {
    width: var(--sensochat-avatar-size);
    height: var(--sensochat-avatar-size);
    min-width: var(--sensochat-avatar-size);
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sc-welcome-bubble .sc-bubble-body {
    flex: 1;
    min-width: 0;
}

.sc-welcome-bubble .sc-bubble-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--sensochat-primary);
    margin-bottom: 4px;
}

.sc-welcome-bubble .sc-bubble-text {
    font-size: 13px;
    color: #333;
    line-height: 1.45;
}

.sc-welcome-bubble .sc-bubble-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sc-welcome-bubble .sc-bubble-close:hover {
    color: #333;
}

@keyframes sc-bubble-in {
    from { opacity: 0; transform: scale(0.6); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes sc-ripple {
    0%   { box-shadow: 0 0 0 0 rgba(var(--sensochat-primary-rgb), 0.6); }
    70%  { box-shadow: 0 0 0 18px rgba(var(--sensochat-primary-rgb), 0); }
    100% { box-shadow: 0 0 0 18px rgba(var(--sensochat-primary-rgb), 0); }
}

.sc-header-name {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sc-header-new,
.sc-header-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
    border-radius: 4px;
}

.sc-header-new:hover,
.sc-header-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.sc-header-close {
    font-size: 20px;
}

/* ---- Messages area ---- */

.sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.sc-msg-bot,
.sc-msg-user {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--sensochat-radius);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.sc-msg-bot {
    background: var(--sensochat-secondary);
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.sc-msg-user {
    background: var(--sensochat-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

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

.sc-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.sc-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: sc-bounce 1.2s infinite ease-in-out;
}

.sc-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.sc-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes sc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-6px); opacity: 1; }
}

/* ---- Link suggestions ---- */

.sc-links {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sc-links-title {
    font-size: 12px;
    color: #888;
    margin-bottom: 2px;
}

.sc-links a {
    color: var(--sensochat-primary);
    text-decoration: none;
    font-size: 13px;
    transition: text-decoration 0.15s;
}

.sc-links a:hover {
    text-decoration: underline;
}

/* ---- Auto-linked URLs in bot messages ---- */

.sc-auto-link {
    color: var(--sensochat-primary);
    text-decoration: underline;
    word-break: break-all;
}

.sc-auto-link:hover {
    opacity: 0.8;
}

/* ---- Phone link in bot messages ---- */

.sc-phone-link {
    color: var(--sensochat-primary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}

.sc-phone-link:hover {
    text-decoration: underline;
}

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

.sc-input-area {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid #e5e5e5;
    gap: 8px;
    flex-shrink: 0;
    background: #fafafa;
}

.sc-input-area input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.15s;
}

.sc-input-area input:focus {
    border-color: var(--sensochat-primary);
}

.sc-send-btn {
    background: var(--sensochat-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
    padding: 0;
}

.sc-send-btn:hover {
    opacity: 0.9;
}

.sc-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    #sensochat-widget.bottom-right,
    #sensochat-widget.bottom-left {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    #sensochat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 90px);
        max-height: none;
        bottom: calc(var(--sensochat-icon-size) + 10px);
        right: 0 !important;
        left: 0 !important;
    }

    #sensochat-button {
        width: var(--sensochat-icon-size);
        height: var(--sensochat-icon-size);
    }
}
