/* EasyChat WP – Frontend Widget */
:root {
    --ec-primary: #4F46E5;
    --ec-radius:  16px;
    --ec-shadow:  0 8px 40px rgba(0,0,0,.18);
    --ec-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --ec-z:       999999;
}

.ec-widget {
    position: fixed;
    bottom: 24px;
    right:  24px;
    z-index: var(--ec-z);
    font-family: var(--ec-font);
    font-size: 15px;
    line-height: 1.5;
}
.ec-widget--left {
    right: auto;
    left:  24px;
}

/* ── FAB button ─────────────────────────────────────────────────────── */
.ec-fab {
    width:  58px;
    height: 58px;
    border-radius: 50%;
    background: var(--ec-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    position: relative;
    color: #fff;
}
.ec-fab:hover  { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.3); }
.ec-fab:active { transform: scale(.96); }
.ec-fab svg    { width: 26px; height: 26px; display: block; }

.ec-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
}
.ec-hidden { display: none !important; }

/* ── Chat window ────────────────────────────────────────────────────── */
.ec-window {
    position: absolute;
    bottom: 72px;
    right:  0;
    width:  360px;
    max-height: 560px;
    background: #fff;
    border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}
.ec-widget--left .ec-window {
    right: auto;
    left:  0;
}
.ec-window--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.ec-header {
    background: var(--ec-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ec-header__title { font-weight: 600; font-size: 15px; }
.ec-header__close {
    background: none; border: none; cursor: pointer;
    color: #fff; opacity: .8; padding: 2px;
    display: flex; align-items: center;
}
.ec-header__close:hover { opacity: 1; }
.ec-header__close svg { width: 18px; height: 18px; }

/* ── Overlay ─────────────────────────────────────────────────────────── */
.ec-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.96);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 10;
}
.ec-overlay--visible { display: flex; }
.ec-overlay__box     { width: 100%; }

.ec-consent-text {
    font-size: 13px;
    color: #374151;
    margin: 0 0 14px;
    line-height: 1.6;
}
.ec-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    margin-bottom: 16px;
    cursor: pointer;
}
.ec-consent-label input { margin-top: 3px; flex-shrink: 0; }

.ec-email-label {
    font-size: 13px;
    color: #374151;
    margin: 0 0 8px;
}
#ec-email-input {
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #D1D5DB;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    transition: border-color .15s;
}
#ec-email-input:focus { border-color: var(--ec-primary); }

.ec-btn-primary {
    width: 100%;
    background: var(--ec-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.ec-btn-primary:hover { opacity: .9; }

/* ── Messages ───────────────────────────────────────────────────────── */
.ec-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.ec-messages::-webkit-scrollbar { width: 4px; }
.ec-messages::-webkit-scrollbar-track { background: transparent; }
.ec-messages::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 4px; }

/* Bubbles */
.ec-bubble {
    max-width: 78%;
    display: flex;
    flex-direction: column;
}
.ec-bubble--user  { align-self: flex-end; }
.ec-bubble--admin,
.ec-bubble--ai    { align-self: flex-start; }

.ec-bubble__text {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}
.ec-bubble--user  .ec-bubble__text {
    background: var(--ec-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ec-bubble--admin .ec-bubble__text,
.ec-bubble--ai    .ec-bubble__text {
    background: #F3F4F6;
    color: #1F2937;
    border-bottom-left-radius: 4px;
}
.ec-bubble--admin .ec-bubble__text a,
.ec-bubble--ai    .ec-bubble__text a,
.ec-link {
    color: var(--ec-primary);
    text-decoration: underline;
    word-break: break-all;
}
.ec-bubble__time {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 3px;
    padding: 0 4px;
}
.ec-bubble--user .ec-bubble__time { text-align: right; }

/* Typing indicator */
.ec-typing {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 5px;
    background: #F3F4F6;
    padding: 12px 16px;
    border-radius: 18px 18px 18px 4px;
    width: fit-content;
}
.ec-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #9CA3AF;
    display: inline-block;
    animation: ec-bounce 1.2s infinite;
}
.ec-typing span:nth-child(2) { animation-delay: .2s; }
.ec-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ec-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.ec-system-msg {
    text-align: center;
    font-size: 12px;
    color: #9CA3AF;
    padding: 4px 0;
}

/* ── Input row ──────────────────────────────────────────────────────── */
.ec-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #F3F4F6;
    background: #fff;
    flex-shrink: 0;
}
.ec-input {
    flex: 1;
    border: 1.5px solid #E5E7EB;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
    transition: border-color .15s;
    max-height: 120px;
    overflow-y: auto;
}
.ec-input:focus { border-color: var(--ec-primary); }
.ec-send {
    width:  38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ec-primary);
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s, transform .15s;
}
.ec-send:hover  { opacity: .88; }
.ec-send:active { transform: scale(.92); }
.ec-send svg    { width: 18px; height: 18px; }

/* ── Branding bar ───────────────────────────────────────────────────── */
.ec-branding {
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
    padding: 6px 0 8px;
    flex-shrink: 0;
    background: #fff;
}
.ec-branding a { color: #9CA3AF; text-decoration: none; }
.ec-branding a:hover { text-decoration: underline; }

/* ── Attention bubble ───────────────────────────────────────────────── */
.ec-hint {
    position: absolute;
    bottom: 72px;
    right:  0;
    width:  240px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
    padding: 14px 36px 14px 16px;
    opacity: 0;
    transform: translateY(10px) scale(.95);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    cursor: pointer;
}
.ec-widget--left .ec-hint { right: auto; left: 0; }
.ec-hint::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 22px;
    width: 0; height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,.08));
}
.ec-widget--left .ec-hint::after { right: auto; left: 22px; }
.ec-hint--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.ec-hint__text {
    margin: 0;
    font-size: 13px;
    color: #1F2937;
    line-height: 1.5;
}
.ec-hint__close {
    position: absolute;
    top: 8px; right: 10px;
    background: none; border: none; cursor: pointer;
    font-size: 14px; color: #9CA3AF;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: background .15s, color .15s;
    line-height: 1;
}
.ec-hint__close:hover { background: #F3F4F6; color: #374151; }

/* ── Shake animation ─────────────────────────────────────────────────── */
@keyframes ec-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
.ec-shake { animation: ec-shake .4s; }

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .ec-widget { bottom: 16px; right: 16px; }
    .ec-widget--left { left: 16px; right: auto; }
    .ec-window {
        width:  calc(100vw - 32px);
        max-height: calc(100dvh - 100px);
        right: 0;
    }
}
