/* ==========================================================================
   Wapflow OS — Premium Support Widget with Human Support & Dual AI Chat
   ========================================================================== */

/* Wrapper fixed in bottom-right corner */
.wos-support-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    pointer-events: auto;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

.wos-support-wrapper.wos-pos-left {
    right: auto;
    left: 24px;
}

[dir="rtl"] .wos-support-wrapper {
    right: auto;
    left: 24px;
}

[dir="rtl"] .wos-support-wrapper.wos-pos-left {
    left: auto;
    right: 24px;
}

/* Floating Launcher Trigger */
.wos-support-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    padding: 6px 14px 6px 6px;
    border-radius: 9999px;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
    cursor: pointer;
    user-select: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.wos-support-launcher:hover,
.wos-support-launcher:focus-visible {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 32px rgba(14, 165, 233, 0.2), 0 4px 10px rgba(15, 23, 42, 0.1);
    border-color: rgba(14, 165, 233, 0.4);
}

.wos-launcher-avatar-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.wos-launcher-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
    display: block;
}

.wos-online-pulse-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #22c55e;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: wos-pulse 2s infinite;
}

@keyframes wos-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.wos-launcher-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

[dir="rtl"] .wos-launcher-text {
    text-align: right;
}

.wos-launcher-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
}

.wos-launcher-subtitle {
    font-size: 11px;
    color: #16a34a;
    font-weight: 600;
    line-height: 1.2;
}

/* Support Popup Panel */
.wos-support-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
    display: none;
    flex-direction: column;
    transform-origin: bottom right;
    animation: wos-panel-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[dir="rtl"] .wos-support-panel {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.wos-support-panel.wos-open {
    display: flex;
}

@keyframes wos-panel-pop {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(16px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Panel Header */
.wos-panel-header {
    background: #0b1329;
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wos-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wos-header-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #22c55e;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.wos-header-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.wos-header-status {
    font-size: 11px;
    color: #4ade80;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.wos-header-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}

.wos-panel-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}

.wos-panel-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Support Representative Photo */
.wos-representative-container {
    position: relative;
    width: 100%;
    height: 180px;
    background: #f1f5f9;
    overflow: hidden;
}

.wos-representative-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 15%;
    display: block;
    transition: transform 0.4s ease;
}

.wos-support-panel:hover .wos-representative-img {
    transform: scale(1.02);
}

.wos-representative-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* Panel Body & Chat Bubble */
.wos-panel-body {
    padding: 14px 16px 16px 16px;
    background: #ffffff;
}

.wos-speech-bubble {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.wos-speech-text {
    font-size: 13px;
    color: #1e293b;
    line-height: 1.45;
    margin: 0;
}

.wos-speech-time {
    font-size: 10px;
    color: #94a3b8;
    text-align: right;
    margin-top: 6px;
}

.wos-options-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    margin-bottom: 8px;
}

/* Dual Chat Action Buttons */
.wos-actions-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wos-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

/* Option A: WhatsApp Button */
.wos-chat-btn-whatsapp {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}

.wos-chat-btn-whatsapp:hover,
.wos-chat-btn-whatsapp:focus-visible {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35);
}

/* Option B: AI Assistant Button */
.wos-chat-btn-ai {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.wos-chat-btn-ai:hover,
.wos-chat-btn-ai:focus-visible {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
}

.wos-chat-btn-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.wos-chat-btn-arrow {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.85;
}

[dir="rtl"] .wos-chat-btn-arrow {
    margin-left: 0;
    margin-right: auto;
    transform: rotate(180deg);
}

.wos-chat-btn-content {
    display: flex;
    flex-direction: column;
    text-align: left;
    flex-grow: 1;
    min-width: 0;
}

[dir="rtl"] .wos-chat-btn-content {
    text-align: right;
}

.wos-chat-btn-title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    color: #ffffff;
    display: block;
}

.wos-chat-btn-sub {
    font-size: 11px;
    opacity: 0.9;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.9);
    display: block;
}

/* AI Dialog / Live Chat Inside Widget */
.wos-ai-modal-view {
    display: none;
    flex-direction: column;
    height: 480px;
    background: #ffffff;
}

.wos-ai-modal-view.wos-active {
    display: flex;
}

.wos-ai-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #0b1329;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.wos-ai-header-back-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wos-ai-header-back-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.25);
}

.wos-ai-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wos-ai-header-avatar {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    overflow: hidden;
}

.wos-ai-header-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    display: block;
}

.wos-ai-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    border: 1.5px solid #ffffff;
    z-index: 2;
}

.wos-ai-header-title {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.wos-ai-header-sub {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.2;
}

/* Scrollable message stream */
.wos-ai-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    background: #ffffff;
}

.wos-ai-message-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wos-msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
    animation: wosFadeIn 0.25s ease-out;
}

@keyframes wosFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.wos-msg-ai {
    align-self: flex-start;
}

.wos-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.wos-msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    flex-shrink: 0;
    margin-top: 2px;
    overflow: hidden;
}

.wos-msg-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    display: block;
}

.wos-msg-bubble {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 12.5px;
    line-height: 1.45;
}

.wos-msg-ai .wos-msg-bubble {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
}

