/* ==========================================================================
   Webyan AI Live Assistant Widget (مستشار وبيان الرقمي)
   ========================================================================== */

:root {
    --wai-primary: #1264a3;
    --wai-primary-dark: #0a4373;
    --wai-primary-light: #298cd8;
    --wai-accent: #00d284;
    --wai-bg-glass: rgba(255, 255, 255, 0.95);
    --wai-border: rgba(226, 232, 240, 0.8);
    --wai-shadow: 0 20px 50px -10px rgba(10, 67, 115, 0.25), 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    --wai-radius: 22px;
}

.webyan-ai-widget {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 999999;
    direction: rtl;
    font-family: inherit;
    box-sizing: border-box;
}

.webyan-ai-widget * {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Floating Launcher Button
   -------------------------------------------------------------------------- */
.webyan-ai-toggle-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    min-width: 52px;
    max-width: 52px;
    padding: 0 13px;
    background: linear-gradient(135deg, #1264a3 0%, #0d8abc 25%, #5046e5 50%, #00b894 75%, #1264a3 100%);
    background-size: 300% 300%;
    animation: wai-bg-flow 8s ease infinite, wai-btn-pulse 3.5s ease-in-out infinite;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(18, 100, 163, 0.4);
    cursor: pointer;
    transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                padding 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.25s ease,
                box-shadow 0.25s ease;
    outline: none;
    user-select: none;
    overflow: hidden;
}

.webyan-ai-toggle-btn:hover {
    max-width: 320px;
    padding-inline-start: 14px;
    padding-inline-end: 18px;
    padding-block: 0;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 35px rgba(18, 100, 163, 0.52), 0 0 20px rgba(0, 210, 132, 0.35);
}

/* Light beam gloss reflection sweep across the button surface */
.webyan-ai-toggle-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        60deg,
        rgba(255, 255, 255, 0) 25%,
        rgba(255, 255, 255, 0.22) 50%,
        rgba(255, 255, 255, 0) 75%
    );
    transform: rotate(25deg) translateY(-120%);
    animation: wai-shine-sweep 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes wai-bg-flow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes wai-btn-pulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(18, 100, 163, 0.4), 0 0 0 0 rgba(18, 100, 163, 0.45);
    }
    50% {
        box-shadow: 0 10px 30px rgba(18, 100, 163, 0.5), 0 0 0 10px rgba(0, 210, 132, 0);
    }
}

@keyframes wai-shine-sweep {
    0%, 35% {
        transform: rotate(25deg) translateY(-120%);
    }
    65%, 100% {
        transform: rotate(25deg) translateY(120%);
    }
}

.webyan-ai-btn-glow {
    position: absolute;
    inset: -3px;
    border-radius: 54px;
    background: linear-gradient(90deg, #00d284, #298cd8, #6366f1, #00d284);
    background-size: 300% 300%;
    animation: wai-glow 6s linear infinite;
    opacity: 0.5;
    filter: blur(5px);
    z-index: -1;
    transition: opacity 0.3s ease, filter 0.3s ease;
    pointer-events: none;
}

.webyan-ai-toggle-btn:hover .webyan-ai-btn-glow {
    opacity: 0.85;
    filter: blur(7px);
}

@keyframes wai-glow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.webyan-ai-btn-icon {
    position: relative;
    z-index: 2;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.webyan-ai-btn-icon svg {
    width: 22px;
    height: 22px;
    transition: transform 0.3s ease;
}

/* Subtle breathing & sparkle animation for the AI bot/sparkle icon */
.webyan-ai-btn-icon .icon-sparkle {
    animation: wai-icon-sparkle 3.5s ease-in-out infinite;
    transform-origin: center;
}

.webyan-ai-toggle-btn:hover .icon-sparkle {
    animation: wai-icon-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes wai-icon-sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
    }
    20% {
        transform: scale(1.12) rotate(-6deg);
        filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.9));
    }
    40% {
        transform: scale(0.96) rotate(3deg);
        filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
    }
    60% {
        transform: scale(1.08) rotate(-3deg);
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
    }
    80% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
    }
}

@keyframes wai-icon-bounce {
    0% { transform: scale(1) rotate(0deg); }
    40% { transform: scale(1.22) rotate(12deg); }
    70% { transform: scale(0.95) rotate(-6deg); }
    100% { transform: scale(1.05) rotate(0deg); }
}

