/* 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;
}

.essiow-bubble:hover {
    transform: scale(1.05);
}

.essiow-bubble--right {
    right: 24px;
}

.essiow-bubble--left {
    left: 24px;
}

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

.essiow-bubble__photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.essiow-bubble__close {
    display: none;
}

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

.essiow-bubble.active .essiow-bubble__close {
    display: block;
    font-size: 28px;
    line-height: 1;
}

/* ── 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;
    height: 550px;
    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;
}

.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: 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__name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
}

.essiow-chat__status {
    font-size: 12px;
    opacity: 0.8;
}

/* ── 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;
}

.essiow-chat__input input:focus {
    border-color: var(--essiow-color);
}

.essiow-chat__send {
    width: 36px;
    height: 36px;
    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: opacity 0.15s;
}

.essiow-chat__send:hover {
    opacity: 0.9;
}

.essiow-chat__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.essiow-chat__send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ── Powered By ───────────────────────────────────── */
.essiow-chat__footer {
    text-align: center;
    padding: 6px;
    font-size: 11px;
    color: var(--essiow-text-light);
    flex-shrink: 0;
}

.essiow-chat__footer a {
    color: var(--essiow-text-light);
    text-decoration: none;
}

.essiow-chat__footer a:hover {
    color: var(--essiow-color);
}

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

    .essiow-tooltip {
        display: none;
    }
}
