/* Essiow Chat Widget */

:root {
    --essiow-color: #4F46E5;
    --essiow-text: #1d2327;
    --essiow-text-light: #646970;
    --essiow-bg: #ffffff;
    --essiow-bg-light: #f6f7f7;
    --essiow-border: #dcdcde;
    --essiow-user-bg: #1d2327;
    --essiow-user-text: #ffffff;
}

/* ── Bubble ───────────────────────────────────────── */
.essiow-bubble {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--essiow-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: visible;
}

.essiow-bubble:hover { transform: scale(1.05); }
.essiow-bubble--right { right: 24px; }
.essiow-bubble--left { left: 24px; }

.essiow-bubble__icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.essiow-bubble__icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.essiow-bubble__photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    clip-path: circle(50%);
}

.essiow-bubble__close { display: none; }

.essiow-bubble.active .essiow-bubble__icon,
.essiow-bubble.active .essiow-bubble__photo { display: none; }

.essiow-bubble.active .essiow-bubble__close {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
}

/* When photo is shown, remove background color padding */
.essiow-bubble--has-photo {
    padding: 0;
    background: transparent;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.essiow-bubble--has-photo.active {
    background: var(--essiow-color);
}

/* Online indicator dot on bubble */
.essiow-bubble__online {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    background: #31c652;
    border-radius: 50%;
    border: 3px solid #fff;
    z-index: 1;
}

.essiow-bubble.active .essiow-bubble__online { display: none; }

/* ── Tooltip ──────────────────────────────────────── */
.essiow-tooltip {
    position: fixed;
    bottom: 96px;
    z-index: 99998;
    background: var(--essiow-bg);
    color: var(--essiow-text);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--essiow-border);
    font-size: 14px;
    max-width: 260px;
    cursor: pointer;
    animation: essiow-fade-up 0.3s ease;
}
.essiow-tooltip--right { right: 24px; }
.essiow-tooltip--left { left: 24px; }

@keyframes essiow-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Chat Window ──────────────────────────────────── */
.essiow-chat {
    position: fixed;
    bottom: 100px;
    z-index: 99999;
    width: 380px;
    max-height: 550px;
    height: calc(100vh - 140px);
    background: var(--essiow-bg);
    border: 1px solid var(--essiow-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: essiow-slide-up 0.3s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.essiow-chat--right { right: 24px; }
.essiow-chat--left { left: 24px; }

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

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

.essiow-chat__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.essiow-chat__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.essiow-chat__header-info { flex: 1; min-width: 0; }
.essiow-chat__name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.essiow-chat__status { font-size: 12px; opacity: 0.8; }

.essiow-chat__close {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.2) !important;
    border: none !important;
    color: #fff !important;
    cursor: pointer !important;
    font-size: 18px !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    transition: background 0.2s !important;
    padding: 0 !important;
    margin: 0 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    -webkit-tap-highlight-color: transparent;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
}
.essiow-chat__close:hover { background: rgba(255,255,255,0.35) !important; }

/* ── Messages ─────────────────────────────────────── */
.essiow-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.essiow-message--assistant {
    align-self: flex-start;
    background: var(--essiow-bg-light);
    color: var(--essiow-text);
    border-bottom-left-radius: 4px;
}

.essiow-message--user {
    align-self: flex-end;
    background: var(--essiow-user-bg);
    color: var(--essiow-user-text);
    border-bottom-right-radius: 4px;
}

.essiow-message a { color: var(--essiow-color); text-decoration: underline; }
.essiow-message--user a { color: #93c5fd; }
.essiow-message ul, .essiow-message ol { margin: 4px 0; padding-left: 20px; }
.essiow-message p { margin: 0 0 6px; }
.essiow-message p:last-child { margin-bottom: 0; }

/* ── Product Card ─────────────────────────────────── */
.essiow-product-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--essiow-border);
    border-radius: 8px;
    margin-top: 8px;
    background: var(--essiow-bg);
}

.essiow-product-card__image { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.essiow-product-card__info { flex: 1; min-width: 0; }
.essiow-product-card__name { font-weight: 600; font-size: 13px; color: var(--essiow-text); display: block; text-decoration: none; margin-bottom: 2px; }
.essiow-product-card__name:hover { color: var(--essiow-color); }
.essiow-product-card__price { font-size: 14px; font-weight: 600; color: var(--essiow-color); }
.essiow-product-card__action { display: inline-block; margin-top: 6px; padding: 4px 12px; background: var(--essiow-color); color: #fff; border-radius: 4px; font-size: 12px; text-decoration: none; cursor: pointer; }
.essiow-product-card__action:hover { opacity: 0.9; color: #fff; }

/* ── Typing Indicator ─────────────────────────────── */
.essiow-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: var(--essiow-bg-light);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.essiow-typing__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--essiow-text-light);
    animation: essiow-bounce 1.4s ease-in-out infinite;
}
.essiow-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.essiow-typing__dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Input ────────────────────────────────────────── */
.essiow-chat__input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--essiow-border);
    flex-shrink: 0;
}

.essiow-chat__input input {
    flex: 1;
    border: 1px solid var(--essiow-border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    min-width: 0;
}
.essiow-chat__input input:focus { border-color: var(--essiow-color); }

.essiow-chat__send {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--essiow-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    font-family: Arial, Helvetica, sans-serif;
    -webkit-tap-highlight-color: transparent;
}
.essiow-chat__send:hover { opacity: 0.9; }
.essiow-chat__send:active { transform: scale(0.92); }
.essiow-chat__send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Responsive (Mobile) ─────────────────────────── */
@media screen and (max-width: 480px) {
    .essiow-chat {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .essiow-chat__close {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .essiow-tooltip { display: none; }
}