.wos-msg-user .wos-msg-bubble {
    background: linear-gradient(135deg, #1e3a8a 0%, #0284c7 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.25);
}

/* Suggestion quick chips */
.wos-ai-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    padding-left: 32px;
}

.wos-ai-chip {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    padding: 4px 10px;
    font-size: 11px;
    color: #334155;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.2s;
    line-height: 1.3;
}

.wos-ai-chip:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #0f172a;
}

.wos-ai-chip-wa {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.wos-ai-chip-wa:hover {
    background: #dcfce7;
    border-color: #4ade80;
}

/* Typing animated dots */
.wos-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.wos-dot {
    width: 6px;
    height: 6px;
    background-color: #6366f1;
    border-radius: 50%;
    animation: wosBounce 1.4s infinite ease-in-out both;
}

.wos-dot:nth-child(1) { animation-delay: -0.32s; }
.wos-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes wosBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Honest status card inside message stream */
.wos-ai-status-notice {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 10px;
    padding: 10px;
    margin-top: 6px;
    font-size: 11.5px;
    color: #92400e;
}

.wos-ai-status-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: #22c55e;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 11.5px;
    text-decoration: none !important;
    transition: background 0.2s;
}

.wos-ai-status-btn:hover {
    background: #16a34a;
}

/* Input Form at bottom */
.wos-ai-input-form {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.wos-ai-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    outline: none;
    transition: border-color 0.2s;
    background: #ffffff;
    color: #0f172a;
}

.wos-ai-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.wos-ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1e3a8a, #0284c7);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
}

.wos-ai-send-btn:hover {
    background: linear-gradient(135deg, #172554, #0369a1);
}

.wos-ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .wos-online-pulse-dot {
        animation: none !important;
    }
    .wos-support-panel {
        animation: none !important;
    }
    .wos-support-launcher:hover {
        transform: none !important;
    }
}

/* Mobile responsive constraints */
@media (max-width: 576px) {
    .wos-support-wrapper {
        bottom: 16px;
        right: 16px;
    }
    [dir="rtl"] .wos-support-wrapper {
        right: auto;
        left: 16px;
    }
    .wos-support-panel {
        width: calc(100vw - 32px);
        bottom: 56px;
        right: 0;
    }
    .wos-representative-container {
        height: 150px;
    }
}


/* ==========================================================================
   WAPFLOW OS COMPLETE SUPPORT PILL — UNIVERSAL DRAGGABLE & RESPONSIVE ENGINE
   ========================================================================== */

/* The floating support pill launcher: entire pill is pressable and draggable */
.wos-support-launcher {
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    cursor: grab !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 12px !important;
    background: #ffffff !important;
    padding: 7px 18px 7px 8px !important;
    border-radius: 9999px !important;
    border: 1.5px solid rgba(226, 232, 240, 0.95) !important;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16), 0 3px 8px rgba(15, 23, 42, 0.08) !important;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease !important;
    max-width: calc(100vw - 24px) !important;
    box-sizing: border-box !important;
}

.wos-support-launcher:hover {
    box-shadow: 0 14px 36px rgba(14, 165, 233, 0.22), 0 4px 12px rgba(15, 23, 42, 0.1) !important;
}

/* While actively dragging anywhere on the pill */
.wos-support-launcher.wos-is-dragging {
    cursor: grabbing !important;
    opacity: 0.94 !important;
    transform: scale(1.03) !important;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28), 0 6px 16px rgba(15, 23, 42, 0.15) !important;
    transition: none !important;
}

/* Text inside launcher */
.wos-launcher-text {
    display: flex !important;
    flex-direction: column !important;
    text-align: left !important;
    min-width: 0 !important;
    flex: 1 !important;
}

[dir="rtl"] .wos-launcher-text {
    text-align: right !important;
}

.wos-launcher-title {
    font-size: 13.5px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.wos-launcher-subtitle {
    font-size: 11px !important;
    color: #16a34a !important;
    font-weight: 600 !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: flex !important;
    align-items: center !important;
}

/* Responsive adjustment for small mobile screens (320px - 430px) */
@media (max-width: 576px) {
    .wos-support-launcher {
        padding: 6px 14px 6px 6px !important;
        gap: 8px !important;
        max-width: min(320px, calc(100vw - 20px)) !important;
    }

    .wos-launcher-avatar-wrap {
        width: 40px !important;
        height: 40px !important;
    }

    .wos-launcher-title {
        font-size: 12.5px !important;
    }

    .wos-launcher-subtitle {
        font-size: 10px !important;
    }

    /* Support Popup Panel on Mobile */
    .wos-support-panel {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;
        width: calc(100vw - 24px) !important;
        max-width: 400px !important;
        max-height: 85vh !important;
        margin: 0 auto !important;
        border-radius: 16px !important;
        box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35) !important;
        z-index: 100000 !important;
    }

    .wos-support-panel .wos-representative-container {
        height: 130px !important;
    }

    .wos-support-panel .wos-panel-body {
        padding: 14px !important;
        max-height: calc(85vh - 190px) !important;
        overflow-y: auto !important;
    }

    .wos-ai-modal-view.wos-active {
        max-height: 85vh !important;
    }
}
