/* ========================================
   AI Assistant Page - Light Theme
   تصميم فاتح مع الروبوت المتحرك
   ======================================== */

:root {
    --primary: #21c68b;
    --primary-hover: #1ba876;
    --primary-light: rgba(33, 198, 139, 0.1);
    --primary-glow: rgba(33, 198, 139, 0.3);
    --primary-dark: #189668;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --danger: #e74c3c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Tajawal', sans-serif;
    min-height: 100vh;
    background: var(--gray-50);
}

/* ========== الصفحة الرئيسية ========== */
.ai-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== الهيدر ========== */
.ai-header {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo-small {
    width: 50px;
    height: 50px;
    background: var(--white);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--gray-200);
    box-shadow: 0 0 15px var(--primary-glow);
}

.brand-logo-small img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.brand-logo-small i {
    font-size: 1.5rem;
    color: var(--primary);
}

.brand-info h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
}

.brand-info span {
    font-size: 0.85rem;
    color: var(--gray-600);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: var(--white);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 15px var(--primary-glow);
    color: var(--white);
}

/* ========== المحتوى الرئيسي ========== */
.ai-main {
    flex: 1;
    display: flex;
    padding: 1.5rem;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ========== الشريط الجانبي ========== */
.ai-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ========== بطاقة الروبوت ========== */
.robot-showcase {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.robot-showcase::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, var(--primary-light), transparent 30%);
    animation: rotate 8s linear infinite;
    opacity: 0.5;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

.robot-container {
    position: relative;
    z-index: 1;
    margin-bottom: 1.5rem;
}

/* الروبوت الكبير */
.big-robot {
    width: 120px;
    height: 140px;
    margin: 0 auto;
    position: relative;
    animation: robotBounce 3s ease-in-out infinite;
}

@keyframes robotBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.robot-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--primary-glow), transparent 70%);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.robot-head-big {
    width: 80px;
    height: 70px;
    background: linear-gradient(180deg, #2dd4bf 0%, var(--primary) 100%);
    border-radius: 20px 20px 15px 15px;
    margin: 0 auto 8px;
    position: relative;
    box-shadow: 
        inset 0 -10px 20px rgba(0,0,0,0.1),
        0 10px 30px var(--primary-glow);
}

.robot-antenna-big {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary), #2dd4bf);
    border-radius: 4px 4px 0 0;
}

.robot-antenna-big::after {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: #06b6d4;
    border-radius: 50%;
    box-shadow: 0 0 15px #06b6d4, 0 0 30px #06b6d4;
    animation: antennaBlink 1.5s ease-in-out infinite;
}

@keyframes antennaBlink {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.2); }
}

.robot-face {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
}

