/* =========================================================
   ES CHATBOT — WIDGET CSS
   Follows Edderton Scott design language:
   Syne (headings) · Urbanist (body) · #1a1a1a palette · zero border-radius
   ========================================================= */

:root {
    --es-chat-bg:        #ffffff;
    --es-chat-panel-bg: #f8f8f8;
    --es-chat-dark:     #1a1a1a;
    --es-chat-border:   #e0e0e0;
    --es-chat-grey:     #666666;
    --es-chat-light:    #f4f4f2;
    --es-chat-font:     'Urbanist', -apple-system, BlinkMacSystemFont, sans-serif;
    --es-chat-head:     'Syne', -apple-system, BlinkMacSystemFont, sans-serif;
    --es-chat-radius:   0px;
    --es-chat-shadow:   0 24px 80px rgba(0,0,0,0.18);
    --es-chat-w:        380px;
    --es-chat-h:        560px;
    --es-chat-ease:     cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── WIDGET CONTAINER ────────────────────────────────────── */
.es-chat-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 999999;
    font-family: var(--es-chat-font);
    -webkit-font-smoothing: antialiased;
}

/* ── LAUNCHER BUTTON ─────────────────────────────────────── */
.es-chat-launcher {
    width: 56px;
    height: 56px;
    background: var(--es-chat-dark);
    color: #fff;
    border: none;
    border-radius: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.25s var(--es-chat-ease), box-shadow 0.25s var(--es-chat-ease), background 0.15s;
    box-shadow: 0 8px 32px rgba(0,0,0,0.24);
    outline: none;
}

.es-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(0,0,0,0.32);
}

.es-chat-launcher:focus-visible {
    outline: 2px solid var(--es-chat-dark);
    outline-offset: 3px;
}

.es-chat-launcher__icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.2s;
}

.es-chat-launcher__icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.8);
}

.es-chat-widget.is-open .es-chat-launcher__icon--open {
    opacity: 0;
    transform: rotate(90deg) scale(0.8);
}

.es-chat-widget.is-open .es-chat-launcher__icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Notification dot */
.es-chat-notification {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #e53e3e;
    border: 2px solid #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s;
}

.es-chat-notification.is-visible {
    opacity: 1;
    animation: esChatPulse 2s ease-in-out infinite;
}

@keyframes esChatPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.2); }
}

/* ── CHAT PANEL ──────────────────────────────────────────── */
.es-chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: var(--es-chat-w);
    height: var(--es-chat-h);
    background: var(--es-chat-bg);
    border: 1px solid var(--es-chat-border);
    box-shadow: var(--es-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.97);
    transform-origin: bottom right;
    transition: opacity 0.28s var(--es-chat-ease),
                transform 0.28s var(--es-chat-ease);
}

.es-chat-widget.is-open .es-chat-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* ── HEADER ──────────────────────────────────────────────── */
.es-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--es-chat-dark);
    color: #fff;
    flex-shrink: 0;
}

.es-chat-header__identity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.es-chat-header__avatar {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--es-chat-head);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.es-chat-header__name {
    font-family: var(--es-chat-head);
    font-size: 13px;
    font-weight: 700;
    display: block;
    letter-spacing: -0.01em;
}

