/* ================================================================
   WP AI Agent — Frontend Widget Styles
   ================================================================ */

/* ── Container ──────────────────────────────────────────────── */
.waia-container {
    position: fixed;
    bottom: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.waia-container.pos-left  { left: 24px;  align-items: flex-start; }
.waia-container.pos-right { right: 24px; align-items: flex-end; }

/* ── Bubble Button ──────────────────────────────────────────── */
.waia-bubble-btn {
    width: 58px; height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    outline: none;
}
.waia-bubble-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,.3);
}
.waia-bubble-btn svg { width: 26px; height: 26px; fill: #fff; transition: all .2s; }
.waia-bubble-btn .waia-icon-close { display: none; }

.waia-bubble-btn.is-open .waia-icon-chat  { display: none; }
.waia-bubble-btn.is-open .waia-icon-close { display: block; }

/* Notification dot */
.waia-bubble-dot {
    position: absolute;
    top: 2px; right: 2px;
    width: 14px; height: 14px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: waiaPulse 1.5s infinite;
}
@keyframes waiaPulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.2); }
}

/* ── Chat Window ────────────────────────────────────────────── */
.waia-window {
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;       /* Tidak ada jarak bawah — mepet ke tepi layar */
    animation: waiaSlideUp .25s ease;
}
@keyframes waiaSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ─────────────────────────────────────────────────── */
.waia-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.waia-header-info { display: flex; align-items: center; gap: 10px; }
.waia-avatar {
    width: 38px; height: 38px;
    min-width: 38px; min-height: 38px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.4);
    background: rgba(255,255,255,.3);
    flex-shrink: 0;
    display: block;
}
.waia-avatar-fallback {
    width: 38px; height: 38px;
    min-width: 38px; min-height: 38px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.waia-agent-name  { font-weight: 700; font-size: 15px; color: #fff; }
.waia-agent-status {
    font-size: 11px; color: rgba(255,255,255,.85);
    display: flex; align-items: center; gap: 4px;
}
.waia-agent-status::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}
.waia-close-btn {
    background: rgba(255,255,255,.2);
    border: none; cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; line-height: 1;
    transition: background .15s;
}
.waia-close-btn:hover { background: rgba(255,255,255,.35); }

/* ── Lead Form ──────────────────────────────────────────────── */
.waia-lead-form {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}
.waia-lead-form h3 {
    margin: 0 0 4px;
    font-size: 17px;
    color: #111827;
}
.waia-lead-form p {
    margin: 0 0 16px;
    color: #6b7280;
    font-size: 13px;
}
.waia-form-field {
    margin-bottom: 12px;
}
.waia-form-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}
.waia-form-field input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
    box-sizing: border-box;
}
.waia-form-field input:focus { border-color: var(--waia-color, #2563eb); }
.waia-form-field input.error { border-color: #ef4444; }

.waia-submit-btn {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    margin-top: 4px;
    transition: opacity .15s, transform .1s;
}
.waia-submit-btn:hover   { opacity: .9; }
.waia-submit-btn:active  { transform: scale(.98); }
.waia-submit-btn:disabled { opacity: .6; cursor: not-allowed; }

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

/* ── Message Bubbles ────────────────────────────────────────── */
.waia-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 88%;
    animation: waiaFadeIn .2s ease;
}
@keyframes waiaFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.waia-msg.user {
    flex-direction: row-reverse;
    margin-left: auto;
}
.waia-msg.assistant { margin-right: auto; }

.waia-msg-avatar {
    width: 26px; height: 26px;
    min-width: 26px; min-height: 26px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}
.waia-msg-avatar-fallback {
    width: 26px; height: 26px;
    min-width: 26px; min-height: 26px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.waia-msg-body { display: flex; flex-direction: column; gap: 2px; }
.waia-msg.user .waia-msg-body { align-items: flex-end; }

.waia-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}
.waia-msg.assistant .waia-bubble {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 4px;
}
.waia-msg.user .waia-bubble {
    color: #fff;
    border-bottom-right-radius: 4px;
}
.waia-msg-time {
    font-size: 10px;
    color: #9ca3af;
    padding: 0 4px;
}

/* ── Typing Indicator ───────────────────────────────────────── */
.waia-typing-wrap {
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.waia-typing-dots { display: flex; gap: 4px; }
.waia-typing-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: waiaTyping 1.2s infinite;
    display: block;
}
.waia-typing-dots span:nth-child(2) { animation-delay: .2s; }
.waia-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes waiaTyping {
    0%,80%,100% { transform: scale(.8); opacity: .5; }
    40%          { transform: scale(1.1); opacity: 1; }
}

/* ── Input Area ─────────────────────────────────────────────── */
.waia-input-area {
    padding: 12px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}
.waia-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 22px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
    transition: border-color .15s;
    font-family: inherit;
}
.waia-input:focus { border-color: var(--waia-color, #2563eb); }

.waia-send-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: transform .15s, opacity .15s;
}
.waia-send-btn:hover  { transform: scale(1.08); }
.waia-send-btn:active { transform: scale(.95); }
.waia-send-btn svg    { width: 18px; height: 18px; fill: #fff; }

/* ── Powered by ─────────────────────────────────────────────── */
.waia-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #d1d5db;
    flex-shrink: 0;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .waia-window {
        width: calc(100vw - 24px);
        max-height: 75vh;
        border-radius: 14px;
    }
    .waia-container { bottom: 16px; }
    .waia-container.pos-right { right: 12px; }
    .waia-container.pos-left  { left: 12px; }
}