.robot-eyes-big {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.robot-eye-big {
    width: 22px;
    height: 26px;
    background: white;
    border-radius: 8px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.robot-pupil-big {
    width: 10px;
    height: 12px;
    background: var(--gray-800);
    border-radius: 4px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: lookAround 4s ease-in-out infinite;
}

@keyframes lookAround {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(-20%, -50%); }
    50% { transform: translate(-50%, -30%); }
    75% { transform: translate(-80%, -50%); }
}

.robot-mouth-big {
    width: 30px;
    height: 8px;
    background: white;
    border-radius: 0 0 15px 15px;
    margin: 0 auto;
    animation: talk 0.5s ease-in-out infinite;
}

@keyframes talk {
    0%, 100% { height: 8px; }
    50% { height: 12px; }
}

.robot-body-big {
    width: 90px;
    height: 50px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 15px 15px 20px 20px;
    margin: 0 auto;
    position: relative;
    box-shadow: 
        inset 0 -5px 15px rgba(0,0,0,0.1),
        0 10px 30px var(--primary-glow);
}

.robot-chest {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 25px;
    background: rgba(255,255,255,0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.robot-heart {
    width: 12px;
    height: 12px;
    background: var(--danger);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--danger), 0 0 20px var(--danger);
    animation: heartbeat 1s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.robot-arms {
    position: absolute;
    top: 5px;
    width: 100%;
}

.robot-arm {
    position: absolute;
    width: 12px;
    height: 40px;
    background: var(--primary);
    border-radius: 6px;
}

.robot-arm.left {
    right: -18px;
    transform: rotate(15deg);
    animation: waveLeft 2s ease-in-out infinite;
}

.robot-arm.right {
    left: -18px;
    transform: rotate(-15deg);
    animation: waveRight 2s ease-in-out infinite;
}

@keyframes waveLeft {
    0%, 100% { transform: rotate(15deg); }
    50% { transform: rotate(25deg); }
}

@keyframes waveRight {
    0%, 100% { transform: rotate(-15deg); }
    50% { transform: rotate(-25deg); }
}

.showcase-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.showcase-subtitle {
    color: var(--gray-600);
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
}

/* ========== الإحصائيات ========== */
.ai-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateX(-5px);
    box-shadow: 5px 0 20px var(--primary-glow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--white);
}

.stat-info h3 {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 0.15rem;
    font-weight: 500;
}

.stat-info p {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
}

/* ========== الأسئلة المقترحة ========== */
.quick-questions {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 18px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.quick-questions h3 {
    font-size: 0.95rem;
    color: var(--gray-800);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.quick-questions h3 i {
    color: var(--primary);
}

.question-chips {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-chip {
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    color: var(--gray-700);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: right;
}

.question-chip:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
    transform: translateX(-5px);
    box-shadow: 5px 0 15px var(--primary-glow);
}

/* ========== منطقة المحادثة ========== */
.chat-area {
    flex: 1;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

/* رأس المحادثة */
.chat-area-header {
    padding: 1rem 1.25rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-status-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-dot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    border-radius: 20px;
}

.status-dot i {
    color: var(--primary);
    font-size: 0.5rem;
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-dot span {
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.ai-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 20px;
    color: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
}

.clear-chat-btn {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    color: var(--danger);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.clear-chat-btn:hover {
    background: var(--danger);
    color: var(--white);
    border-color: var(--danger);
}

/* ========== منطقة الرسائل ========== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--gray-50);
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

/* رسالة الترحيب */
.welcome-message {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 15px 40px var(--primary-glow);
    animation: welcomeFloat 3s ease-in-out infinite;
}

@keyframes welcomeFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

.welcome-icon i {
    font-size: 2.5rem;
    color: var(--white);
}

.welcome-message h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.welcome-message p {
    color: var(--gray-600);
    font-size: 1rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ========== الرسائل ========== */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
    /* RTL: جميع الرسائل على اليمين */
    margin-right: 0;
    margin-left: auto;
    flex-direction: row;
}

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

/* RTL: رسائل المستخدم - الأيقونة على اليمين */
.message.user {
    flex-direction: row;
}

/* RTL: رسائل المساعد - نفس المحاذاة أسفل رسالة المستخدم */
.message.assistant {
    flex-direction: row;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    align-self: flex-start;
    margin-top: 2px;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--white);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    line-height: 1.7;
    font-size: 0.925rem;
    text-align: right;
}

.message-content.rtl {
    direction: rtl;
    text-align: right;
}

.message-content.ltr {
    direction: ltr;
    text-align: left;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--white);
    border-top-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-top-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* مؤشر الكتابة */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); background: var(--primary); }
}

/* رابط التسجيل */
.register-link-message {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: var(--white);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.register-link-message:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-glow);
    color: var(--white);
}

/* ========== منطقة الإدخال ========== */
.chat-input-wrapper {
    padding: 1rem 1.25rem;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
}

.input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.input-wrapper {
    flex: 1;
}

.chat-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.925rem;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
    line-height: 1.5;
}

.chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.chat-input::placeholder {
    color: var(--gray-500);
}

.send-button {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    border-radius: 14px;
    color: var(--white);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 20px var(--primary-glow);
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== Responsive ========== */
@media (max-width: 992px) {
    .ai-main {
        flex-direction: column;
    }
    
    .ai-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .robot-showcase {
        flex: 1;
        min-width: 250px;
    }
    
    .ai-stats {
        flex: 1;
        min-width: 200px;
    }
    
    .quick-questions {
        width: 100%;
    }
    
    .question-chips {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .question-chip {
        flex: 1;
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .ai-header {
        padding: 1rem;
    }
    
    .ai-main {
        padding: 1rem;
    }
    
    .ai-sidebar {
        flex-direction: column;
    }
    
    .robot-showcase,
    .ai-stats,
    .quick-questions {
        width: 100%;
    }
    
    .brand-info h1 {
        font-size: 1.1rem;
    }
    
    .back-btn span {
        display: none;
    }
    
    .back-btn {
        padding: 0.75rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-area-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .big-robot {
        width: 110px;
        height: 130px;
    }
    
    .robot-head-big {
        width: 72px;
        height: 62px;
    }
    
    .robot-face {
        top: 12px;
        width: 55px;
    }
    
    .robot-eyes-big {
        gap: 12px;
        margin-bottom: 8px;
    }
    
    .robot-eye-big {
        width: 18px;
        height: 22px;
    }
    
    .robot-pupil-big {
        width: 8px;
        height: 10px;
    }
    
    .robot-mouth-big {
        width: 24px;
        height: 6px;
    }
    
    .robot-body-big {
        width: 80px;
        height: 45px;
    }
    
    .robot-chest {
        width: 35px;
        height: 22px;
    }
    
    .robot-heart {
        width: 10px;
        height: 10px;
    }
    
    .robot-arm {
        width: 10px;
        height: 35px;
    }
    
    .robot-arm.left {
        right: -15px;
    }
    
    .robot-arm.right {
        left: -15px;
    }
    
    .robot-antenna-big {
        width: 6px;
        height: 16px;
        top: -16px;
    }
    
    .robot-antenna-big::after {
        width: 12px;
        height: 12px;
        top: -10px;
    }
}

@media (max-width: 576px) {
    .ai-header {
        padding: 0.75rem;
    }
    
    .brand-logo-small {
        width: 40px;
        height: 40px;
    }
    
    .brand-logo-small img {
        width: 32px;
        height: 32px;
    }
    
    .question-chips {
        flex-direction: column;
    }
    
    .question-chip {
        min-width: 100%;
    }
    
    .message-avatar {
        width: 34px;
        height: 34px;
        font-size: 0.85rem;
    }
    
    .message-content {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    .send-button {
        width: 44px;
        height: 44px;
    }
    
    .showcase-title {
        font-size: 1.15rem;
    }
    
    .showcase-subtitle {
        font-size: 0.85rem;
    }
    
    /* تحسين الروبوت للشاشات الصغيرة جداً */
    .big-robot {
        width: 100px;
        height: 120px;
    }
    
    .robot-head-big {
        width: 65px;
        height: 56px;
    }
    
    .robot-face {
        top: 10px;
        width: 50px;
    }
    
    .robot-eyes-big {
        gap: 10px;
        margin-bottom: 6px;
    }
    
    .robot-eye-big {
        width: 16px;
        height: 20px;
    }
    
    .robot-pupil-big {
        width: 7px;
        height: 9px;
    }
    
    .robot-mouth-big {
        width: 20px;
        height: 5px;
    }
    
    .robot-body-big {
        width: 72px;
        height: 40px;
    }
    
    .robot-chest {
        width: 30px;
        height: 18px;
        top: 8px;
    }
    
    .robot-heart {
        width: 8px;
        height: 8px;
    }
    
    .robot-arm {
        width: 9px;
        height: 30px;
    }
    
    .robot-arm.left {
        right: -13px;
    }
    
    .robot-arm.right {
        left: -13px;
    }
    
    .robot-antenna-big {
        width: 5px;
        height: 14px;
        top: -14px;
    }
    
    .robot-antenna-big::after {
        width: 10px;
        height: 10px;
        top: -8px;
    }
}