.webyan-ai-btn-icon .icon-close {
    display: none;
}

.webyan-ai-widget.is-open .webyan-ai-btn-icon .icon-sparkle {
    display: none;
    animation: none;
}

.webyan-ai-widget.is-open .webyan-ai-btn-icon .icon-close {
    display: block;
    animation: wai-close-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes wai-close-in {
    from {
        transform: rotate(-90deg) scale(0.7);
        opacity: 0;
    }
    to {
        transform: rotate(0deg) scale(1);
        opacity: 1;
    }
}

/* Label is collapsed/hidden by default, expands smoothly on hover */
.webyan-ai-btn-label {
    position: relative;
    z-index: 2;
    max-width: 0;
    opacity: 0;
    margin-inline-start: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
    transition: max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease,
                margin-inline-start 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.webyan-ai-toggle-btn:hover .webyan-ai-btn-label,
.webyan-ai-toggle-btn:focus-visible .webyan-ai-btn-label {
    max-width: 280px;
    opacity: 1;
    margin-inline-start: 8px;
}

/* Round compact button when chat window is active */
.webyan-ai-widget.is-open .webyan-ai-toggle-btn {
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #0a4373 !important;
    animation: none !important;
    box-shadow: 0 4px 15px rgba(10, 67, 115, 0.3) !important;
}

.webyan-ai-widget.is-open .webyan-ai-toggle-btn::after {
    display: none !important;
}

.webyan-ai-widget.is-open .webyan-ai-btn-glow {
    display: none !important;
}

.webyan-ai-widget.is-open .webyan-ai-toggle-btn:hover {
    max-width: 52px !important;
    padding: 0 !important;
}

.webyan-ai-widget.is-open .webyan-ai-toggle-btn .webyan-ai-btn-label {
    max-width: 0 !important;
    opacity: 0 !important;
    margin-inline-start: 0 !important;
    display: none !important;
}

/* --------------------------------------------------------------------------
   Chat Window (Glassmorphic)
   -------------------------------------------------------------------------- */
.webyan-ai-chat-window {
    position: absolute;
    bottom: 64px;
    left: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 100px);
    background: var(--wai-bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--wai-border);
    border-radius: var(--wai-radius);
    box-shadow: var(--wai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
    animation: wai-pop-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes wai-pop-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.webyan-ai-header {
    background: linear-gradient(135deg, var(--wai-primary) 0%, var(--wai-primary-dark) 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0 !important;
}

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

.webyan-ai-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}

.webyan-ai-avatar svg {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    flex-shrink: 0;
}

.webyan-ai-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--wai-accent);
    border: 2px solid var(--wai-primary);
    border-radius: 50%;
}

.webyan-ai-title-wrap {
    display: flex;
    flex-direction: column;
}

.webyan-ai-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
}

.webyan-ai-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}

.webyan-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.webyan-ai-action-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.webyan-ai-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.webyan-ai-action-btn svg {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Dual-Tab Header (محادثة المستشار & الأسئلة الشائعة)
   -------------------------------------------------------------------------- */
.webyan-ai-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--wai-border);
    user-select: none;
    flex-shrink: 0 !important;
}

.webyan-ai-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    background: transparent;
    color: #64748b;
    border: 1px solid transparent;
    border-radius: 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.webyan-ai-tab-btn svg {
    width: 15px !important;
    height: 15px !important;
    max-width: 15px !important;
    max-height: 15px !important;
    color: currentColor;
    flex-shrink: 0 !important;
}

.webyan-ai-tab-btn:hover {
    color: var(--wai-primary);
    background: rgba(255, 255, 255, 0.85);
}

.webyan-ai-tab-btn.is-active {
    background: #ffffff !important;
    color: var(--wai-primary) !important;
    border-color: rgba(18, 100, 163, 0.2) !important;
    box-shadow: 0 2px 8px rgba(18, 100, 163, 0.08) !important;
    font-weight: 700 !important;
}

.webyan-ai-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10.5px;
    font-weight: 700;
    background: rgba(18, 100, 163, 0.12);
    color: var(--wai-primary);
    transition: all 0.2s ease;
}

.webyan-ai-tab-btn.is-active .webyan-ai-tab-badge {
    background: var(--wai-primary) !important;
    color: #ffffff !important;
}

