/* =============================================================
   Elisa Chat Widget — Lanaio.it  v3.0.0
   Visual theme: warm off-white backgrounds, Biella green primary,
   purple accent (matching brand logo), Fraunces headings, Inter body.
   ============================================================= */

/* ---- Tokens ---- */
:root {
    --el-green:      #2F6E4F;
    --el-green-dark: #285F45;
    --el-purple:     #8F4D99;
    --el-purple-hov: #7A3F85;
    --el-text:       #1F2937;
    --el-text-light: #6B7280;
    --el-bg:         #FFFCF7;
    --el-bg-light:   #F7F3EE;
    --el-bg-warm:    #E7E2DB;
    --el-white:      #ffffff;
    --el-font:       'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --el-font-head:  'Fraunces', Georgia, 'Times New Roman', serif;
    --el-radius:     16px;
    --el-shadow:     0 8px 30px rgba(0, 0, 0, 0.12);
    --el-shadow-sm:  0 1px 4px rgba(0, 0, 0, 0.06);
}

/* ---- Reset for widget scope ---- */
#elisa-chat-widget,
#elisa-chat-widget *,
#elisa-chat-widget *::before,
#elisa-chat-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =============================================================
   TOGGLE BUTTON  (hidden — chat opens only via shortcode link)
   ============================================================= */

.elisa-toggle {
    display: none;
}

/* =============================================================
   CHAT WINDOW
   ============================================================= */

#elisa-chat-widget .elisa-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: var(--el-bg);
    border-radius: var(--el-radius);
    box-shadow: var(--el-shadow);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--el-font);
    font-size: 14px;
    color: var(--el-text);
    line-height: 1.5;
}

/* open animation */
#elisa-chat-widget .elisa-window.elisa-entering {
    animation: elisa-slide-up 0.3s ease-out forwards;
}

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

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

#elisa-chat-widget .elisa-header {
    background: var(--el-green-dark);
    color: var(--el-white);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#elisa-chat-widget .elisa-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#elisa-chat-widget .elisa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--el-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--el-font-head);
    font-weight: 700;
    font-size: 18px;
    color: var(--el-white);
    flex-shrink: 0;
}

#elisa-chat-widget .elisa-name {
    font-family: var(--el-font-head);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
}

#elisa-chat-widget .elisa-subtitle {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.3;
}

#elisa-chat-widget .elisa-close-btn {
    background: none;
    border: none;
    color: var(--el-white);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    opacity: 0.75;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
}

#elisa-chat-widget .elisa-close-btn:hover {
    opacity: 1;
}

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

#elisa-chat-widget .elisa-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* hide scrollbar but keep scroll */
#elisa-chat-widget .elisa-messages::-webkit-scrollbar { width: 4px; }
#elisa-chat-widget .elisa-messages::-webkit-scrollbar-track { background: transparent; }
#elisa-chat-widget .elisa-messages::-webkit-scrollbar-thumb {
    background: var(--el-bg-warm);
    border-radius: 4px;
}

/* ---- single message ---- */
#elisa-chat-widget .elisa-msg {
    display: flex;
    max-width: 88%;
    animation: elisa-fade-in 0.25s ease-out;
}

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

#elisa-chat-widget .elisa-msg-bot  { align-self: flex-start; }
#elisa-chat-widget .elisa-msg-user { align-self: flex-end;   }

#elisa-chat-widget .elisa-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.55;
    font-size: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#elisa-chat-widget .elisa-msg-bot .elisa-msg-bubble {
    background: var(--el-white);
    color: var(--el-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--el-shadow-sm);
}

#elisa-chat-widget .elisa-msg-user .elisa-msg-bubble {
    background: var(--el-green);
    color: var(--el-white);
    border-bottom-right-radius: 4px;
}

/* ---- links inside messages ---- */
#elisa-chat-widget .elisa-msg-bubble a {
    color: var(--el-green);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

#elisa-chat-widget .elisa-msg-bubble a:hover {
    color: var(--el-green-dark);
}

#elisa-chat-widget .elisa-msg-user .elisa-msg-bubble a {
    color: var(--el-white);
    text-decoration-color: rgba(255,255,255,0.55);
}

/* =============================================================
   QUICK-REPLY CHIPS
   ============================================================= */

#elisa-chat-widget .elisa-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 6px;
    animation: elisa-fade-in 0.3s ease-out;
}

