/* Sweetch Chat Widget - Sofia */
/* ---- Widget Button ---- */
#sweetch-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    overflow: hidden;
    padding: 0;
}
#sweetch-widget-btn:hover {
    transform: scale(1.08);
}
#sweetch-widget-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
}
#sweetch-widget-btn .chat-icon { display: block; }
#sweetch-widget-btn .close-icon { display: none; }
#sweetch-widget-btn.open { background: #A7452E; }
#sweetch-widget-btn.open .chat-icon { display: none; }
#sweetch-widget-btn.open .close-icon { display: block; }

/* ---- Chat Window ---- */
#sweetch-chat-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    height: 520px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Lexend Deca', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
#sweetch-chat-window.open {
    display: flex;
}

/* ---- Mobile Fullscreen ---- */
@media (max-width: 768px) {
    #sweetch-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    #sweetch-widget-btn.open { display: none; }
    .sweetch-input-area textarea {
        font-size: 16px !important;
    }
    .sweetch-esc-input {
        font-size: 16px !important;
    }
}

/* ---- Header ---- */
.sweetch-header {
    background: #A7452E;
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.sweetch-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.sweetch-header-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}
.sweetch-header-info p {
    margin: 0;
    font-size: 11px;
    opacity: 0.8;
}
.sweetch-close-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: none;
}
@media (max-width: 768px) {
    .sweetch-close-btn { display: block; }
}

/* ---- Messages ---- */
.sweetch-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}
.sweetch-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}
.sweetch-msg.assistant {
    background: transparent;
    color: #333;
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    padding: 0;
    max-width: 88%;
}
.sweetch-msg.assistant .sweetch-msg-content {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}
.sweetch-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.sweetch-msg.user {
    background: #A7452E;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.sweetch-msg.user a {
    color: white !important;
}

/* ---- Typing Indicator ---- */
.sweetch-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 14px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.sweetch-typing.visible { display: flex; gap: 4px; align-items: center; }
.sweetch-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c86b52;
    animation: sweetchTyping 1.2s infinite;
}
.sweetch-typing span:nth-child(2) { animation-delay: 0.2s; }
.sweetch-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sweetchTyping {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ---- Thinking Indicator ---- */
.sweetch-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 0;
    background: #FFF3E0;
    border-left: 3px solid #A7452E;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: #5d3a1a;
    align-self: flex-start;
    animation: sweetchThinkingPulse 1.8s ease-in-out infinite;
}
.sweetch-thinking-icon {
    font-size: 16px;
    flex-shrink: 0;
}
.sweetch-thinking-text {
    font-style: italic;
}
@keyframes sweetchThinkingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ---- CTA Buttons (after price messages) ---- */
.sweetch-cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    width: 100%;
    padding-left: 36px;
}
.sweetch-cta-btn {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    line-height: 1.4;
}
.sweetch-cta-primary {
    background: #A7452E;
    color: white;
}
.sweetch-cta-primary:hover {
    background: #8a3826;
}
.sweetch-cta-secondary {
    background: white;
    color: #A7452E;
    border: 1px solid #A7452E;
}
.sweetch-cta-secondary:hover {
    background: #A7452E;
    color: white;
}