/* Tab Panels */
.webyan-ai-tab-panel {
    flex: 1 1 0% !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    min-height: 0 !important;
}

/* --------------------------------------------------------------------------
   FAQ Explorer Panel (مستكشف الأسئلة الشائعة والبحث الفوري)
   -------------------------------------------------------------------------- */
#webyan-ai-faq-panel {
    background: #ffffff;
    flex: 1 1 0% !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    min-height: 0 !important;
}

.webyan-ai-faq-search-wrap {
    padding: 12px 14px 8px 14px;
    background: #ffffff;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    flex-shrink: 0 !important;
}

.webyan-ai-faq-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.webyan-ai-faq-search-icon {
    position: absolute;
    right: 12px;
    width: 15px;
    height: 15px;
    color: #94a3b8;
    pointer-events: none;
}

.webyan-ai-faq-search-input {
    width: 100%;
    padding: 8px 36px 8px 28px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 12.5px;
    color: #1e293b;
    outline: none;
    transition: all 0.2s ease;
    direction: rtl;
}

.webyan-ai-faq-search-input:focus {
    background: #ffffff;
    border-color: var(--wai-primary-light);
    box-shadow: 0 0 0 3px rgba(41, 140, 216, 0.12);
}

.webyan-ai-faq-clear-btn {
    position: absolute;
    left: 8px;
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
}

.webyan-ai-faq-clear-btn:hover {
    color: #475569;
}

.webyan-ai-faq-list {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.webyan-ai-faq-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0 !important;
    box-sizing: border-box;
}

.webyan-ai-faq-item:hover {
    background: #ffffff;
    border-color: #cbd5e1;
}

.webyan-ai-faq-item.is-open {
    background: #ffffff;
    border-color: rgba(18, 100, 163, 0.3);
    box-shadow: 0 4px 14px rgba(18, 100, 163, 0.08);
}

.webyan-ai-faq-q {
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    font-family: inherit;
    text-align: right;
    direction: rtl;
    min-height: 46px;
    box-sizing: border-box;
}

.webyan-ai-faq-q-text {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.5;
    flex: 1;
    text-align: right;
}

.webyan-ai-faq-arrow {
    width: 16px;
    height: 16px;
    color: #94a3b8;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
}

.webyan-ai-faq-item.is-open .webyan-ai-faq-arrow {
    transform: rotate(180deg);
    color: var(--wai-primary);
}

.webyan-ai-faq-a {
    display: none;
    padding: 0 14px 14px 14px;
    border-top: 1px dashed rgba(226, 232, 240, 0.8);
    background: #ffffff;
    box-sizing: border-box;
    animation: wai-faq-expand 0.2s ease-out;
}

@keyframes wai-faq-expand {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.webyan-ai-faq-item.is-open .webyan-ai-faq-a {
    display: block !important;
}

.webyan-ai-faq-a-content {
    font-size: 12.5px;
    color: #475569;
    line-height: 1.65;
    word-break: break-word;
    padding-top: 10px;
}

.webyan-ai-faq-a-content p {
    margin: 0 0 6px 0;
}
.webyan-ai-faq-a-content p:last-child {
    margin-bottom: 0;
}

.webyan-ai-faq-a-actions {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
}

.webyan-ai-faq-ask-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(18, 100, 163, 0.08);
    color: var(--wai-primary);
    border: 1px solid rgba(18, 100, 163, 0.2);
    border-radius: 8px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.webyan-ai-faq-ask-btn svg {
    width: 14px;
    height: 14px;
}

.webyan-ai-faq-ask-btn:hover {
    background: var(--wai-primary);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(18, 100, 163, 0.25);
}

.webyan-ai-faq-empty {
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.webyan-ai-faq-empty svg {
    width: 38px;
    height: 38px;
    color: #cbd5e1;
}

.webyan-ai-faq-empty p {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

/* Messages Body */
.webyan-ai-messages-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.webyan-ai-msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    animation: wai-msg-slide 0.25s ease-out forwards;
}

@keyframes wai-msg-slide {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.webyan-ai-msg-user {
    align-self: flex-end;
}

.webyan-ai-msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
}

.webyan-ai-msg-assistant .webyan-ai-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.webyan-ai-msg-assistant .webyan-ai-msg-bubble p {
    margin: 0 0 8px 0;
}
.webyan-ai-msg-assistant .webyan-ai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.webyan-ai-msg-assistant .webyan-ai-msg-bubble ul,
.webyan-ai-msg-assistant .webyan-ai-msg-bubble ol {
    margin: 6px 0;
    padding-right: 20px;
}

.webyan-ai-msg-assistant .webyan-ai-msg-bubble li {
    margin-bottom: 4px;
}

.webyan-ai-msg-assistant .webyan-ai-msg-bubble a {
    color: var(--wai-primary);
    text-decoration: underline;
    font-weight: 600;
}

.webyan-ai-msg-user .webyan-ai-msg-bubble {
    background: linear-gradient(135deg, var(--wai-primary) 0%, var(--wai-primary-dark) 100%);
    color: #ffffff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 14px rgba(18, 100, 163, 0.28);
}

.webyan-ai-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
}

.webyan-ai-msg-user .webyan-ai-msg-time {
    text-align: left;
}

/* Typing Indicator & Streaming Cursor */
.webyan-ai-typing-cursor {
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--wai-primary);
    vertical-align: middle;
    margin-right: 3px;
    animation: wai-blink 0.8s infinite;
}

