/* WP Flow Chat Widget */

/* Reset within widget scope */
.wpflow-chat-widget,
.wpflow-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── FLOATING POSITIONING ────────────────────────────── */

.wpflow-chat-floating {
    position: fixed;
    z-index: 9999999;
    bottom: 20px;
}

.wpflow-pos-bottom-right {
    right: 20px;
}

.wpflow-pos-bottom-left {
    left: 20px;
}

/* ─── BUBBLE ──────────────────────────────────────────── */

.wpflow-bubble {
    width: var(--wpflow-icon-size, 60px);
    height: var(--wpflow-icon-size, 60px);
    border-radius: 50%;
    background: var(--wpflow-primary, #004F6B);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    color: #fff;
}

.wpflow-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.wpflow-bubble-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.wpflow-bubble-has-avatar {
    background: transparent !important;
    overflow: hidden;
}

.wpflow-bubble-has-avatar video {
    border-radius: 50%;
}

.wpflow-header-avatar {
    border-radius: 50%;
    object-fit: cover;
}

video.wpflow-header-avatar {
    border-radius: 50%;
}

.wpflow-header-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.wpflow-bubble-icon {
    width: 28px;
    height: 28px;
}

.wpflow-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ─── TEASER ──────────────────────────────────────────── */

.wpflow-teaser {
    position: absolute;
    /* Vertically centered with the bubble, placed to the LEFT of it */
    bottom: calc((var(--wpflow-icon-size, 60px) - 40px) / 2);
    right: calc(var(--wpflow-icon-size, 60px) + 12px);
    background: #fff;
    color: #333;
    padding: 10px 32px 10px 14px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    line-height: 1.4;
    max-width: 240px;
    animation: wpflow-fade-in 0.4s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* When the bubble is on the left, put the teaser to the RIGHT of it */
.wpflow-pos-bottom-left .wpflow-teaser {
    right: auto;
    left: calc(var(--wpflow-icon-size, 60px) + 12px);
}

/* Arrow pointing TOWARD the bubble (right side by default) */
.wpflow-teaser::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    margin-top: -6px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 2px -2px 4px rgba(0, 0, 0, 0.05);
}

/* Arrow points LEFT when teaser is on the right of the bubble */
.wpflow-pos-bottom-left .wpflow-teaser::after {
    right: auto;
    left: -6px;
    box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.05);
}

.wpflow-teaser-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 2px;
}

/* ─── CHAT CONTAINER ──────────────────────────────────── */

