/* SP Chatbot Widget v2 — Luxury Glass Terminal */
/* DA: sp-vision.net glassmorphism + dark conversational UI */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
    --spc-green: #15bc84;
    --spc-green-light: #3cd0a1;
    --spc-green-pale: #e6faf2;
    --spc-green-glow: rgba(21, 188, 132, 0.35);
    --spc-dark: #0f1117;
    --spc-dark-card: #1a1d27;
    --spc-dark-elevated: #22252f;
    --spc-dark-border: rgba(255, 255, 255, 0.06);
    --spc-text-on-dark: #e8eaed;
    --spc-text-dim: #8b8fa3;
    --spc-text-muted: #5f6377;
    --spc-white: #ffffff;
    --spc-shadow-glow: 0 0 40px rgba(21, 188, 132, 0.12);
    --spc-shadow-drop: 0 24px 64px rgba(0, 0, 0, 0.35);
    --spc-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ==================== FLOATING BUBBLE ==================== */

.sp-chatbot-bubble {
    position: fixed;
    bottom: 28px;
    left: 28px;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--spc-green) 0%, #0ea572 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 24px var(--spc-green-glow), inset 0 1px 0 rgba(255,255,255,0.2);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sp-chatbot-bubble:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 32px var(--spc-green-glow);
    border-radius: 20px;
}

.sp-chatbot-bubble:active { transform: scale(0.94); }

.sp-chatbot-bubble svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    transition: all 0.3s ease;
}

.sp-chatbot-bubble.sp-chatbot-open { border-radius: 50%; }
.sp-chatbot-bubble.sp-chatbot-open svg.sp-chat-icon { display: none; }
.sp-chatbot-bubble.sp-chatbot-open svg.sp-close-icon { display: block; }
.sp-chatbot-bubble:not(.sp-chatbot-open) svg.sp-chat-icon { display: block; }
.sp-chatbot-bubble:not(.sp-chatbot-open) svg.sp-close-icon { display: none; }

/* Notification dot */
.sp-chatbot-bubble::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border-radius: 50%;
    border: 2.5px solid var(--spc-white);
    animation: spc-notif-pulse 2s ease-in-out infinite;
}

.sp-chatbot-bubble.sp-chatbot-open::after { display: none; }

@keyframes spc-notif-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ==================== CHAT CONTAINER ==================== */

.sp-chatbot-container {
    position: fixed;
    bottom: 100px;
    left: 28px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 130px);
    background: var(--spc-dark);
    border: 1px solid var(--spc-dark-border);
    border-radius: 24px;
    box-shadow: var(--spc-shadow-drop), var(--spc-shadow-glow);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--spc-font);
    font-size: 14px;
    color: var(--spc-text-on-dark);
    -webkit-font-smoothing: antialiased;
}

.sp-chatbot-container.sp-chatbot-visible {
    display: flex;
    animation: spc-open 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes spc-open {
    from { opacity: 0; transform: translateY(24px) scale(0.92); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==================== HEADER ==================== */

.sp-chatbot-header {
    background: var(--spc-dark-card);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--spc-dark-border);
    position: relative;
}

.sp-chatbot-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--spc-green) 0%, #0ea572 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.sp-chatbot-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Online pulse ring */
.sp-chatbot-header-avatar::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: var(--spc-green);
    border-radius: 50%;
    border: 2.5px solid var(--spc-dark-card);
    box-shadow: 0 0 0 0 var(--spc-green-glow);
    animation: spc-online 3s ease-in-out infinite;
}

@keyframes spc-online {
    0%, 100% { box-shadow: 0 0 0 0 rgba(21,188,132,0.3); }
    50% { box-shadow: 0 0 0 4px rgba(21,188,132,0); }
}

.sp-chatbot-header-info { flex: 1; }

.sp-chatbot-header-name {
    color: var(--spc-white);
    font-size: 14px;
    font-weight: 600;
}

.sp-chatbot-header-status {
    color: var(--spc-green-light);
    font-size: 12px;
    font-weight: 400;
    margin-top: 1px;
    opacity: 0.8;
}

/* ==================== MESSAGES AREA ==================== */

.sp-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--spc-dark);
    scroll-behavior: smooth;
}

