/* SonoMedoc Chatbot Widget */

#sonomedoc-chatbot-root {
    --snm-color: #7c3aed;
    --snm-color-dark: #6d28d9;
    --snm-color-light: #ede9fe;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    z-index: 999999;
}

/* Bubble */
.snm-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--snm-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 999999;
}

.snm-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.snm-bubble svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.snm-bubble.snm-left {
    right: auto;
    left: 20px;
}

/* Popup */
.snm-popup {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    animation: snmSlideUp 0.3s ease;
}

.snm-popup.snm-left {
    right: auto;
    left: 20px;
}

.snm-popup.snm-open {
    display: flex;
}

@keyframes snmSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.snm-header {
    background: var(--snm-color);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.snm-header-title {
    font-weight: 600;
    font-size: 15px;
}

.snm-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.snm-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.snm-close:hover {
    opacity: 1;
}

.snm-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* Messages zone */
.snm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
}

.snm-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.snm-message-bot {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

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

.snm-message-source {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
}

/* Links in messages */
.snm-message-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.snm-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--snm-color);
    color: #fff;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.snm-link-btn:hover {
    opacity: 0.85;
}

.snm-link-btn::after {
    content: '\2192';
    font-size: 11px;
}

/* Typing indicator */
.snm-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.snm-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: snmBounce 1.4s infinite both;
}

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

@keyframes snmBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* Suggestions */
.snm-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
    background: #f9fafb;
}

.snm-suggestion-btn {
    background: #fff;
    border: 1px solid var(--snm-color);
    color: var(--snm-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.snm-suggestion-btn:hover {
    background: var(--snm-color);
    color: #fff;
}

/* Input zone */
.snm-input-zone {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}

.snm-input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 8px 16px;
    font-size: 13px;
    outline: none;
    background: #f9fafb;
    color: #1f2937;
    transition: border-color 0.2s;
}

.snm-input:focus {
    border-color: var(--snm-color);
}

.snm-input::placeholder {
    color: #9ca3af;
}

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

.snm-send:hover {
    background: var(--snm-color-dark);
}

.snm-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.snm-send svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* Powered by */
.snm-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #9ca3af;
    background: #fff;
    border-top: 1px solid #f3f4f6;
}

.snm-powered a {
    color: var(--snm-color);
    text-decoration: none;
}

/* Mobile */
@media (max-width: 480px) {
    .snm-popup {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .snm-popup.snm-left {
        left: 0;
        right: 0;
    }
}