.wpflow-chat-container {
    width: var(--wpflow-width, 380px);
    height: var(--wpflow-height, 520px);
    max-height: calc(100vh - 120px);
    border-radius: var(--wpflow-radius, 16px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    animation: wpflow-slide-up 0.3s ease;
}

.wpflow-chat-floating .wpflow-chat-container {
    position: fixed;
    bottom: calc(var(--wpflow-icon-size, 60px) + 34px);
    right: 20px;
    z-index: 9999999;
}

.wpflow-pos-bottom-left .wpflow-chat-container {
    right: auto;
    left: 20px;
}

.wpflow-chat-hidden {
    display: none !important;
}

/* ─── INLINE MODE (ChatGPT / Claude style) ────────────── */

.wpflow-chat-inline {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
}

.wpflow-chat-inline .wpflow-chat-container {
    position: relative;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    flex: 1;
    animation: none;
}

/* Hide the small header in inline mode — replace with minimal title */
.wpflow-chat-inline .wpflow-chat-header {
    background: transparent;
    color: var(--wpflow-primary, #004F6B);
    padding: 32px 0 16px;
    text-align: center;
    justify-content: center;
    border: none;
    border-radius: 0;
}

.wpflow-chat-inline .wpflow-chat-header-info {
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wpflow-chat-inline .wpflow-header-avatar {
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
}

.wpflow-chat-inline .wpflow-header-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--wpflow-primary, #004F6B);
    letter-spacing: -0.02em;
}

.wpflow-chat-inline .wpflow-header-status {
    font-size: 13px;
    color: #86868b;
}

.wpflow-chat-inline .wpflow-online-indicator {
    width: 7px;
    height: 7px;
}

.wpflow-chat-inline .wpflow-chat-close {
    display: none;
}

/* Messages — centered, comfortable width */
.wpflow-chat-inline .wpflow-chat-messages {
    flex: 1;
    background: transparent;
    padding: 16px 0;
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    min-height: 200px;
    overflow-y: visible;
}

.wpflow-chat-inline .wpflow-msg {
    max-width: 100%;
    border-radius: 16px;
    padding: 14px 18px;
    font-size: 15px;
    line-height: 1.65;
    box-shadow: none;
}

.wpflow-chat-inline .wpflow-msg-bot {
    background: var(--wpflow-msg-bg, #f8f8fa);
    border: none;
    color: #1d1d1f;
    border-radius: 16px;
    padding: 16px 20px;
}

.wpflow-chat-inline .wpflow-msg-user {
    background: var(--wpflow-primary, #004F6B);
    color: #fff;
    border-radius: 16px;
    max-width: 80%;
}

/* Options in inline mode */
.wpflow-chat-inline .wpflow-options {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.wpflow-chat-inline .wpflow-option-btn {
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 14px;
}

/* Typing in inline mode */
.wpflow-chat-inline .wpflow-typing {
    background: transparent;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    padding: 8px 0;
}

.wpflow-chat-inline .wpflow-typing-dots {
    border: none;
    background: var(--wpflow-msg-bg, #f8f8fa);
}

/* Input — centered bar like ChatGPT */
.wpflow-chat-inline .wpflow-chat-input-area {
    max-width: 700px;
    margin: 0 auto 16px;
    width: 100%;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 0;
    overflow: hidden;
}

.wpflow-chat-inline .wpflow-chat-input {
    border: none;
    border-radius: 0;
    padding: 16px 20px;
    font-size: 16px;
    background: transparent;
    flex: 1;
}

.wpflow-chat-inline .wpflow-chat-input:focus {
    box-shadow: none;
    border: none;
}

.wpflow-chat-inline .wpflow-chat-send {
    width: 44px;
    height: 44px;
    margin-right: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Powered by — subtle */
.wpflow-chat-inline .wpflow-powered {
    background: transparent;
    border: none;
    padding: 8px 0 24px;
    font-size: 11px;
    color: #c7c7cc;
}

/* Inline mobile */
@media (max-width: 768px) {
    .wpflow-chat-inline {
        padding: 0 16px;
    }

    .wpflow-chat-inline .wpflow-header-name {
        font-size: 18px;
    }

    .wpflow-chat-inline .wpflow-chat-input {
        font-size: 16px;
        padding: 14px 16px;
    }
}

/* ─── HEADER ──────────────────────────────────────────── */

.wpflow-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--wpflow-header-bg, var(--wpflow-primary));
    color: var(--wpflow-header-color, #fff);
    flex-shrink: 0;
}

.wpflow-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpflow-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.wpflow-header-name {
    font-weight: 600;
    font-size: 15px;
}

.wpflow-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wpflow-online-indicator {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.wpflow-chat-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.wpflow-chat-close:hover {
    opacity: 1;
}

/* ─── MESSAGES ────────────────────────────────────────── */

.wpflow-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--wpflow-msg-bg, #f8fafc);
}

.wpflow-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: wpflow-fade-in 0.3s ease;
}

.wpflow-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: var(--wpflow-bot-color, #333);
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.wpflow-msg-user {
    align-self: flex-end;
    background: var(--wpflow-user-bg, var(--wpflow-primary));
    color: var(--wpflow-user-color, #fff);
    border-bottom-right-radius: 4px;
}

.wpflow-msg-image img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 6px;
}

/* Options / Buttons */
.wpflow-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.wpflow-option-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--wpflow-primary, #004F6B);
    color: var(--wpflow-primary, #004F6B);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    transition: background 0.2s, color 0.2s;
}

.wpflow-option-btn:hover {
    background: var(--wpflow-primary, #004F6B);
    color: #fff;
}

/* ─── TYPING INDICATOR ────────────────────────────────── */

.wpflow-typing {
    padding: 8px 16px;
    background: var(--wpflow-msg-bg, #f8fafc);
}

.wpflow-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.wpflow-typing-dots span {
    width: 8px;
    height: 8px;
    background: #b0b0b0;
    border-radius: 50%;
    animation: wpflow-bounce 1.4s ease-in-out infinite;
}

.wpflow-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.wpflow-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

/* ─── INPUT AREA ──────────────────────────────────────── */

.wpflow-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.wpflow-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.wpflow-chat-input:focus {
    border-color: var(--wpflow-primary, #004F6B);
}

.wpflow-chat-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.wpflow-chat-send {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--wpflow-primary, #004F6B);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.wpflow-chat-send:hover {
    opacity: 0.85;
}

.wpflow-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── POWERED BY ──────────────────────────────────────── */

.wpflow-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #aaa;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

/* ─── ANIMATIONS ──────────────────────────────────────── */

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

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

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

/* ─── RESPONSIVE ──────────────────────────────────────── */

@media (max-width: 480px) {
    .wpflow-chat-floating .wpflow-chat-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        max-width: none;
    }

    .wpflow-chat-floating .wpflow-bubble {
        bottom: 10px;
    }

    .wpflow-teaser {
        display: none;
    }
}

/* ─── DEVICE VISIBILITY (applied via JS) ──────────────── */

.wpflow-hide-device {
    display: none !important;
}

/* ─── TAKEOVER BANNER ─────────────────────────────────── */

.wpflow-system-banner {
    align-self: center;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    margin: 8px 0;
    max-width: 90%;
    text-align: center;
}

.wpflow-system-banner-takeover {
    background: #34c759;
}

.wpflow-system-banner-takeover-end {
    background: #86868b;
}
