/* ===== CHATBOT WIDGET — Modern Design ===== */

#chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== TOGGLE BUTTON ===== */
#chatbot-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 0;
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
}

#chatbot-toggle:hover {
    transform: scale(1.1);
}

#chatbot-toggle-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(225, 82, 160, 0.4), 0 2px 8px rgba(0,0,0,0.15);
    position: relative;
    border: 3px solid #fff;
}

#chatbot-toggle-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#chatbot-toggle-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2.5px solid #fff;
    z-index: 2;
}

#chatbot-toggle-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e052a0, #f15c41);
    opacity: 0;
    z-index: -1;
    animation: chatbot-pulse 3s ease-in-out infinite;
}

@keyframes chatbot-pulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.15); }
}

/* ===== TRIGGER GROUP (teaser + toggle) ===== */
#chatbot-trigger {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-direction: row;
    justify-content: flex-end;
}

#chatbot-teaser {
    background: #fff;
    color: #1f2937;
    padding: 10px 16px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: chatbot-teaserIn 0.5s 2s both cubic-bezier(.34,1.56,.64,1);
    max-width: 260px;
    line-height: 1.35;
    transition: transform 0.2s, box-shadow 0.2s;
}

#chatbot-teaser:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
}

@keyframes chatbot-teaserIn {
    from { opacity: 0; transform: translateX(20px) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

#chatbot-teaser-close {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    padding: 0 0 0 4px;
    line-height: 1;
    flex-shrink: 0;
}

#chatbot-teaser-close:hover {
    color: #4b5563;
}

/* Hide trigger group when open */
#chatbot-widget.open #chatbot-trigger {
    display: none;
}

/* ===== CHAT WINDOW ===== */
#chatbot-window {
    display: none;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 400px;
    height: 560px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    flex-direction: column;
    animation: chatbot-slideUp 0.35s cubic-bezier(.34,1.56,.64,1);
}

@keyframes chatbot-slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#chatbot-widget.open #chatbot-window {
    display: flex;
}

/* ===== HEADER ===== */
#chatbot-header {
    background: linear-gradient(135deg, #e052a0, #f15c41);
    color: #fff;
    padding: 16px 16px 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
}

#chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

#chatbot-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
    position: relative;
}

#chatbot-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

#chatbot-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #e052a0;
    box-sizing: border-box;
}

#chatbot-header-info {
    min-width: 0;
}

#chatbot-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

#chatbot-header-info p {
    margin: 2px 0 0;
    font-size: 13px;
    opacity: 0.9;
    font-weight: 400;
    white-space: nowrap;
    color: #ffffff;
}

#chatbot-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

#chatbot-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ===== MESSAGES AREA ===== */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f9fafb;
    scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ===== MESSAGE BUBBLES ===== */
.chatbot-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
}

.chatbot-msg-row.assistant {
    align-self: flex-start;
}

.chatbot-msg-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.chatbot-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chatbot-msg {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: chatbot-msgIn 0.25s ease-out;
}

@keyframes chatbot-msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chatbot-msg-row.assistant .chatbot-msg {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
}

.chatbot-msg-row.user .chatbot-msg {
    background: linear-gradient(135deg, #e052a0, #f15c41);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.chatbot-msg.error {
    align-self: center;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-size: 13px;
    text-align: center;
    border-radius: 12px;
    padding: 8px 14px;
}

/* ===== TYPING INDICATOR ===== */
.chatbot-typing-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
}

.chatbot-typing {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
}

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

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

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

@keyframes chatbot-bounce {
    0%, 60%, 100% { transform: translateY(0); background: #d1d5db; }
    30% { transform: translateY(-8px); background: #e052a0; }
}

/* ===== INPUT AREA ===== */
#chatbot-input-area {
    display: flex;
    align-items: flex-end;
    padding: 12px 14px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
    gap: 10px;
}

#chatbot-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 22px;
    padding: 10px 18px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

#chatbot-input:focus {
    border-color: #e052a0;
    box-shadow: 0 0 0 3px rgba(224, 82, 160, 0.1);
    background: #fff;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e052a0, #f15c41);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    color: #fff;
}

#chatbot-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(225, 82, 160, 0.35);
}