#elisa-chat-widget .elisa-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 22px;
    border: 1.5px solid var(--el-green);
    background: var(--el-white);
    color: var(--el-green);
    font-family: var(--el-font);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    text-decoration: none;
    text-align: left;
    white-space: normal;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#elisa-chat-widget .elisa-chip:hover {
    background: var(--el-green);
    color: var(--el-white);
    transform: translateY(-1px);
}

#elisa-chat-widget .elisa-chip:active {
    transform: scale(0.97);
}

/* WhatsApp chip variant */
#elisa-chat-widget .elisa-chip.elisa-chip-wa {
    border-color: #25D366;
    color: #25D366;
}

#elisa-chat-widget .elisa-chip.elisa-chip-wa:hover {
    background: #25D366;
    color: var(--el-white);
}

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

#elisa-chat-widget .elisa-typing {
    display: inline-flex;
    gap: 5px;
    padding: 12px 16px;
    background: var(--el-white);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--el-shadow-sm);
    width: fit-content;
}

#elisa-chat-widget .elisa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--el-bg-warm);
    display: block;
    animation: elisa-bounce 1.4s ease-in-out infinite;
}

#elisa-chat-widget .elisa-typing span:nth-child(2) { animation-delay: 0.16s; }
#elisa-chat-widget .elisa-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes elisa-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* =============================================================
   PRODUCT CARDS
   ============================================================= */

#elisa-chat-widget .elisa-product-card {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    background: var(--el-white);
    border: 1px solid var(--el-bg-warm);
    border-radius: 12px;
    margin-top: 4px;
    text-decoration: none;
    color: var(--el-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    align-self: flex-start;
    max-width: 88%;
    animation: elisa-fade-in 0.25s ease-out;
}

#elisa-chat-widget .elisa-product-card:hover {
    border-color: var(--el-green);
    box-shadow: 0 2px 10px rgba(47, 110, 79, 0.1);
}

#elisa-chat-widget .elisa-product-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

#elisa-chat-widget .elisa-product-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    justify-content: center;
}

#elisa-chat-widget .elisa-product-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--el-text);
    line-height: 1.3;
}

#elisa-chat-widget .elisa-product-detail {
    font-size: 12px;
    color: var(--el-text-light);
    line-height: 1.3;
}

#elisa-chat-widget .elisa-product-cta {
    font-size: 12px;
    color: var(--el-green);
    font-weight: 600;
    margin-top: 2px;
}

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

#elisa-chat-widget .elisa-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--el-bg-warm);
    background: var(--el-white);
    flex-shrink: 0;
}

#elisa-chat-widget textarea.elisa-input {
    flex: 1;
    width: 100%;
    min-width: 0;
    border: 1.5px solid var(--el-bg-warm);
    border-radius: 20px;
    padding: 10px 16px;
    font-family: var(--el-font);
    font-size: 14px;
    color: var(--el-text);
    background: var(--el-bg-light);
    resize: none;
    outline: none;
    max-height: 96px;
    min-height: 40px;
    line-height: 1.45;
    transition: border-color 0.2s, background-color 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

#elisa-chat-widget textarea.elisa-input:focus {
    border-color: var(--el-green);
    background: var(--el-white);
}

#elisa-chat-widget textarea.elisa-input::placeholder {
    color: #9CA3AF;
    opacity: 1;
}

#elisa-chat-widget .elisa-send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: var(--el-purple);
    color: var(--el-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.2s, transform 0.15s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0;
}

#elisa-chat-widget .elisa-send-btn:hover {
    background: var(--el-purple-hov);
}

#elisa-chat-widget .elisa-send-btn:active {
    transform: scale(0.93);
}

#elisa-chat-widget .elisa-send-btn:disabled {
    background: var(--el-bg-warm);
    cursor: not-allowed;
    transform: none;
}

/* =============================================================
   POWERED-BY (optional, subtle)
   ============================================================= */

#elisa-chat-widget .elisa-powered {
    text-align: center;
    padding: 4px 0 6px;
    font-size: 10px;
    color: var(--el-text-light);
    opacity: 0.6;
    background: var(--el-white);
}

/* =============================================================
   RESPONSIVE
   ============================================================= */

@media (max-width: 480px) {
    #elisa-chat-widget .elisa-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 85vh;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
    }

    #elisa-chat-widget .elisa-msg { max-width: 92%; }
    #elisa-chat-widget .elisa-product-card { max-width: 92%; }

    #elisa-chat-widget .elisa-chip {
        font-size: 12px;
        padding: 8px 14px;
        min-height: 40px;
    }
}