.sp-chatbot-messages::-webkit-scrollbar { width: 3px; }
.sp-chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.sp-chatbot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ==================== MESSAGE BUBBLES ==================== */

.sp-chatbot-msg {
    max-width: 80%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    opacity: 0;
    transform: translateY(8px);
    animation: spc-msg-appear 0.3s ease forwards;
}

@keyframes spc-msg-appear {
    to { opacity: 1; transform: translateY(0); }
}

/* User bubble — solid green, right aligned */
.sp-chatbot-msg-user {
    background: var(--spc-green);
    color: #fff;
    align-self: flex-end;
    border-radius: 18px 18px 6px 18px;
    font-weight: 400;
}

/* Bot bubble — dark elevated card, left aligned */
.sp-chatbot-msg-assistant {
    background: var(--spc-dark-elevated);
    color: var(--spc-text-on-dark);
    align-self: flex-start;
    border-radius: 18px 18px 18px 6px;
    border: 1px solid var(--spc-dark-border);
}

.sp-chatbot-msg-assistant p { margin: 0 0 8px; }
.sp-chatbot-msg-assistant p:last-child { margin-bottom: 0; }
.sp-chatbot-msg-assistant ul, .sp-chatbot-msg-assistant ol { margin: 6px 0; padding-left: 18px; }
.sp-chatbot-msg-assistant li { margin-bottom: 4px; color: var(--spc-text-dim); }
.sp-chatbot-msg-assistant strong { font-weight: 600; color: var(--spc-white); }

.sp-chatbot-msg-assistant code {
    background: rgba(21, 188, 132, 0.12);
    color: var(--spc-green-light);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 12.5px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Timestamp */
.sp-chatbot-msg-time {
    font-size: 10px;
    color: var(--spc-text-muted);
    margin-top: 4px;
    display: block;
}

.sp-chatbot-msg-user .sp-chatbot-msg-time { text-align: right; color: rgba(255,255,255,0.5); }

/* ==================== TYPING INDICATOR ==================== */

.sp-chatbot-typing {
    display: none;
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--spc-dark-elevated);
    border-radius: 18px 18px 18px 6px;
    border: 1px solid var(--spc-dark-border);
    margin-top: 4px;
}

.sp-chatbot-typing.sp-chatbot-visible {
    display: flex;
    gap: 4px;
    align-items: center;
    animation: spc-msg-appear 0.3s ease forwards;
}

.sp-chatbot-typing span {
    width: 7px;
    height: 7px;
    background: var(--spc-green);
    border-radius: 50%;
    animation: spc-dot 1.4s infinite ease-in-out;
}

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

@keyframes spc-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==================== QUICK ACTIONS (Chips) ==================== */

.sp-chatbot-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0 4px;
    align-self: flex-start;
    max-width: 90%;
}

.sp-chatbot-quick-btn {
    background: transparent;
    border: 1px solid rgba(21, 188, 132, 0.3);
    color: var(--spc-green-light);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--spc-font);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(6px);
    animation: spc-chip-in 0.3s ease forwards;
}

.sp-chatbot-quick-btn:nth-child(1) { animation-delay: 0.05s; }
.sp-chatbot-quick-btn:nth-child(2) { animation-delay: 0.12s; }
.sp-chatbot-quick-btn:nth-child(3) { animation-delay: 0.19s; }
.sp-chatbot-quick-btn:nth-child(4) { animation-delay: 0.26s; }

@keyframes spc-chip-in {
    to { opacity: 1; transform: translateY(0); }
}

.sp-chatbot-quick-btn:hover {
    background: var(--spc-green);
    border-color: var(--spc-green);
    color: #fff;
    box-shadow: 0 4px 16px var(--spc-green-glow);
    transform: translateY(-1px);
}

.sp-chatbot-quick-btn:active { transform: translateY(0) scale(0.97); }

/* ==================== CREDENTIALS CARD ==================== */

.sp-chatbot-credentials {
    background: var(--spc-dark-card);
    border: 1px solid rgba(21, 188, 132, 0.15);
    border-radius: 16px;
    padding: 16px;
    margin: 4px 0;
    font-size: 13px;
    max-width: 85%;
    align-self: flex-start;
    animation: spc-msg-appear 0.3s ease forwards;
}