/* ---- Feedback ---- */
.sweetch-feedback {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    width: 100%;
    padding-left: 36px;
}
.sweetch-feedback button {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
}
.sweetch-feedback button:hover { border-color: #A7452E; color: #A7452E; }
.sweetch-feedback button.active { background: #A7452E; color: white; border-color: #A7452E; }

/* ---- Audio Button (TTS) ---- */
.sweetch-audio-btn {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
    margin-left: 4px;
}
.sweetch-audio-btn:hover { border-color: #A7452E; color: #A7452E; }
.sweetch-audio-btn.playing { background: #A7452E; color: white; border-color: #A7452E; animation: sweetchPulse 1.5s infinite; }
@keyframes sweetchPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ---- Audio Toggle in Header ---- */
.sweetch-audio-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    opacity: 0.8;
    transition: opacity 0.2s;
    margin-left: auto;
}
.sweetch-audio-toggle:hover { opacity: 1; }

/* ---- Suggestions ---- */
.sweetch-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    background: #f8f9fa;
}
.sweetch-suggestions button {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    color: #A7452E;
    font-family: inherit;
    transition: all 0.2s;
}
.sweetch-suggestions button:hover {
    background: #A7452E;
    color: white;
    border-color: #A7452E;
}

/* ---- Consent ---- */
.sweetch-consent {
    padding: 12px 16px;
    background: #f0f4f8;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
    color: #666;
    text-align: center;
}
.sweetch-consent a { color: #A7452E; }
.sweetch-consent button {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: #A7452E;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
}
.sweetch-consent button:hover { background: #8a3826; }

/* ---- Input Area ---- */
.sweetch-input-area {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #eee;
    background: white;
    flex-shrink: 0;
}
.sweetch-input-area textarea {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 16px;
    resize: none;
    outline: none;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.4;
}
.sweetch-input-area textarea:focus { border-color: #A7452E; }
.sweetch-input-area button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #A7452E;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: background 0.2s;
}
.sweetch-input-area button:hover { background: #8a3826; }
.sweetch-input-area button:disabled { background: #ccc; cursor: not-allowed; }
.sweetch-input-area button svg { width: 18px; height: 18px; fill: white; }

/* ---- Clip (File Upload) Button ---- */
.sweetch-input-area .sweetch-clip-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: all 0.2s;
}
.sweetch-input-area .sweetch-clip-btn:hover { border-color: #A7452E; background: #f5f7fa; }
.sweetch-input-area .sweetch-clip-btn svg { width: 18px; height: 18px; fill: #666; }

/* ---- File Preview ---- */
.sweetch-file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 0 12px;
    background: #f0f4f8;
    border-radius: 8px;
    font-size: 12px;
    color: #444;
}
.sweetch-file-preview .sweetch-file-icon { font-size: 16px; flex-shrink: 0; }
.sweetch-file-preview .sweetch-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sweetch-file-preview .sweetch-file-remove {
    background: none; border: none; cursor: pointer; color: #999; font-size: 16px; padding: 0 4px; line-height: 1;
}
.sweetch-file-preview .sweetch-file-remove:hover { color: #e53e3e; }
.sweetch-file-uploading { opacity: 0.6; pointer-events: none; }
.sweetch-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(0,0,0,0.06);
    border-radius: 4px;
    font-size: 11px;
    margin-bottom: 4px;
    color: #555;
}

/* ---- Mic Button (Voice Dictation) ---- */
.sweetch-mic-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: all 0.2s;
}
.sweetch-mic-btn:hover { border-color: #A7452E; background: #f5f7fa; }
.sweetch-mic-btn svg { width: 18px; height: 18px; fill: #666; }
.sweetch-mic-btn.recording {
    background: #e53e3e;
    border-color: #e53e3e;
    animation: sweetchMicPulse 1.2s infinite;
}
.sweetch-mic-btn.recording svg { fill: white; }
@keyframes sweetchMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229,62,62,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(229,62,62,0); }
}

/* ---- Error ---- */
.sweetch-error {
    padding: 8px 14px;
    margin: 4px 0;
    background: #fff3f3;
    color: #c00;
    border-radius: 8px;
    font-size: 12px;
    align-self: center;
    text-align: center;
}

/* ---- Escalation ---- */
.sweetch-escalate-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}
.sweetch-escalate-btn:hover { opacity: 1; }
.sweetch-escalation-form {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}
.sweetch-escalation-title {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 8px;
}
.sweetch-escalation-desc {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}
.sweetch-esc-input {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
    font-family: inherit;
    box-sizing: border-box;
}
.sweetch-esc-input:focus {
    outline: none;
    border-color: #A7452E;
}
textarea.sweetch-esc-input { resize: vertical; }
.sweetch-esc-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}
.sweetch-esc-btn-cancel {
    padding: 8px 14px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.sweetch-esc-btn-cancel:hover { background: #f5f5f5; }
.sweetch-esc-btn-submit {
    padding: 8px 14px;
    border: none;
    background: #A7452E;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.sweetch-esc-btn-submit:hover { background: #8a3826; }
.sweetch-esc-btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Proactive Notification Bubble ---- */
.sweetch-proactive-bubble {
    position: fixed;
    bottom: 88px;
    right: 24px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 12px 16px;
    max-width: 260px;
    z-index: 99997;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: sweetchBubbleIn 0.4s ease-out;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 3px solid #A7452E;
}
.sweetch-proactive-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}
.sweetch-proactive-bubble-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.sweetch-proactive-bubble-text {
    flex: 1;
    font-family: 'Lexend Deca', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
}
.sweetch-proactive-bubble-name {
    font-weight: 600;
    color: #A7452E;
    font-size: 12px;
    margin-bottom: 2px;
}
.sweetch-proactive-bubble-close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #999;
    line-height: 1;
    padding: 2px;
}
.sweetch-proactive-bubble-close:hover { color: #666; }
@keyframes sweetchBubbleIn {
    0% { opacity: 0; transform: translateY(10px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 768px) {
    .sweetch-proactive-bubble {
        right: 16px;
        bottom: 84px;
        max-width: calc(100vw - 90px);
    }
}
