/* ================================================================
   Veneto Kitchens Chatbot – Stylesheet v1.1
   Italian minimalist: restraint, proportion, clarity.
   ================================================================ */

:root {
    --vk-primary:     #1A1A1A;
    --vk-accent:      #8B7355;
    --vk-bg:          #FFFFFF;
    --vk-bubble-bot:  #F4F3F0;
    --vk-bubble-user: #1A1A1A;
    --vk-text-dark:   #1A1A1A;
    --vk-text-mid:    #555555;
    --vk-text-light:  #888888;
    --vk-border:      #E8E6E1;
    --vk-shadow:      0 8px 40px rgba(0,0,0,0.18);
    --vk-radius:      16px;
    --vk-radius-sm:   8px;
    --vk-font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --vk-z:           999999;
    --vk-width:       370px;
    --vk-height:      560px;
}

/* ── Reset inside widget ────────────────────────────────────────── */
#vk-chatbot-root *,
#vk-chatbot-root *::before,
#vk-chatbot-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Root Container ─────────────────────────────────────────────── */
#vk-chatbot-root {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: var(--vk-z) !important;
    font-family: var(--vk-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--vk-text-dark);
}

/* Bottom-left override (applied by JS when admin chooses left) */
#vk-chatbot-root.vk-pos-bottom-left {
    right: auto !important;
    left: 24px !important;
}

/* ── Launcher Button ─────────────────────────────────────────────── */
#vk-chatbot-launcher {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--vk-primary);
    border: none;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

#vk-chatbot-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}

#vk-chatbot-launcher:focus-visible {
    outline: 3px solid var(--vk-accent);
    outline-offset: 3px;
}

/* ── Unread Badge ───────────────────────────────────────────────── */
.vk-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #E53E3E;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: vk-pulse 2s infinite;
}

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

/* ── Chat Window ─────────────────────────────────────────────────
   IMPORTANT: hidden via class toggle, NOT inline display style.
   display:none is the default; .vk-window-open shows it.
   Using !important on .vk-window-open to override any theme resets.
   ────────────────────────────────────────────────────────────── */
#vk-chatbot-window {
    display: none;
    position: absolute;
    bottom: 74px;
    right: 0;
    width: var(--vk-width);
    max-height: var(--vk-height);
    background: var(--vk-bg);
    border-radius: var(--vk-radius);
    box-shadow: var(--vk-shadow);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--vk-border);
}

/* This class is toggled by JS — !important overrides theme CSS resets */
#vk-chatbot-window.vk-window-open {
    display: flex !important;
    flex-direction: column !important;
    animation: vk-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Left-side override */
#vk-chatbot-root.vk-pos-bottom-left #vk-chatbot-window {
    right: auto;
    left: 0;
}

@keyframes vk-slide-up {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Header ─────────────────────────────────────────────────────── */
.vk-chat-header {
    background: var(--vk-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.vk-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--vk-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.vk-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vk-bot-name {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.2px;
}

.vk-bot-status {
    font-size: 12px;
    opacity: 0.75;
    display: flex;
    align-items: center;
    gap: 5px;
}

.vk-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;
    flex-shrink: 0;
    animation: vk-blink 3s infinite;
}

@keyframes vk-blink {
    0%, 90%, 100% { opacity: 1; }
    95%            { opacity: 0.3; }
}

.vk-header-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.vk-header-close:hover { color: #fff; }

/* ── Message Area ───────────────────────────────────────────────── */
.vk-message-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    min-height: 0;
}

.vk-message-area::-webkit-scrollbar { width: 4px; }
.vk-message-area::-webkit-scrollbar-track { background: transparent; }
.vk-message-area::-webkit-scrollbar-thumb {
    background: var(--vk-border);
    border-radius: 4px;
}

/* ── Individual Messages ────────────────────────────────────────── */
.vk-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: vk-msg-in 0.2s ease;
}

@keyframes vk-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.vk-msg.vk-msg-bot  { align-self: flex-start; align-items: flex-start; }
.vk-msg.vk-msg-user { align-self: flex-end;   align-items: flex-end; }

.vk-msg-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.vk-msg-bot  .vk-msg-bubble {
    background: var(--vk-bubble-bot);
    color: var(--vk-text-dark);
    border-bottom-left-radius: 4px;
}

.vk-msg-user .vk-msg-bubble {
    background: var(--vk-bubble-user);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.vk-msg-time {
    font-size: 11px;
    color: var(--vk-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

/* ── Typing Indicator ───────────────────────────────────────────── */
.vk-typing {
    padding: 4px 14px 8px;
    display: none;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.vk-typing.active { display: flex; }

.vk-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--vk-accent);
    animation: vk-bounce 1.2s infinite ease-in-out;
}

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

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

/* ── Quick Replies ──────────────────────────────────────────────── */
.vk-quick-replies {
    padding: 4px 14px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    flex-shrink: 0;
}

.vk-quick-reply-btn {
    background: none;
    border: 1.5px solid var(--vk-accent);
    color: var(--vk-accent);
    font-family: var(--vk-font);
    font-size: 12.5px;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}

.vk-quick-reply-btn:hover {
    background: var(--vk-accent);
    color: #fff;
}

/* ── Input Area ─────────────────────────────────────────────────── */
.vk-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--vk-border);
    background: #FAFAF8;
    flex-shrink: 0;
}

.vk-user-input {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--vk-border);
    border-radius: 22px;
    padding: 9px 14px;
    font-family: var(--vk-font);
    font-size: 14px;
    line-height: 1.4;
    color: var(--vk-text-dark);
    background: var(--vk-bg);
    outline: none;
    transition: border-color 0.15s;
    max-height: 100px;
    overflow-y: auto;
    -webkit-appearance: none;
    appearance: none;
}

.vk-user-input:focus         { border-color: var(--vk-accent); }
.vk-user-input::placeholder  { color: var(--vk-text-light); }

.vk-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--vk-accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.vk-send-btn:disabled              { background: var(--vk-border); cursor: not-allowed; }
.vk-send-btn:not(:disabled):hover  { background: var(--vk-primary); transform: scale(1.05); }

.vk-send-btn:focus-visible {
    outline: 3px solid var(--vk-accent);
    outline-offset: 2px;
}

/* ── Footer Branding ────────────────────────────────────────────── */
.vk-chat-footer {
    text-align: center;
    font-size: 11px;
    color: var(--vk-text-light);
    padding: 6px 12px;
    background: #FAFAF8;
    border-top: 1px solid var(--vk-border);
    flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 420px) {
    :root { --vk-width: calc(100vw - 24px); }

    #vk-chatbot-window {
        right: 0;
        left: 0 !important;
        margin: 0 12px;
        width: calc(100vw - 24px);
    }
}