@keyframes wai-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Quick Action Chips */
.webyan-ai-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    animation: wai-msg-slide 0.3s ease-out;
}

.webyan-ai-chip {
    background: #ffffff;
    border: 1px solid rgba(18, 100, 163, 0.25);
    color: var(--wai-primary);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: right;
}

.webyan-ai-chip:hover {
    background: var(--wai-primary);
    color: #ffffff;
    border-color: var(--wai-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(18, 100, 163, 0.2);
}

/* Input Footer */
.webyan-ai-footer {
    padding: 12px 16px 10px 16px;
    background: #ffffff;
    border-top: 1px solid var(--wai-border);
}

.webyan-ai-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.webyan-ai-form:focus-within {
    border-color: var(--wai-primary-light);
    box-shadow: 0 0 0 3px rgba(41, 140, 216, 0.15);
}

.webyan-ai-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    color: #1e293b;
    outline: none;
    resize: none;
    max-height: 80px;
    padding: 4px 0;
    direction: rtl;
}

.webyan-ai-send-btn {
    background: var(--wai-primary);
    color: #ffffff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.webyan-ai-send-btn:hover:not(:disabled) {
    background: var(--wai-primary-dark);
    transform: scale(1.06);
}

.webyan-ai-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.7;
}

.webyan-ai-send-btn svg {
    width: 16px;
    height: 16px;
    transform: rotate(180deg);
}

.webyan-ai-footnote {
    text-align: center;
    font-size: 10.5px;
    color: #94a3b8;
    margin-top: 6px;
}

/* --------------------------------------------------------------------------
   Pre-Chat Lead Capture Overlay (نموذج بيانات الزائر قبل المحادثة)
   -------------------------------------------------------------------------- */
.webyan-ai-lead-overlay {
    position: absolute;
    top: 58px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-bottom-left-radius: var(--wai-radius);
    border-bottom-right-radius: var(--wai-radius);
    animation: wai-fade-in 0.25s ease-out;
}

.webyan-ai-lead-card {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.webyan-ai-lead-header {
    margin-bottom: 16px;
}

.webyan-ai-lead-badge {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(18, 100, 163, 0.12), rgba(0, 210, 132, 0.18));
    color: var(--wai-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.webyan-ai-lead-badge svg {
    width: 22px;
    height: 22px;
}

.webyan-ai-lead-title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.webyan-ai-lead-subtitle {
    font-size: 12px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

.webyan-ai-lead-form {
    display: flex;
    flex-direction: column;
    gap: 11px;
    text-align: right;
}

.webyan-ai-lead-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.webyan-ai-lead-field label {
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
}

.webyan-ai-lead-field .req-star {
    color: #ef4444;
}

.webyan-ai-lead-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    outline: none;
    background: #f8fafc;
    color: #1e293b;
    transition: all 0.2s ease;
}

.webyan-ai-lead-input:focus {
    border-color: var(--wai-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(18, 100, 163, 0.12);
}

.webyan-ai-lead-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    margin-top: 4px;
    background: linear-gradient(135deg, var(--wai-primary) 0%, var(--wai-primary-dark) 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(18, 100, 163, 0.28);
    transition: all 0.2s ease;
}

.webyan-ai-lead-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(18, 100, 163, 0.38);
}

.webyan-ai-lead-submit-btn svg {
    width: 15px;
    height: 15px;
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Action Cards (بطاقات الإجراءات المباشرة مثل تذاكر الدعم)
   -------------------------------------------------------------------------- */
.webyan-ai-ticket-card {
    background: linear-gradient(145deg, rgba(0, 210, 132, 0.08) 0%, rgba(18, 100, 163, 0.05) 100%);
    border: 1.5px solid rgba(0, 210, 132, 0.5);
    border-radius: 14px;
    padding: 12px 14px;
    margin: 4px 0;
    box-shadow: 0 4px 14px rgba(0, 210, 132, 0.12);
}

.webyan-ai-ticket-card strong {
    color: #065f46;
}

.webyan-ai-ticket-card a.webyan-ai-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--wai-primary), var(--wai-primary-dark));
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(18, 100, 163, 0.25);
    transition: all 0.2s ease;
}