#chatbot-send:disabled {
    background: #e5e7eb;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#chatbot-send svg {
    width: 18px;
    height: 18px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    #chatbot-widget {
        bottom: 16px;
        right: 16px;
    }

    #chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100dvh - 100px);
        bottom: 0;
        right: -16px;
        border-radius: 16px;
    }

    #chatbot-toggle-avatar,
    #chatbot-toggle {
        width: 56px;
        height: 56px;
    }
}

/* ===== FULLSCREEN WELCOME MODAL ===== */
#chatbot-welcome-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatbot-overlayIn 0.4s ease-out;
}

@keyframes chatbot-overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#chatbot-welcome-modal {
    background: #fff;
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: chatbot-modalIn 0.5s cubic-bezier(.34,1.56,.64,1);
}

@keyframes chatbot-modalIn {
    from { opacity: 0; transform: scale(0.85) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

#chatbot-welcome-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f3f4f6;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

#chatbot-welcome-close:hover {
    background: #e5e7eb;
    color: #1f2937;
}

#chatbot-welcome-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 3px solid transparent;
    background-image: linear-gradient(#fff, #fff), linear-gradient(135deg, #e052a0, #f15c41);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

#chatbot-welcome-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.chatbot-welcome-dot {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2.5px solid #fff;
}

#chatbot-welcome-modal h2 {
    margin: 0 0 2px;
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
}

.chatbot-welcome-role {
    margin: 0 0 16px;
    font-size: 14px;
    color: #9ca3af;
    font-weight: 500;
}

.chatbot-welcome-text {
    margin: 0 0 24px;
    font-size: 16px;
    color: #4b5563;
    line-height: 1.5;
    padding: 0 8px;
}

#chatbot-welcome-start {
    background: linear-gradient(135deg, #e052a0, #f15c41);
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

#chatbot-welcome-start:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(225, 82, 160, 0.35);
}

#chatbot-welcome-overlay.closing {
    animation: chatbot-overlayOut 0.3s ease-in forwards;
}

#chatbot-welcome-overlay.closing #chatbot-welcome-modal {
    animation: chatbot-modalOut 0.3s ease-in forwards;
}

@keyframes chatbot-overlayOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes chatbot-modalOut {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to { opacity: 0; transform: scale(0.9) translateY(20px); }
}

/* ===== FULLSCREEN CHAT MODE ===== */
#chatbot-fullscreen-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100000;
    animation: chatbot-overlayIn 0.4s ease-out;
}

#chatbot-widget.fullscreen-chat #chatbot-fullscreen-overlay {
    display: block;
}

#chatbot-widget.fullscreen-chat #chatbot-trigger {
    display: none;
}

#chatbot-widget.fullscreen-chat #chatbot-window {
    display: flex;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    bottom: auto;
    right: auto;
    width: 520px;
    height: 680px;
    max-width: 94vw;
    max-height: 90dvh;
    z-index: 100001;
    animation: chatbot-fullscreenIn 0.5s cubic-bezier(.34,1.56,.64,1);
}

@keyframes chatbot-fullscreenIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Fullscreen chat closing animation */
#chatbot-widget.fullscreen-chat.closing #chatbot-fullscreen-overlay {
    animation: chatbot-overlayOut 0.3s ease-in forwards;
}

#chatbot-widget.fullscreen-chat.closing #chatbot-window {
    animation: chatbot-fullscreenOut 0.3s ease-in forwards;
}

@keyframes chatbot-fullscreenOut {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

/* Mobile fullscreen chat */
@media (max-width: 480px) {
    #chatbot-widget.fullscreen-chat #chatbot-window {
        width: calc(100vw - 24px);
        height: calc(100dvh - 48px);
    }
}

/* ===== MARKDOWN FORMATTING ===== */
.chatbot-msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-msg-row.assistant .chatbot-msg a {
    color: #e052a0;
    font-weight: 500;
}

.chatbot-msg strong {
    font-weight: 600;
}

.chatbot-msg ul, .chatbot-msg ol {
    margin: 6px 0;
    padding-left: 18px;
}

.chatbot-msg li {
    margin-bottom: 3px;
}

/* ===== OFFER CARDS ===== */
.chatbot-offer-card {
    background: linear-gradient(135deg, #fdf2f8, #fff1f2);
    border: 1px solid #fce7f3;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 8px 0;
    font-size: 13px;
}

.chatbot-offer-card strong {
    display: block;
    color: #e052a0;
    margin-bottom: 4px;
    font-size: 14px;
}

.chatbot-offer-card .chatbot-offer-meta {
    color: #6b7280;
    font-size: 12px;
}
