/* ==========================================================================
   Chatbot & Intro Styles (chatbot.css) - نالش
   يحتوي على: الروبوت الذكي، واجهة الدردشة، الانترو السينمائي، وحركات البناء
   ========================================================================== */

/* ================= 1. شاشة التحميل والانترو (Splash & Intro) ================= */
#smart-splash-screen {
    position: fixed; 
    inset: 0; 
    z-index: 999999;
    background: #f8fafc;
    display: flex; 
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    overflow: hidden;
    transition: opacity 0.6s ease-out, background-color 0.4s ease;
    will-change: opacity;
}
html.dark-mode #smart-splash-screen { background: #0b1120; }

.intro-bg-glow {
    position: absolute; width: 100vw; height: 100vw;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.05) 0%, transparent 70%);
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    pointer-events: none;
}
html.dark-mode .intro-bg-glow { background: radial-gradient(circle, rgba(0, 198, 251, 0.08) 0%, transparent 60%); }

.nalsh-brand-intro {
    font-family: 'Tajawal', sans-serif;
    font-size: 4.5rem; font-weight: 900; letter-spacing: 12px;
    display: flex; gap: 4px; z-index: 2; margin-top: 130px; direction: ltr;
}
.nalsh-brand-intro span {
    opacity: 0; transform: translateY(30px) scale(0.8);
    animation: letterBounce 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.nalsh-brand-intro span:nth-child(1) { animation-delay: 0.1s; color: #4F46E5; }
.nalsh-brand-intro span:nth-child(2) { animation-delay: 0.2s; color: #3b82f6; }
.nalsh-brand-intro span:nth-child(3) { animation-delay: 0.3s; color: #06b6d4; }
.nalsh-brand-intro span:nth-child(4) { animation-delay: 0.4s; color: #14b8a6; }
.nalsh-brand-intro span:nth-child(5) { animation-delay: 0.5s; color: #10B981; }

html.dark-mode .nalsh-brand-intro span { text-shadow: 0 0 15px currentColor; }
html.dark-mode .nalsh-brand-intro span:nth-child(1) { color: #a855f7; }
html.dark-mode .nalsh-brand-intro span:nth-child(2) { color: #ec4899; }
html.dark-mode .nalsh-brand-intro span:nth-child(3) { color: #3b82f6; }
html.dark-mode .nalsh-brand-intro span:nth-child(4) { color: #00c6fb; }
html.dark-mode .nalsh-brand-intro span:nth-child(5) { color: #2dd4bf; }

.intro-loader-line {
    width: 200px; height: 4px; background: rgba(0, 0, 0, 0.05);
    margin-top: 35px; border-radius: 50px; position: relative; overflow: hidden; z-index: 2;
}
.intro-loader-line::after {
    content: ''; position: absolute; top: 0; left: 0; height: 100%; width: 30%;
    background: linear-gradient(90deg, #4F46E5, #06b6d4); border-radius: 50px;
    animation: loaderScan 1s ease-in-out infinite alternate;
}
html.dark-mode .intro-loader-line { background: rgba(255, 255, 255, 0.05); }
html.dark-mode .intro-loader-line::after { background: linear-gradient(90deg, #a855f7, #00c6fb); box-shadow: 0 0 10px #00c6fb; }

.intro-status-text {
    margin-top: 15px; font-size: 0.9rem; font-weight: 800;
    color: #64748b; letter-spacing: 1px; z-index: 2; animation: pulseOpacity 1.5s infinite;
}
html.dark-mode .intro-status-text { color: #94a3b8; }

/* إخفاء المحتوى وعمليات البناء */
#main-content, .header-container, .mobile-bar, .isolated-header, .isolated-bottom-bar {
    opacity: 0; visibility: hidden; transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease, visibility 0.8s ease; pointer-events: none; 
}
body.store-ready #main-content, body.store-ready .header-container, body.store-ready .mobile-bar, body.store-ready .isolated-header, body.store-ready .isolated-bottom-bar {
    opacity: 1 !important; visibility: visible !important; transform: translateY(0); pointer-events: auto;
}
body.intro-locked { overflow: hidden !important; touch-action: none; pointer-events: none; }
#smart-splash-screen, .cyber-robot, .robot-speech-bubble { pointer-events: auto !important; }

.intro-hidden { opacity: 0; transform: translateY(40px) scale(0.95); filter: blur(10px); pointer-events: none; }
.intro-reveal { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); pointer-events: auto; transition: opacity 0.6s ease-out, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.4s ease-out; }

.build-laser {
    position: fixed; height: 4px; background: linear-gradient(90deg, var(--primary), #00ffff, #ffffff);
    box-shadow: 0 0 15px #00ffff, 0 0 30px var(--primary); border-radius: 4px;
    z-index: 100000; transform-origin: left center; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.building-flash { animation: element-build-flash 0.8s ease-out forwards; }

/* عناصر الانترو الاحتياطية (الهولوجرام) */
.boot-loader-wrap { text-align: center; position: relative; z-index: 10; }
.boot-percentage { font-size: 3.5rem; font-weight: 900; line-height: 1; background: linear-gradient(135deg, #fff, var(--primary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-family: monospace; }
.boot-label { font-size: 1rem; color: var(--text-muted); font-weight: 800; margin-top: 10px; letter-spacing: 2px; text-transform: uppercase; }
.hologram-platform { width: 200px; height: 20px; background: var(--primary); filter: blur(40px); border-radius: 50%; opacity: 0.4; position: absolute; bottom: -40px; left: 50%; transform: translateX(-50%); }
.cyber-grid-bg { position: absolute; inset: -50%; background-image: linear-gradient(rgba(0, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 255, 255, 0.05) 1px, transparent 1px); background-size: 40px 40px; transform: perspective(500px) rotateX(60deg) translateY(-100px); animation: gridMove 10s linear infinite; z-index: 1; }
.hologram-base { position: relative; z-index: 2; width: 200px; height: 200px; display: flex; justify-content: center; align-items: center; transform: translateY(60px); }
.loading-core { position: absolute; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.8); width: 140px; height: 140px; border-radius: 50%; box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.2); backdrop-filter: blur(5px); }
.loading-percentage { font-size: 2.8rem; font-weight: 900; background: linear-gradient(135deg, #00ffff, #3b82f6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-family: monospace; letter-spacing: -2px; }
.loading-status { font-size: 0.85rem; font-weight: 800; color: #94a3b8; margin-top: 5px; height: 20px; transition: color 0.3s; }
.hologram-ring { transform: rotate(-90deg); filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.5)); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.05); stroke-width: 6; }
.ring-progress { fill: none; stroke: #00ffff; stroke-width: 6; stroke-dasharray: 502; stroke-dashoffset: 502; stroke-linecap: round; transition: stroke-dashoffset 0.2s ease-out, stroke 0.5s; }

/* ================= 2. تصميم الروبوت الأساسي (Cyber Robot) ================= */
.cyber-robot {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 15px) !important;
    left: 20px;
    width: 50px !important; 
    height: 58px !important;
    background: linear-gradient(135deg, #00c6fb, #005bea);
    border-radius: 40% 40% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 10px 25px rgba(0, 198, 251, 0.5);
    z-index: 999999 !important;
    cursor: pointer;
    will-change: transform, opacity;
    animation: floatHoverGPU 3s ease-in-out infinite;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.4s, opacity 0.4s, left 0.4s ease, right 0.4s ease, bottom 0.4s ease !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* تفاصيل الروبوت */
.cyber-visor { position: absolute; top: 16px !important; left: 8px !important; right: 8px !important; height: 20px !important; background: #0f172a; border-radius: 15px; display: flex; justify-content: space-evenly; align-items: center; box-shadow: inset 0 0 10px rgba(0,0,0,0.8); overflow: hidden; transition: justify-content 0.5s ease; }
.cyber-eye { width: 8px !important; height: 8px !important; background: #00ffff; border-radius: 50%; box-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); animation: cyberBlink 4s infinite; }
.cyber-antenna { position: absolute; top: -10px !important; left: 50%; transform: translateX(-50%); width: 3px !important; height: 10px !important; background: #cbd5e1; border-radius: 2px; }
.cyber-antenna::after { content: ''; position: absolute; top: -5px !important; left: -1.5px; width: 6px !important; height: 6px !important; background: #00ffff; border-radius: 50%; box-shadow: 0 0 10px #00ffff; animation: pulseGlow 1.5s infinite; }
.cyber-wing { position: absolute; top: 24px !important; width: 12px !important; height: 20px !important; background: rgba(255,255,255,0.2); backdrop-filter: blur(5px); border-radius: 10px; }
.cyber-wing.left { left: -10px; transform: rotate(-15deg); }
.cyber-wing.right { right: -10px; transform: rotate(15deg); }

/* حالات ومشاعر الروبوت */
.cyber-robot.eyes-closed .cyber-eye { height: 2px; border-radius: 2px; background: #008888; box-shadow: 0 0 5px #008888; animation: none; }
.cyber-robot.eyes-happy .cyber-robot.discount-magic .cyber-eye { border-radius: 50% 50% 0 0; height: 8px; transform: translateY(-2px); animation: none; background: #ffffff; box-shadow: 0 0 15px #ffffff; }
.cyber-robot.look-up { transform: translateY(-10px) rotate(5deg); }
.cyber-robot:hover:not(.in-cart):not(.discount-magic):not(.status-processing):not(.status-delivery):not(.status-completed):not(.intro-mode) { transform: scale(1.1); }

/* أوضاع الروبوت الخاصة */
.cyber-robot.intro-mode { top: 25% !important; left: 50% !important; bottom: auto !important; transform: translate3d(-50%, -50%, 0) scale(1.5) !important; z-index: 9999999 !important; pointer-events: none !important; }
.cyber-robot.intro-mode::after { content: ''; position: absolute; bottom: -60px; left: 50%; transform: translateX(-50%); width: 100px; height: 30px; background: radial-gradient(ellipse, rgba(0, 198, 251, 0.4) 0%, transparent 70%); animation: pulseBase 1.5s infinite alternate; }

.cyber-robot.status-processing { background: linear-gradient(135deg, #f59e0b, #d97706) !important; box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important; animation: floatHoverGPU 1s ease-in-out infinite !important; }
.cyber-robot.status-processing .cyber-eye { background: #fff; box-shadow: 0 0 15px #fff; border-radius: 2px; width: 15px; height: 4px; animation: robotScan 0.8s infinite alternate !important; }

.cyber-robot.status-delivery { background: linear-gradient(135deg, #3b82f6, #60a5fa) !important; box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important; animation: robotZoom 0.4s ease infinite alternate !important; transform: skewX(-10deg) translateY(-15px); }
.cyber-robot.status-delivery .cyber-wing { height: 35px; background: rgba(255,255,255,0.9); box-shadow: 0 0 15px #fff; animation: wingFlap 0.1s infinite alternate; }

.cyber-robot.status-completed { background: linear-gradient(135deg, #10b981, #34d399) !important; box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important; animation: spinHappy 1.2s ease-in-out 2 !important; }
.cyber-robot.status-completed .cyber-eye { border-radius: 50% 50% 0 0; height: 8px; transform: translateY(-2px); background: #ffffff; box-shadow: 0 0 15px #ffffff; }

.cyber-robot.in-cart { transform: translate3d(calc(100vw - 110px), -80px, 0) scale(0.75) !important; z-index: 1002; animation: cartHoverGPU 2.5s ease-in-out infinite; }
.cyber-robot.in-cart .cyber-visor { justify-content: flex-end; }

.cyber-robot.discount-magic { animation: bounceGlow 1s ease infinite !important; background: linear-gradient(135deg, #f6d365, #fda085); box-shadow: 0 10px 30px rgba(253, 160, 133, 0.8), inset 0px -5px 15px rgba(255,255,255,0.5); }
.cyber-robot.discount-magic .cyber-antenna::after { background: #ff0000; box-shadow: 0 0 15px #ff0000; }

/* توجيه الروبوت لليمين عند فتح نافذة */
body.body-no-scroll .cyber-robot:not(.intro-mode) { left: auto !important; right: 15px !important; bottom: calc(var(--bottom-nav-height) + 140px) !important; transform: scale(0.85) !important; z-index: 20000 !important; }

/* ================= 3. فقاعة الكلام (Speech Bubble) ================= */
.robot-speech-bubble {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 85px) !important;
    left: 20px;
    background: var(--bg-card);
    color: var(--text-main);
    padding: 8px 14px !important;
    border-radius: 20px 20px 20px 0;
    font-size: 0.85rem !important;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border: 1.5px solid var(--primary);
    z-index: 1000000 !important;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transform-origin: bottom left;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto !important;
    max-width: 200px !important;
    line-height: 1.5;
}
.robot-speech-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
.robot-speech-bubble::after {
    content: ''; position: absolute; bottom: -10px; left: 15px;
    border-width: 10px 10px 0 0; border-style: solid; border-color: var(--primary) transparent transparent transparent;
}
/* نقل الفقاعة لليمين مع الروبوت */
body.body-no-scroll .robot-speech-bubble {
    left: auto !important; right: 15px !important;
    bottom: calc(var(--bottom-nav-height) + 205px) !important;
    border-radius: 20px 20px 0 20px !important;
    z-index: 20000 !important; transform-origin: bottom right !important;
}
body.body-no-scroll .robot-speech-bubble::after {
    left: auto !important; right: 15px !important;
    border-width: 10px 0 0 10px !important; 
    border-color: var(--primary) transparent transparent transparent !important;
}

/* ================= 4. نافذة الدردشة (Chat Window) ================= */
#nalsh-chat-overlay {
    position: fixed; inset: 0; z-index: 10001; display: flex; justify-content: center; align-items: center;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
}
#nalsh-chat-overlay.open { opacity: 1; visibility: visible; }

.nalsh-chat-window {
    width: 90%; max-width: 420px; height: 85vh; max-height: 650px;
    background: var(--bg-body); border-radius: var(--radius-xl);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3);
    display: flex; flex-direction: column; transform: scale(0.95); transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); border: none;
}
#nalsh-chat-overlay.open .nalsh-chat-window { transform: scale(1); }

.nalsh-chat-header {
    padding: 10px 15px !important; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 15px; flex-shrink: 0;
    background: linear-gradient(135deg, #00c6fb, #005bea); border-top-left-radius: var(--radius-xl); border-top-right-radius: var(--radius-xl); color: white;
}
.nalsh-avatar { width: 35px !important; height: 35px !important; border-radius: 50%; background: rgba(255,255,255,0.2); font-size: 1.2rem !important; display: flex; justify-content: center; align-items: center; }
.nalsh-chat-header .info h4 { font-weight: 900; margin: 0; font-size: 1rem !important; margin-bottom: 2px !important; }
.nalsh-chat-header .info p { color: rgba(255,255,255,0.8); font-size: 0.75rem !important; font-weight: 500; margin: 0; }
.nalsh-chat-close { margin-right: auto; cursor: pointer; font-size: 1.5rem; color: rgba(255,255,255,0.7); transition: color 0.2s; }
.nalsh-chat-close:hover { color: white; }

#nalsh-chat-messages { flex: 1; padding: 20px; overflow-y: auto; background: radial-gradient(var(--border) 0.5px, transparent 0.5px); background-size: 10px 10px; }
.nalsh-message-wrapper { display: flex; margin-bottom: 15px; opacity: 0; transform: translateY(10px); animation: message-fade-in 0.5s forwards; }
.nalsh-message-wrapper.user { justify-content: flex-end; }
.nalsh-message { max-width: 90%; padding: 8px 14px !important; border-radius: 16px !important; line-height: 1.4 !important; font-weight: 500; font-size: 0.85rem !important; }
.nalsh-message-wrapper.bot .nalsh-message { background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.nalsh-message-wrapper.user .nalsh-message { background: linear-gradient(135deg, #00c6fb, #005bea); color: white; border-bottom-right-radius: 5px; }
.nalsh-message-wrapper.bot .nalsh-message.system { background: linear-gradient(135deg, #00c6fb, #005bea); color: white; font-weight: 700; box-shadow: 0 5px 15px rgba(0, 198, 251, 0.3); }

.nalsh-quick-reply-container { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 15px; padding-top: 15px; border-top: 1px dashed var(--border); }
.nalsh-quick-reply { background: var(--bg-card); border: 1px solid #00c6fb !important; color: #00c6fb; padding: 6px 12px !important; border-radius: 50px; cursor: pointer; font-weight: 700; font-size: 0.8rem !important; transition: all 0.2s; }
.nalsh-quick-reply:hover { background: #00c6fb; color: white; }
.nalsh-message a.nalsh-contact-link { display: inline-flex; align-items: center; gap: 8px; background: #25D366; color: white; text-decoration: none; padding: 10px 18px; border-radius: 50px; font-weight: 800; margin-top: 10px; transition: transform 0.2s; }
.nalsh-message a.nalsh-contact-link:hover { transform: scale(1.05); }

.nalsh-chat-input-area { display: flex; padding: 10px !important; border-top: 1px solid var(--border); background: var(--bg-card); }
#nalsh-user-input { flex: 1; border: none; background: transparent; font-size: 0.85rem !important; color: var(--text-main); padding: 8px !important; }
#nalsh-send-btn { background: linear-gradient(135deg, #00c6fb, #005bea); color: white; border: none; width: 38px !important; height: 38px !important; border-radius: 50%; font-size: 1rem !important; cursor: pointer; transition: transform 0.2s; }
#nalsh-send-btn:hover { transform: scale(1.1); }

/* منتجات الدردشة */
.nalsh-products-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 5px;}
.nalsh-product-card { display: flex; gap: 10px !important; padding: 8px !important; border-radius: var(--radius-xl); background: var(--bg-card); border: 1px solid rgba(255,255,255,0.1); cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); text-align: right; position: relative; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05); backdrop-filter: blur(10px); }
.nalsh-product-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary-gradient); opacity: 0; transition: 0.3s; }
.nalsh-product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.nalsh-product-card:hover::before { opacity: 1; }
.nalsh-product-card .img-wrapper { width: 60px !important; height: 60px !important; flex-shrink: 0; border-radius: 10px !important; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.nalsh-product-card .details { display: flex; flex-direction: column; justify-content: center; flex: 1;}
.nalsh-product-card .details .name { font-weight: 800; line-height: 1.3; font-size: 0.9rem !important; margin-bottom: 3px !important; color: var(--text-main);}
.nalsh-product-card .details .price-row { display: flex; align-items: center; gap: 8px; }
.nalsh-product-card .details .price { font-weight: 900; font-size: 0.95rem !important; color: var(--primary); }
.nalsh-product-card .details .old-price { font-size: 0.85rem; text-decoration: line-through; color: var(--text-muted); font-weight: 500;}
.nalsh-product-card .discount-badge-chat { position: absolute; top: 10px; left: 10px; background: var(--danger); color: white; padding: 4px 8px; border-radius: 8px; font-size: 0.75rem; font-weight: 900; box-shadow: 0 2px 5px rgba(244, 63, 94, 0.4); z-index: 2; }

/* ================= 5. الحركات الافتراضية (Animations) ================= */
@keyframes letterBounce { 0% { opacity: 0; transform: translateY(30px) scale(0.8); } 50% { opacity: 1; transform: translateY(-10px) scale(1.05); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes loaderScan { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
@keyframes pulseOpacity { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes element-build-flash { 0% { box-shadow: 0 0 0 0 rgba(0, 255, 255, 0); border-color: transparent; } 50% { box-shadow: 0 0 30px 5px rgba(0, 255, 255, 0.6); border-color: #00ffff; } 100% { box-shadow: 0 0 0 0 rgba(0, 255, 255, 0); border-color: var(--border); } }
@keyframes gridMove { 0% { transform: perspective(500px) rotateX(60deg) translateY(0); } 100% { transform: perspective(500px) rotateX(60deg) translateY(40px); } }
@keyframes floatHoverGPU { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(0, -15px, 0); } }
@keyframes cartHoverGPU { 0%, 100% { transform: translate3d(calc(100vw - 110px), -80px, 0) scale(0.75); } 50% { transform: translate3d(calc(100vw - 110px), -90px, 0) scale(0.75); } }
@keyframes cyberBlink { 0%, 96%, 98% { transform: scaleY(1); } 97%, 99% { transform: scaleY(0.1); } }
@keyframes pulseGlow { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.5); opacity: 1; } }
@keyframes robotScan { 0% { transform: translateX(-6px); } 100% { transform: translateX(6px); } }
@keyframes robotZoom { 0% { transform: translateY(-10px) skewX(-10deg); } 100% { transform: translateY(-20px) skewX(-10deg); } }
@keyframes wingFlap { 0% { transform: rotate(-15deg) scaleY(1); } 100% { transform: rotate(-25deg) scaleY(1.5); } }
@keyframes spinHappy { 0% { transform: rotate(0deg) scale(1); } 50% { transform: rotate(180deg) scale(1.2); } 100% { transform: rotate(360deg) scale(1); } }
@keyframes bounceGlow { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
@keyframes message-fade-in { to { opacity: 1; transform: translateY(0); } }