.webyan-ai-ticket-card a.webyan-ai-link:hover {
    background: var(--wai-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(18, 100, 163, 0.35);
}

@keyframes wai-fade-in {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .webyan-ai-toggle-btn {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        max-width: 48px !important;
        padding: 0 !important;
        border-radius: 50% !important;
    }

    .webyan-ai-toggle-btn:hover,
    .webyan-ai-toggle-btn:focus-visible {
        max-width: 48px !important;
        padding: 0 !important;
        transform: none !important;
    }

    .webyan-ai-btn-label {
        display: none !important;
        max-width: 0 !important;
        opacity: 0 !important;
        margin: 0 !important;
    }
}

@media (max-width: 480px) {
    .webyan-ai-widget {
        bottom: 16px;
        left: 16px;
    }
    .webyan-ai-chat-window {
        bottom: 58px;
        left: 0;
        width: calc(100vw - 32px);
        height: 80vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .webyan-ai-toggle-btn,
    .webyan-ai-toggle-btn::after,
    .webyan-ai-btn-glow,
    .webyan-ai-btn-icon .icon-sparkle,
    .webyan-ai-widget.is-open .webyan-ai-btn-icon .icon-close {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   Dark Mode Support (:root[data-theme="dark"]) — مستشار وبيان الرقمي
   ========================================================================== */
:root[data-theme="dark"] {
    --wai-primary: #38d0f5;
    --wai-primary-dark: #1264a3;
    --wai-primary-light: #60a5fa;
    --wai-accent: #00e696;
    --wai-bg-glass: rgba(19, 26, 46, 0.94);
    --wai-border: rgba(255, 255, 255, 0.12);
    --wai-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.65), 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .webyan-ai-chat-window {
    background: rgba(19, 26, 46, 0.96) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7) !important;
}

:root[data-theme="dark"] .webyan-ai-header {
    background: linear-gradient(135deg, #162447 0%, #0f172a 100%) !important;
    border-bottom-color: rgba(255, 255, 255, 0.1) !important;
}

:root[data-theme="dark"] .webyan-ai-tabs {
    background: #0f1525 !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"] .webyan-ai-tab-btn {
    color: #94a3b8 !important;
}

:root[data-theme="dark"] .webyan-ai-tab-btn:hover {
    color: #38d0f5 !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

:root[data-theme="dark"] .webyan-ai-tab-btn.is-active {
    background: #161e36 !important;
    color: #38d0f5 !important;
    border-color: rgba(56, 208, 245, 0.3) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

:root[data-theme="dark"] .webyan-ai-tab-btn.is-active .webyan-ai-tab-badge {
    background: #38d0f5 !important;
    color: #0b1024 !important;
}

/* FAQ Explorer Dark Mode */
:root[data-theme="dark"] #webyan-ai-faq-panel {
    background: #131a2e !important;
}

:root[data-theme="dark"] .webyan-ai-faq-search-wrap {
    background: #131a2e !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"] .webyan-ai-faq-search-input {
    background: #0f1525 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #eaf0ff !important;
}

:root[data-theme="dark"] .webyan-ai-faq-search-input:focus {
    background: #161e36 !important;
    border-color: #38d0f5 !important;
}

:root[data-theme="dark"] .webyan-ai-faq-item {
    background: #0f1525 !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"] .webyan-ai-faq-item:hover {
    background: #161e36 !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
}

:root[data-theme="dark"] .webyan-ai-faq-item.is-open {
    background: #161e36 !important;
    border-color: rgba(56, 208, 245, 0.4) !important;
}

:root[data-theme="dark"] .webyan-ai-faq-q-text {
    color: #eaf0ff !important;
}

:root[data-theme="dark"] .webyan-ai-faq-a {
    background: #161e36 !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"] .webyan-ai-faq-a-content {
    color: #b6c0db !important;
}

:root[data-theme="dark"] .webyan-ai-faq-a-actions {
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"] .webyan-ai-faq-ask-btn {
    background: rgba(56, 208, 245, 0.12) !important;
    color: #38d0f5 !important;
    border-color: rgba(56, 208, 245, 0.25) !important;
}

/* Chat Assistant Bubbles Dark Mode */
:root[data-theme="dark"] .webyan-ai-messages-body {
    background: #131a2e !important;
}

:root[data-theme="dark"] .webyan-ai-msg-assistant .webyan-ai-msg-bubble {
    background: #161e36 !important;
    color: #eaf0ff !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

:root[data-theme="dark"] .webyan-ai-msg-assistant .webyan-ai-msg-bubble a {
    color: #38d0f5 !important;
}

:root[data-theme="dark"] .webyan-ai-msg-user .webyan-ai-msg-bubble {
    background: linear-gradient(135deg, #1f5a9f 0%, #1264a3 100%) !important;
    color: #ffffff !important;
}

:root[data-theme="dark"] .webyan-ai-msg-time {
    color: #8590b0 !important;
}

:root[data-theme="dark"] .webyan-ai-typing-cursor {
    background: #38d0f5 !important;
}

:root[data-theme="dark"] .webyan-ai-chip {
    background: #161e36 !important;
    border-color: rgba(56, 208, 245, 0.3) !important;
    color: #38d0f5 !important;
}

:root[data-theme="dark"] .webyan-ai-chip:hover {
    background: #38d0f5 !important;
    color: #0b1024 !important;
}

:root[data-theme="dark"] .webyan-ai-footer {
    background: #131a2e !important;
    border-top-color: rgba(255, 255, 255, 0.08) !important;
}

:root[data-theme="dark"] .webyan-ai-form {
    background: #0f1525 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

:root[data-theme="dark"] .webyan-ai-form:focus-within {
    border-color: #38d0f5 !important;
    box-shadow: 0 0 0 3px rgba(56, 208, 245, 0.2) !important;
}

:root[data-theme="dark"] .webyan-ai-input {
    color: #eaf0ff !important;
}

:root[data-theme="dark"] .webyan-ai-input::placeholder {
    color: #8590b0 !important;
}

/* Pre-Chat Lead Overlay Dark Mode */
:root[data-theme="dark"] .webyan-ai-lead-overlay {
    background: rgba(19, 26, 46, 0.97) !important;
}

:root[data-theme="dark"] .webyan-ai-lead-title {
    color: #eaf0ff !important;
}

:root[data-theme="dark"] .webyan-ai-lead-subtitle {
    color: #b6c0db !important;
}

:root[data-theme="dark"] .webyan-ai-lead-field label {
    color: #b6c0db !important;
}

:root[data-theme="dark"] .webyan-ai-lead-input {
    background: #0f1525 !important;
    border-color: rgba(255, 255, 255, 0.14) !important;
    color: #eaf0ff !important;
}

:root[data-theme="dark"] .webyan-ai-lead-input:focus {
    background: #161e36 !important;
    border-color: #38d0f5 !important;
    box-shadow: 0 0 0 3px rgba(56, 208, 245, 0.2) !important;
}

:root[data-theme="dark"] .webyan-ai-lead-submit-btn {
    background: linear-gradient(135deg, #25b9dc 0%, #1f5a9f 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(37, 185, 220, 0.3) !important;
}

:root[data-theme="dark"] .webyan-ai-ticket-card {
    background: linear-gradient(145deg, rgba(0, 230, 150, 0.1) 0%, rgba(56, 208, 245, 0.08) 100%) !important;
    border-color: rgba(0, 230, 150, 0.4) !important;
}

:root[data-theme="dark"] .webyan-ai-ticket-card strong {
    color: #34d399 !important;
}