.es-chat-header__status {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.es-chat-status-dot {
    width: 5px;
    height: 5px;
    background: #48bb78;
    border-radius: 50%;
    flex-shrink: 0;
    animation: esStatusBlink 2s ease-in-out infinite;
}

@keyframes esStatusBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

.es-chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.es-chat-close:hover { color: #fff; }

/* ── MESSAGES ────────────────────────────────────────────── */
.es-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.es-chat-messages::-webkit-scrollbar { width: 4px; }
.es-chat-messages::-webkit-scrollbar-track { background: transparent; }
.es-chat-messages::-webkit-scrollbar-thumb { background: #ddd; }

/* Message bubbles */
.es-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    animation: esMsgIn 0.22s var(--es-chat-ease) both;
}

@keyframes esMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.es-chat-msg--assistant { align-self: flex-start; }
.es-chat-msg--user      { align-self: flex-end; }

.es-chat-bubble,
.es-chat-bubble p,
.es-chat-bubble *,
.es-chatbot-fullpage .es-chat-bubble,
.es-chatbot-fullpage .es-chat-bubble p,
.es-chatbot-fullpage .es-chat-bubble * {
    font-size: 15px !important;
    line-height: 1.45 !important;
}

.es-chat-bubble {
    padding: 5px 9px;
    border: 1px solid transparent;
}

.es-chat-bubble p {
    margin: 0 0 3px 0;
}
.es-chat-bubble p:last-child {
    margin-bottom: 0;
}

.es-chat-msg--assistant .es-chat-bubble {
    background: var(--es-chat-light);
    border-color: var(--es-chat-border);
    color: var(--es-chat-dark);
}

/* ── USER BUBBLE — force white text against theme overrides ── */
.es-chat-msg--user .es-chat-bubble,
.es-chat-msg--user .es-chat-bubble p,
.es-chat-msg--user .es-chat-bubble *,
.es-chatbot-fullpage .es-chat-msg--user .es-chat-bubble,
.es-chatbot-fullpage .es-chat-msg--user .es-chat-bubble p,
.es-chatbot-fullpage .es-chat-msg--user .es-chat-bubble * {
    background: var(--es-chat-dark);
    color: #fff !important;
}

.es-chat-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.es-chat-bubble a:hover { opacity: 0.75; }

/* Typing indicator */
.es-chat-typing {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 5px 9px;
    background: var(--es-chat-light);
    border: 1px solid var(--es-chat-border);
    width: fit-content;
}

.es-chat-typing span {
    width: 5px;
    height: 5px;
    background: #999;
    border-radius: 50%;
    animation: esTypingDot 1.2s ease-in-out infinite;
}
.es-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.es-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes esTypingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-4px); opacity: 1; }
}

/* ── LEAD CAPTURE FORM — step by step ───────────────────── */
.es-chat-lead-form {
    padding: 0 12px 8px;
    background: transparent;
    flex-shrink: 0;
}

/* Each step row: input + arrow button side by side */
.es-lead-step {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--es-chat-border);
    animation: esMsgIn 0.18s ease both;
}

.es-chat-lead-input {
    flex: 1;
    padding: 6px 4px;
    border: none;
    background: transparent;
    font-family: var(--es-chat-font);
    font-size: 15px !important;
    color: var(--es-chat-dark);
    outline: none;
    border-radius: 0;
    min-width: 0;
}

.es-chat-lead-input::placeholder { color: #bbb; }

.es-chat-lead-next {
    width: 26px;
    height: 26px;
    background: var(--es-chat-dark);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
    border-radius: 0;
    padding: 0;
}
.es-chat-lead-next:hover { opacity: 0.8; }

/* ── INPUT AREA ──────────────────────────────────────────── */
.es-chat-input-area {
    padding: 6px 10px 8px;
    border-top: 1px solid var(--es-chat-border);
    background: #fff;
    flex-shrink: 0;
}

.es-chat-input-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.es-chat-input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--es-chat-border);
    background: var(--es-chat-light);
    font-family: var(--es-chat-font);
    font-size: 15px !important;
    color: var(--es-chat-dark);
    resize: none;
    outline: none;
    max-height: 70px;
    overflow-y: auto;
    line-height: 1.4;
    transition: border-color 0.15s;
    border-radius: 0;
}

.es-chat-input:focus { border-color: var(--es-chat-dark); background: #fff; }
.es-chat-input::placeholder { color: #aaa; }

.es-chat-send {
    width: 28px;
    height: 28px;
    background: var(--es-chat-dark);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
    border-radius: 0;
}

.es-chat-send:disabled { opacity: 0.35; cursor: not-allowed; }
.es-chat-send:not(:disabled):hover { opacity: 0.85; transform: translateY(-1px); }

.es-chat-disclaimer {
    font-size: 9px;
    color: #bbb;
    margin: 5px 0 0 0;
    text-align: center;
    font-family: var(--es-chat-font);
}

.es-chat-disclaimer a { color: inherit; text-decoration: underline; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .es-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    .es-chat-panel {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 68px;
        height: calc(100vh - 100px);
        max-height: 580px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .es-chat-panel,
    .es-chat-launcher,
    .es-chat-msg,
    .es-chat-typing span { animation: none !important; transition: none !important; }
}