/* ============================================================================
   robot.css — مساعد الإعداد في لوحة العميل (robot.js)

   كان صورة PNG ثلاثية الأبعاد بعرض 160px على قاعدة، بطبقة z-index أعلى من
   كل شيء: تغطي بطاقات المؤشرات، وعلى الجوال تجلس فوق حقل كتابة المحادثة.
   صار زر إطلاق صغيرًا (44px) بأيقونة SVG بلون الهوية، مكدّسًا فوق زر الدعم
   المباشر في نفس الركن (نهاية السطر = أسفل اليسار في RTL)، ويختفي حين تكون
   المحادثة مفتوحة حتى لا يتزاحم عنصران عائمان.

   الألوان من توكنز الصفحة المضيفة (--color-*) بقيم احتياطية، فيتبع الوضع
   الليلي/النهاري. أنماط Driver.js في آخر الملف كما هي (تستخدمها صفحات أخرى).
   ========================================================================== */

.robot-container {
    --ra-surface: var(--color-surface, #ffffff);
    --ra-surface-2: var(--color-muted, #f3f6fa);
    --ra-border: var(--color-border, rgba(0, 51, 102, 0.12));
    --ra-text: var(--color-text, #16202b);
    --ra-text-2: var(--color-text-secondary, #4d5a69);
    --ra-accent: var(--color-accent, #0077cc);
    --ra-brand: #003366;
    --ra-brand-2: #0055aa;

    position: fixed;
    /* فوق زر الدعم المباشر (56px + 24px + فاصل 12px) */
    bottom: 92px;
    left: 24px;
    z-index: 9997;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    pointer-events: none;
    font-family: 'Cairo', system-ui, sans-serif;
    direction: rtl;
}

.robot-container > * { pointer-events: auto; }

/* المحادثة المفتوحة تأخذ الركن كله — المساعد يتنحّى */
body.chat-widget-open .robot-container { display: none; }

/* ── زر الإطلاق ─────────────────────────────────────────────────────────── */
.robot-avatar {
    position: relative;
    order: 2;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--ra-border);
    background: var(--ra-surface);
    color: var(--ra-brand-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 20px -8px rgba(0, 28, 58, 0.35), 0 1px 3px rgba(0, 28, 58, 0.08);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

[data-theme='dark'] .robot-avatar { color: #8fc7ff; }

.robot-avatar:hover { transform: translateY(-1px); border-color: var(--ra-accent); }
.robot-avatar:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.35); }
.robot-avatar[aria-expanded='true'] { border-color: var(--ra-accent); }
.robot-avatar svg { width: 24px; height: 24px; }

/* تلميح نصي عند التحويم — ناحية بداية السطر (يمين الزر) */
.robot-avatar-label {
    position: absolute;
    inset-inline-end: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--ra-brand);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease, transform .15s ease;
}

.robot-avatar:hover .robot-avatar-label,
.robot-avatar:focus-visible .robot-avatar-label { opacity: 1; transform: translateY(-50%); }
.robot-avatar[aria-expanded='true'] .robot-avatar-label { display: none; }

.robot-notify-dot {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--color-danger, #e03b3b);
    border: 2px solid var(--ra-surface);
    display: none;
}
.robot-notify-dot.show { display: block; }

/* ── لوحة المساعد ───────────────────────────────────────────────────────── */
.speech-bubble {
    order: 1;
    width: 340px;
    max-width: calc(100vw - 48px);
    max-height: min(560px, calc(100vh - 190px));
    max-height: min(560px, calc(100dvh - 190px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: var(--ra-surface);
    color: var(--ra-text);
    border: 1px solid var(--ra-border);
    border-radius: 16px;
    box-shadow: 0 24px 50px -14px rgba(0, 28, 58, 0.32), 0 3px 10px rgba(0, 28, 58, 0.08);
    transform-origin: bottom left;
}

/* كان .assistant-mode يفرض display:flex على اللوحة المخفية بـopacity:0 —
   أي طبقة غير مرئية بعرض 360px تبتلع النقرات فوق المحتوى. الآن مخفية فعلًا. */
.speech-bubble.visible { display: flex; animation: raIn .2s cubic-bezier(.2, .8, .2, 1); }

@keyframes raIn {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.robot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 10px 14px;
    flex-shrink: 0;
}

.robot-header-mark {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--ra-brand), var(--ra-brand-2));
}

.robot-header-mark svg { width: 19px; height: 19px; }
.robot-header-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.robot-name { font-size: 14px; font-weight: 800; color: var(--ra-text); line-height: 1.3; }
.robot-subtitle { font-size: 12px; color: var(--ra-text-2); }

.robot-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success, #16a36a);
    flex-shrink: 0;
}

.robot-text { margin: 0; font-size: 14px; line-height: 1.7; color: var(--ra-text); }

.tour-btn {
    width: 100%;
    margin-top: 12px;
    padding: 9px 16px;
    border: 0;
    border-radius: 10px;
    background: var(--ra-accent);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 640px) {
    .robot-container { bottom: 84px; left: 16px; }
    .speech-bubble { width: calc(100vw - 32px); max-width: 380px; }
}

@media (prefers-reduced-motion: reduce) {
    .robot-avatar, .speech-bubble.visible { transition: none; animation: none; }
}

/* ============================================================
   Driver.js Customization - Making all popovers professional
   ============================================================ */

.driver-popover.driverjs-theme {
    direction: rtl;
    text-align: right;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(15px) !important;
    border-radius: 1.5rem !important;
    border: 1px solid rgba(0, 119, 204, 0.15) !important;
    border-right: 6px solid var(--color-accent) !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2) !important;
    padding: 1.5rem !important;
    max-width: 350px !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

.driver-popover-title {
    font-size: 1.2rem !important;
    font-weight: 800 !important;
    color: var(--color-accent) !important;
    margin-bottom: 12px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    padding-bottom: 10px !important;
    display: block !important;
}

.driver-popover-description {
    font-size: 1rem !important;
    line-height: 1.7 !important;
    color: #2c3e50 !important;
    font-weight: 500 !important;
    margin-bottom: 15px !important;
}

.driver-popover-footer {
    display: flex !important;
    justify-content: space-between !important;
    gap: 10px !important;
    margin-top: 15px !important;
}

.driver-popover-btn {
    flex: 1 !important;
    text-align: center !important;
    padding: 8px 15px !important;
    border-radius: 25px !important;
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    transition: all 0.3s !important;
    text-shadow: none !important;
    border: none !important;
}

/* زر التالي */
.driver-popover-next-btn {
    background: linear-gradient(135deg, var(--color-accent), #0055AA) !important;
    color: white !important;
}

.driver-popover-next-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(0, 119, 204, 0.3) !important;
}

/* زر السابق */
.driver-popover-prev-btn {
    background: #f0f0f0 !important;
    color: #555 !important;
}

.driver-popover-prev-btn:hover {
    background: #e0e0e0 !important;
}

/* زر الإغلاق/تم */
.driver-popover-close-btn {
    color: #999 !important;
}

.driver-popover-progress-text {
    font-size: 0.85rem !important;
    color: #777 !important;
    font-weight: 600 !important;
}

/* تخصيص السهم */
.driver-popover-arrow {
    border-color: rgba(255, 255, 255, 0.98) !important;
}