.sp-chatbot-cred-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--spc-dark-border);
}

.sp-chatbot-cred-row:last-child { border-bottom: none; }

.sp-chatbot-cred-label {
    color: var(--spc-text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sp-chatbot-cred-value {
    color: var(--spc-white);
    font-weight: 500;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-chatbot-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--spc-text-muted);
    padding: 3px;
    border-radius: 6px;
    transition: all 0.15s;
    font-size: 13px;
    line-height: 1;
}

.sp-chatbot-copy-btn:hover { color: var(--spc-green); }
.sp-chatbot-copy-btn.sp-copied { color: var(--spc-green); }

/* ==================== ACTION BUTTONS ==================== */

.sp-chatbot-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--spc-green);
    color: #fff;
    padding: 10px 20px;
    border-radius: 100px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--spc-font);
    margin: 6px 0;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px var(--spc-green-glow);
    animation: spc-msg-appear 0.3s ease forwards;
}

.sp-chatbot-wa-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px var(--spc-green-glow);
    color: #fff;
    text-decoration: none;
}

/* ==================== INPUT AREA ==================== */

.sp-chatbot-input-area {
    padding: 12px 14px;
    border-top: 1px solid var(--spc-dark-border);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--spc-dark-card);
    flex-shrink: 0;
}

.sp-chatbot-input {
    flex: 1;
    border: 1px solid var(--spc-dark-border);
    border-radius: 100px;
    padding: 10px 16px;
    font-size: 13.5px;
    outline: none;
    font-family: var(--spc-font);
    transition: all 0.2s ease;
    color: var(--spc-text-on-dark);
    background: var(--spc-dark-elevated);
}

.sp-chatbot-input:focus {
    border-color: rgba(21, 188, 132, 0.4);
    box-shadow: 0 0 0 3px rgba(21, 188, 132, 0.08);
}

.sp-chatbot-input::placeholder { color: var(--spc-text-muted); }

.sp-chatbot-upload-btn,
.sp-chatbot-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sp-chatbot-upload-btn {
    background: var(--spc-dark-elevated);
    color: var(--spc-text-dim);
}

.sp-chatbot-upload-btn:hover {
    color: var(--spc-green);
    background: rgba(21, 188, 132, 0.1);
}

.sp-chatbot-send-btn {
    background: var(--spc-green);
    color: #fff;
}

.sp-chatbot-send-btn:hover { transform: scale(1.08); }

.sp-chatbot-send-btn:disabled {
    background: var(--spc-dark-elevated);
    color: var(--spc-text-muted);
    cursor: not-allowed;
    transform: none;
}

.sp-chatbot-send-btn svg,
.sp-chatbot-upload-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ==================== QR CODE ==================== */

.sp-chatbot-qr {
    text-align: center;
    padding: 16px;
    background: var(--spc-dark-card);
    border-radius: 16px;
    border: 1px solid var(--spc-dark-border);
    margin: 4px 0;
    max-width: 80%;
    align-self: flex-start;
    animation: spc-msg-appear 0.3s ease forwards;
}

.sp-chatbot-qr canvas, .sp-chatbot-qr img {
    max-width: 160px;
    border-radius: 12px;
    background: #fff;
    padding: 8px;
}

.sp-chatbot-qr-label {
    font-size: 11px;
    color: var(--spc-text-muted);
    margin-top: 8px;
}

/* ==================== IMAGE ==================== */

.sp-chatbot-msg-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
}

/* ==================== RATING ==================== */

.sp-chatbot-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    justify-content: center;
}

.sp-chatbot-rating-btn {
    background: var(--spc-dark-elevated);
    border: 1px solid var(--spc-dark-border);
    border-radius: 10px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
    color: var(--spc-text-on-dark);
}

.sp-chatbot-rating-btn:hover {
    border-color: var(--spc-green);
    background: rgba(21, 188, 132, 0.08);
}

/* ==================== MOBILE ==================== */

@media (max-width: 480px) {
    .sp-chatbot-container {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .sp-chatbot-bubble {
        bottom: 18px;
        left: 18px;
        width: 54px;
        height: 54px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .sp-chatbot-container {
        width: 370px;
        height: 540px;
    }
}
