﻿:root {
    --bg-color: #1e1e2e; 
    --card-bg: #2d2d44; 
    --primary: #89b4fa;
    --text: #cdd6f4; 
    --accent: #f38ba8; 
    --success: #a6e3a1;
    --warning: #fab387; 
    --info: #74c7ec; 
    --console-bg: #11111b;
    --mem-btn: #e67e22; 
    
    /* ألوان اللغات */
    --c-color: #5555aa; 
    --csharp-color: #9b4f96;
    --cpp-color: #5e97d0;
    --java-color: #b07219;

    --btn-ai: #cba6f7;
    --stop-color: #ff5555;
    --user-msg-bg: #44475a;
    --ai-msg-bg: #282a36;
    --rec-color: #ff5555;
    
    /* ألوان أزرار الـ AI */
    --ai-purple: #bd93f9;
    --ai-green: #50fa7b;
    --ai-pink: #ff79c6;
    --ai-orange: #ffb86c;
    --ai-cyan: #8be9fd;
    --ai-yellow: #f1fa8c;
    --ai-red: #ff5555;
    --ai-indigo: #6c5ce7;
    --ai-blue: #3498db; 
    --ai-teal: #1abc9c;
    --ai-gold: #f39c12;
    --ai-history: #95a5a6;
    --ai-game: #e74c3c;
    --ai-carrot: #e67e22; 
    --ai-security: #2c3e50;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
}

/* --- إعدادات المحرر (RTL Cursor Fix) --- */
#code-section-panel, 
.editors-container,
.ace_editor {
    direction: ltr !important;
    text-align: left !important;
}

.ace_editor, 
.ace_editor * {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace !important;
    font-feature-settings: "liga" 0, "calt" 0 !important;
    font-variant-ligatures: none !important;
}

.ace_text-layer {
    padding-left: 5px !important; 
}

.ace_gutter-layer {
    text-align: right !important;
    padding-right: 3px !important;
}

.ace_scroller {
    left: 1 !important; 
}
/* -------------------------------------- */

body[lang="ja"], body[lang="zh"], body[lang="ko"] { 
    font-family: 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif; 
}

body { 
    background-color: var(--bg-color); 
    color: var(--text); 
    min-height: 100vh; 
    overflow: hidden; 
}

/* --- الصفحة الرئيسية --- */
#home-view { 
    padding: 20px; 
    max-width: 1200px; 
    margin: 0 auto; 
    height: 100vh; 
    overflow-y: auto; 
    position: relative; 
}

header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 30px; 
    padding-bottom: 15px; 
    border-bottom: 1px solid #444; 
    flex-wrap: wrap; 
    gap: 15px;
}

.header-controls { 
    display: flex; 
    gap: 10px; 
    align-items: center; 
    flex-wrap: wrap; 
}

h1 { 
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    background: linear-gradient(90deg, var(--primary), #5e81ac, var(--primary));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    display: flex; 
    align-items: center; 
    gap: 10px; 
    line-height: 1.5;
    animation: titleFloat 3s ease-in-out infinite, titleGlow 2s ease-in-out infinite alternate, titleGradientMove 3s linear infinite alternate;
}

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

@keyframes titleGlow {
    0% { filter: drop-shadow(0 0 5px rgba(137, 180, 250, 0.5)); }
    100% { filter: drop-shadow(0 0 15px rgba(137, 180, 250, 0.9)); }
}

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

/* Network Status */
.network-status {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 20px;
    background: #333;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 1;
    color: white; 
}
.network-status.online { color: var(--success); border: 1px solid var(--success); }
.network-status.offline { color: var(--stop-color); border: 1px solid var(--stop-color); opacity: 1 !important; }

.network-status.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.sync-icon { transition: transform 1s; }
.syncing .sync-icon { animation: spin 1s infinite linear; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- تصميم الأزرار الموحد --- */
.btn {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 18px;
    border-radius: 10px; 
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #3a3a4e, #2b2b3a);
    color: var(--text);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    border-color: var(--primary);
    filter: brightness(1.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* تخصيص الألوان */
.add-btn { background: linear-gradient(135deg, var(--primary), #5e81ac); color: #181825; text-shadow: none; }
.run-btn { background: linear-gradient(135deg, var(--success), #7ec97e); color: #181825; text-shadow: none; }
.ai-btn { background: linear-gradient(135deg, var(--btn-ai), #a27ae0); color: #181825; text-shadow: none; }
.btn-danger { background: linear-gradient(135deg, var(--stop-color), #cc4444); color: white; }
.search-btn { background: linear-gradient(135deg, #50fa7b, #2ea043); color: #000; text-shadow: none; }
.btn-preview { background: linear-gradient(135deg, #2ecc71, #27ae60); color: #000; text-shadow: none; }

.btn-security-audit {
    background: linear-gradient(135deg, #ff5555, #cc0000); 
    color: white;
    text-shadow: none;
    width: 100%;
    margin-bottom: 10px;
    justify-content: center;
}
.btn-security-harden {
    background: linear-gradient(135deg, #3498db, #2980b9); 
    color: white;
    text-shadow: none;
    width: 100%;
    justify-content: center;
}

/* --- حاوية الأزرار العائمة (Community & Support & Memory) --- */
.floating-actions {
    position: fixed;
    bottom: 30px;
    inset-inline-start: 30px; 
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 999;
}

.mem-btn-round {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--warning);
    color: #000;
    border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    transition: transform 0.3s;
}
.mem-btn-round:hover { transform: scale(1.1) rotate(90deg); }

.reddit-btn-round {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #ff4500;
    color: #fff;
    border: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: transform 0.3s;
    text-decoration: none;
}
.reddit-btn-round:hover { transform: scale(1.1); filter: brightness(1.1); }

.bmc-btn-link {
    transition: transform 0.3s;
    display: flex;
    align-items: center;
}
.bmc-btn-link img {
    height: 50px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border-radius: 8px;
}
.bmc-btn-link:hover { transform: scale(1.05); }

/* --- باقي التنسيقات --- */
.apply-code-btn { 
    background: linear-gradient(135deg, #2ecc71, #27ae60); 
    color: #fff; 
    border: 1px solid rgba(255,255,255,0.2); 
    padding: 8px 15px; 
    border-radius: 8px; 
    cursor: pointer; 
    font-weight: bold; 
    font-size: 12px; 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    margin-top: 8px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.apply-code-btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4); 
    filter: brightness(1.1); 
}

.ai-quick-actions {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #444;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end; 
}

.projects-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); 
    gap: 20px; 
    padding-bottom: 50px; 
}

.card { 
    background: var(--card-bg); 
    border-radius: 15px; 
    overflow: hidden; 
    transition: transform 0.3s; 
    cursor: pointer; 
    position: relative; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.3); 
}
.card:hover { transform: translateY(-5px); }

.card-img { 
    height: 140px; 
    width: 100%; 
    background-size: cover; 
    background-position: center; 
    background-color: #444; 
    position: relative; 
}

.card-badges { 
    position: absolute; 
    bottom: 10px; 
    inset-inline-end: 10px; 
    display: flex; 
    gap: 5px; 
    z-index: 2; 
    flex-wrap: wrap; 
}

.lang-badge { 
    font-size: 10px; 
    padding: 3px 8px; 
    border-radius: 4px; 
    color: #fff; 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    backdrop-filter: blur(4px); 
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); 
}

.badge-web { background: rgba(120, 120, 120, 0.8); color: #fff; }
.badge-html { background: rgba(228, 77, 38, 0.9); color: #fff; }
.badge-css { background: rgba(38, 77, 228, 0.9); color: #fff; }
.badge-js { background: rgba(240, 219, 79, 0.9); color: #000; }
.badge-py { background: rgba(255, 221, 84, 0.8); color: #000; }
.badge-c { background: rgba(85, 85, 170, 0.9); color: #fff; }
.badge-csharp { background: rgba(155, 79, 150, 0.9); color: #fff; }
.badge-cpp { background: rgba(94, 151, 208, 0.9); color: #fff; }
.badge-java { background: rgba(176, 114, 25, 0.9); color: #fff; }
.badge-three { background: #000; color: #fff; border: 1px solid #fff; }
.badge-new { background: rgba(255, 255, 255, 0.3); }

.edit-card-btn { 
    position: absolute; 
    top: 10px; 
    inset-inline-start: 10px; 
    background: rgba(0,0,0,0.6); 
    color: white; 
    border: none; 
    width: 30px; 
    height: 30px; 
    border-radius: 50%; 
    cursor: pointer; 
    display:flex; 
    justify-content:center; 
    align-items:center; 
    z-index: 2; 
}

.card-body { padding: 15px; }
.card-title { font-size: 18px; font-weight: bold; margin-bottom: 5px; }
.card-date { font-size: 12px; color: #888; }

/* --- المحرر --- */
#editor-view { display: none; height: 100vh; flex-direction: column; }

.editor-header { 
    background: #181825; 
    padding: 0 20px; 
    height: 60px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid #333; 
}

.back-btn { 
    background: transparent; 
    border: 1px solid var(--text); 
    color: var(--text); 
    padding: 5px 15px; 
    border-radius: 5px; 
    cursor: pointer; 
}

.editor-workspace { 
    display: flex; 
    flex: 1; 
    height: calc(100vh - 60px); 
    overflow: hidden; 
    transition: 0.1s; 
    flex-direction: row; 
}

.editor-workspace.layout-vertical { flex-direction: column; }

.code-section { 
    width: 50%; 
    display: flex; 
    flex-direction: column; 
    background: #1e1e2e; 
    position: relative; 
    min-width: 100px; 
    min-height: 100px; 
}

.preview-section { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background: #fff; 
    position: relative; 
    min-width: 100px; 
    min-height: 100px; 
}

.resizer { 
    background-color: #000; 
    opacity: 0.5; 
    z-index: 10; 
    transition: opacity 0.2s; 
}

.resizer:hover { opacity: 1; background-color: var(--primary); }

.editor-workspace:not(.layout-vertical) .resizer { 
    width: 5px; cursor: col-resize; border-left: 1px solid #444; border-right: 1px solid #444; 
}

.editor-workspace.layout-vertical .resizer { 
    height: 5px; width: 100%; cursor: row-resize; border-top: 1px solid #444; border-bottom: 1px solid #444; 
}

.editor-workspace.layout-vertical .code-section { width: 100%; height: 50%; border-right: none; }

.code-section.fullscreen-active { 
    position: fixed; top: 0; left: 0; width: 100vw !important; height: 100vh !important; z-index: 1000; border: none; 
}

.code-section.fullscreen-active .tabs { padding-top: 5px; } 

#exit-code-fullscreen { 
    position: fixed; bottom: 20px; right: 20px; 
    z-index: 2000; display: none; background: var(--accent); color: #000; 
    border: none; padding: 8px 15px; border-radius: 8px; cursor: pointer; 
    font-weight: bold; font-size: 14px; align-items: center; gap: 5px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.code-section.fullscreen-active #exit-code-fullscreen { display: flex; }

/* Floating Buttons */
.trash-code-btn {
    position: absolute;
    bottom: 20px;
    left: 20px; 
    background: rgba(255, 85, 85, 0.8);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 90;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.trash-code-btn:hover { transform: scale(1.1); background: rgba(255, 85, 85, 1); }

.copy-code-btn {
    position: absolute;
    bottom: 20px;
    left: 70px;
    background: rgba(52, 152, 219, 0.8);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 90;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.copy-code-btn:hover { transform: scale(1.1); background: rgba(52, 152, 219, 1); }

.auto-fix-btn {
    position: absolute;
    bottom: 20px;
    left: 120px;
    background: rgba(155, 89, 182, 0.8);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 90;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.auto-fix-btn:hover { transform: scale(1.1); background: rgba(155, 89, 182, 1); }

.zoom-in-btn, .zoom-out-btn {
    position: absolute;
    bottom: 20px;
    background: rgba(128, 128, 128, 0.8); /* لون رمادي شفاف */
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 90;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.zoom-in-btn { left: 170px; }
.zoom-out-btn { left: 220px; }
.zoom-in-btn:hover, .zoom-out-btn:hover { transform: scale(1.1); background: rgba(128, 128, 128, 1); }

/* تحديث مكان زر التنزيل ليصبح بعد أزرار التكبير والتصغير */
.download-code-btn { left: 235px !important; }

.download-code-btn {
    position: absolute;
    bottom: 20px;
    left: 170px;
    background: rgba(46, 204, 113, 0.8); /* لون أخضر شفاف قليلاً */
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 90;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.download-code-btn:hover { transform: scale(1.1); background: rgba(46, 204, 113, 1); } /* لون أخضر ساطع عند التأشير */

.tabs { display: flex; background: #11111b; height: 40px; overflow-x: auto; }

.tab { 
    padding: 0 20px; color: #888; cursor: pointer; background: #11111b; 
    border: none; border-bottom: 2px solid transparent; font-weight: bold; 
    height: 100%; display: flex; align-items: center; 
}

.tab.active { 
    color: var(--primary); border-bottom: 2px solid var(--primary); background: #1e1e2e; 
}

.editors-container { flex: 1; position: relative; }
.ace-editor-instance { position: absolute; top: 0; left: 0; right: 0; bottom: 0; font-size: 16px; }

.ghost-text-overlay {
    position: absolute;
    color: #888; 
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Source Code Pro', monospace;
    font-size: 16px; 
    pointer-events: none;
    z-index: 9999;
    white-space: pre;
    opacity: 0.6;
    font-style: italic;
}

#ghost-indicator {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    padding: 2px 5px;
    font-size: 10px;
    border-radius: 3px;
    pointer-events: none;
    z-index: 100;
    display: none;
}

iframe { flex: 1; width: 100%; border: none; background: #fff; }

/* --- PREVIEW MODE STYLES --- */
body.preview-mode .code-section, 
body.preview-mode .resizer { display: none !important; }
body.preview-mode .preview-section { width: 100% !important; height: 100% !important; }
body.preview-mode .hide-in-preview { display: none !important; }
body.preview-mode #console-toggle-btn { display: none !important; }

/* =========================================
   Console & Preview Controls
   (تم إصلاح مشكلة الإخفاء وإلغاء الاعتماد على inset-inline)
========================================= */

/* حاوية الأزرار فوق المعاينة */
.preview-controls { 
    position: absolute !important; 
    bottom: 15px !important; 
    right: 15px !important; /* تثبيت في اليمين بشكل صريح */
    z-index: 99999 !important; 
    display: flex !important; 
    gap: 8px !important; 
    visibility: visible !important;
    pointer-events: auto !important;
}

.floating-btn { 
    background: rgba(0,0,0,0.7) !important; 
    color: white !important; 
    border: none !important; 
    padding: 8px 12px !important; 
    border-radius: 5px !important; 
    cursor: pointer !important; 
    backdrop-filter: blur(4px) !important; 
    transition: 0.2s !important; 
    display: flex !important; 
    align-items: center !important; 
    gap: 5px !important; 
}

.floating-btn:hover { background: rgba(0,0,0,0.9) !important; }
.floating-btn.active { background: var(--primary) !important; color: #000 !important; }

/* منطقة شاشة الكونسول */
#console-area { 
    height: 150px; 
    background: var(--console-bg); 
    color: #0f0; 
    padding: 10px; 
    font-family: monospace; 
    overflow-y: auto; 
    border-top: 2px solid #444; 
    display: none; 
    flex-direction: column; 
    font-size: 13px; 
    direction: ltr; 
    text-align: left; 
    position: relative; /* ضمان البقاء داخل الحاوية */
    z-index: 99990;
}

.console-header { 
    display: flex; justify-content: space-between; background: #333; 
    padding: 2px 10px; font-size: 11px; color: #ccc; margin: -10px -10px 5px -10px; 
}

.log-entry { 
    border-bottom: 1px solid #333; padding: 2px 0; white-space: pre-wrap; 
    display: flex; justify-content: space-between; align-items: flex-start; 
}

.log-explain-btn {
    background: #444; color: #fff; border: none; padding: 2px 6px; 
    font-size: 10px; border-radius: 3px; cursor: pointer; margin-left: 10px;
}
.log-explain-btn:hover { background: var(--primary); color: #000; }

/* Modal */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.7); display: none; justify-content: center; 
    align-items: center; z-index: 100; 
}

#style-transfer-modal, #gen-3d-modal, #gen-python-modal { z-index: 101; }
#project-type-modal { z-index: 102; }
#deploy-modal { z-index: 103; }
#clear-code-modal, #exit-confirmation-modal, #language-modal, #history-modal, #game-composer-modal, #explain-modal, #memory-modal { z-index: 104; }
#custom-alert-modal, #custom-confirm-modal { z-index: 105; }
#convert-code-modal { z-index: 106; }
#web-split-modal { z-index: 107; }
#quick-fix-modal, #security-guard-modal { z-index: 108; }
#thinking-mode-modal { z-index: 109; }

.modal { 
    background: var(--card-bg); padding: 25px; border-radius: 15px; 
    width: 90%; max-width: 400px; text-align: center; color: var(--text); 
    transition: all 0.3s ease; 
}

.modal input[type="text"], .modal input[type="password"], .modal select, .modal input[type="checkbox"] { 
    padding: 10px; margin: 10px 0; background: #181825; 
    border: 1px solid #444; color: white; border-radius: 5px; 
}

/* تنسيق القائمة المنسدلة الجديدة لمستوى التفكير */
.modal-select {
    width: 100%;
    padding: 10px;
    background: #181825;
    border: 1px solid #444;
    color: white;
    border-radius: 5px;
    cursor: pointer;
}
.modal-select:focus {
    border-color: var(--primary);
    outline: none;
}

/* تنسيقات زر اختيار مستوى التفكير (فوق زر الحفظ) */
.setting-trigger-btn {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: #181825;
    border: 1px solid #444;
    color: #ccc;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    transition: all 0.2s;
}
.setting-trigger-btn:hover {
    border-color: var(--primary);
    background: #2a2a35;
    color: #fff;
}
.setting-trigger-btn span:last-child {
    color: var(--primary);
    font-weight: bold;
}

/* تنسيقات نافذة اختيار مستوى التفكير */
.think-options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
}

.think-option-card {
    background: #1e1e2e;
    border: 1px solid #444;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    position: relative;
}

html[dir="rtl"] .think-option-card { text-align: right; }

.think-option-card:hover {
    background: #2a2a35;
    border-color: #666;
}

.think-option-card.selected {
    border-color: var(--success);
    box-shadow: 0 0 10px rgba(80, 250, 123, 0.1);
}

.think-option-card.selected::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 15px;
    right: 15px;
    color: var(--success);
}
html[dir="rtl"] .think-option-card.selected::after { right: auto; left: 15px; }

.think-card-title {
    font-weight: bold;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 5px;
}
.think-card-desc {
    font-size: 11px;
    color: #888;
}

/* تنسيقات صندوق سلسلة التفكير (Chain of Thought) */
.ai-thought-container {
    margin: 5px 0 10px 0;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 8px;
    overflow: hidden;
}

.ai-thought-header {
    background: #2a2a35;
    padding: 5px 10px;
    font-size: 11px;
    color: var(--warning);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
}

.ai-thought-content {
    padding: 10px;
    font-size: 12px;
    color: #aaa;
    font-style: italic;
    display: none; /* يتم تبديله بواسطة JS */
    border-top: 1px solid #444;
    white-space: pre-wrap;
    background: #1e1e2e;
}

.ai-thought-content.show { display: block; }

.modal textarea {
    padding: 10px; margin: 10px 0; background: #181825; 
    border: 1px solid #444; color: white; border-radius: 5px;
    width: 100%; height: 100px; resize: none;
}

.modal input[type="text"], .modal input[type="password"], .modal select { width: 100%; }

input[type="file"] {
    background: #111;
    color: #fff;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
    width: 100%;
    font-size: 12px;
    cursor: pointer;
}
input[type="file"]::-webkit-file-upload-button {
    background: #444;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}
input[type="file"]::-webkit-file-upload-button:hover {
    background: var(--primary);
    color: #000;
}

.image-upload-container { 
    margin: 15px 0; 
    padding: 20px; 
    border: 2px dashed #555; 
    border-radius: 10px; 
    text-align: center;
    transition: border-color 0.3s, background 0.3s;
    background: rgba(0,0,0,0.2);
}

.image-upload-container:hover {
    border-color: var(--primary);
    background: rgba(137, 180, 250, 0.1);
}

.image-preview { 
    width: 100%; height: 120px; background-color: #181825; 
    background-size: cover; background-position: center; margin-bottom: 15px; 
    border-radius: 5px; display: flex; justify-content: center; 
    align-items: center; color: #666; font-size: 12px; 
    border: 1px solid #444;
}

.upload-btn-label { 
    background: linear-gradient(135deg, #3a3a4e, #2b2b3a);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 10px; 
    cursor: pointer; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px; 
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.upload-btn-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.4);
    border-color: var(--primary);
}

.modal-btns { 
    display: flex; gap: 10px; justify-content: center; margin-top: 15px; 
}

.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lang-option { 
    background: #444; color: white; border: none; padding: 15px; 
    border-radius: 8px; cursor: pointer; font-weight: bold; 
}
.lang-option:hover { background: var(--primary); color: #000; }

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    background: #1e1e2e;
    padding: 10px;
    border-radius: 8px;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(80, 250, 123, 0.9);
    color: #000;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}
.toast.show { opacity: 1; }

.deploy-status-bar { height: 4px; background: #333; width: 100%; border-radius: 2px; overflow: hidden; margin: 15px 0; }
.deploy-progress { height: 100%; background: #50fa7b; width: 0%; transition: width 0.5s; }
.deploy-link-box { display: none; gap: 5px; margin-top: 10px; align-items: center; justify-content: center; }
.deploy-link-box input { flex: 1; }

#history-modal .modal { max-width: 500px; height: 70vh; display: flex; flex-direction: column; }
.timeline-container { flex: 1; overflow-y: auto; margin-top: 10px; border: 1px solid #444; border-radius: 5px; background: #11111b; padding: 10px; }
.timeline-item { display: flex; gap: 10px; margin-bottom: 15px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 14px; top: 25px; bottom: -20px; width: 2px; background: #333; }
.timeline-item:last-child::before { display: none; }
html[dir="rtl"] .timeline-item::before { left: auto; right: 14px; }

.timeline-marker { width: 30px; height: 30px; border-radius: 50%; background: #444; display: flex; justify-content: center; align-items: center; font-size: 12px; z-index: 2; border: 2px solid #2d2d44; }
.timeline-content { flex: 1; background: #2d2d44; padding: 10px; border-radius: 8px; }
.timeline-time { font-size: 10px; color: #888; margin-bottom: 5px; }
.timeline-tag { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; background: var(--primary); color: #000; font-weight: bold; margin-bottom: 5px; }
.timeline-desc { font-size: 12px; color: #ccc; }
.timeline-restore-btn { margin-top: 5px; background: transparent; border: 1px solid var(--success); color: var(--success); padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 10px; }
.timeline-restore-btn:hover { background: var(--success); color: #000; }

#game-composer-modal .modal { max-width: 550px; text-align: left; }
html[dir="rtl"] #game-composer-modal .modal { text-align: right; }
.stack-group { margin-bottom: 15px; background: #282a36; padding: 10px; border-radius: 8px; }
.stack-title { font-weight: bold; color: var(--primary); margin-bottom: 5px; font-size: 13px; display: flex; align-items: center; gap: 5px; }
.stack-options { display: flex; gap: 10px; flex-wrap: wrap; }
.stack-option { display: flex; align-items: center; gap: 5px; font-size: 12px; background: #111; padding: 5px 8px; border-radius: 4px; border: 1px solid #444; cursor: pointer; transition: 0.2s; }
.stack-option:hover { border-color: var(--primary); }
.stack-option input { width: auto !important; margin: 0 !important; cursor: pointer; }
.stack-desc { font-size: 10px; color: #888; margin-top: 5px; }

#ai-modal .modal { 
    max-width: 600px; width: 90%; height: 600px; display: flex; flex-direction: column; 
    background: #181825; border: 1px solid #444; box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
}

#ai-modal .modal.expanded { width: 95vw; max-width: 95vw; height: 95vh; }

html[dir="ltr"] #ai-modal .modal { text-align: left; }

.ai-chat-box { 
    flex: 1; background: #1e1e2e; border: none; overflow-y: auto; padding: 15px; 
    margin-bottom: 10px; border-radius: 8px; font-size: 14px; text-align: left; 
    direction: ltr; display: flex; flex-direction: column; gap: 12px; 
}

.cursor-blink::after {
    content: '▌';
    animation: blink 1s step-end infinite;
    color: var(--primary);
    margin-left: 2px;
}

@keyframes blink { 50% { opacity: 0; } }

.ai-message { 
    padding: 12px 16px; border-radius: 12px; max-width: 85%; 
    line-height: 1.5; position: relative; word-wrap: break-word; 
}

.ai-message.user { 
    background: var(--user-msg-bg); color: #fff; align-self: flex-end; 
    border-bottom-right-radius: 2px; 
    display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
}

.ai-message.system { 
    background: var(--ai-msg-bg); color: #eee; align-self: flex-start; 
    border-bottom-left-radius: 2px; border: 1px solid #444; 
}

.ai-message pre {
    background: #0f0f13;
    border: 1px solid #333;
    border-radius: 8px;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.ai-message pre::before {
    content: '';
    display: block;
    background: #2a2a35;
    height: 25px;
    border-bottom: 1px solid #333;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.ai-message pre::after {
    content: ' ';
    height: 10px;
    width: 10px;
    background-color: #ff5f56;
    border-radius: 50%;
    position: absolute;
    top: 7.5px;
    left: 10px;
    box-shadow: 15px 0 0 #ffbd2e, 30px 0 0 #27c93f;
}

.ai-message pre code {
    display: block;
    padding: 40px 15px 15px 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #e0e0e0;
    line-height: 1.5;
    overflow-x: auto;
}

.ai-msg-content { width: 100%; word-wrap: break-word; }
.ai-msg-controls {
    display: flex;
    gap: 10px;
    opacity: 0.6;
    font-size: 11px;
    margin-top: 3px;
}
.ai-msg-controls i { cursor: pointer; transition: 0.2s; }
.ai-msg-controls i:hover { transform: scale(1.2); color: #fff; opacity: 1; }

.ai-dropdown-wrapper {
    width: 100%;
    position: relative;
    margin-bottom: 10px;
}

.ai-main-trigger {
    width: 100%;
    padding: 12px;
    background: #282a36;
    color: var(--primary);
    border: 1px solid #444;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}

.ai-main-trigger:hover {
    background: #333;
    border-color: var(--primary);
}

.ai-dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%; 
    top: auto;
    left: 0;
    width: 100%;
    background: #1e1e2e;
    border: 1px solid #444;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 5px;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    z-index: 150;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}

#ai-modal .modal.expanded .ai-dropdown-content {
    bottom: auto;
    top: 100%;
    margin-top: 5px;
    margin-bottom: 0;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

.ai-dropdown-content.active {
    display: grid;
}

.ai-tool-item { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    padding: 12px 5px; 
    border: none; 
    border-radius: 8px; 
    cursor: pointer; 
    color: #282a36; 
    font-weight: bold; 
    font-size: 10px;
    gap: 5px;
    transition: transform 0.2s, filter 0.2s;
    height: 70px;
    text-align: center;
}

.ai-tool-item i { font-size: 18px; margin-bottom: 3px; }
.ai-tool-item:hover { transform: translateY(-3px); filter: brightness(1.1); }

.btn-purple { background: var(--ai-purple); }
.btn-green { background: var(--ai-green); }
.btn-pink { background: var(--ai-pink); }
.btn-orange { background: var(--ai-orange); }
.btn-cyan { background: var(--ai-cyan); }
.btn-yellow { background: var(--ai-yellow); }
.btn-red { background: var(--ai-red); color: white; }
.btn-indigo { background: var(--ai-indigo); color: white; } 
.btn-blue { background: var(--ai-blue); color: white; }
.btn-teal { background: var(--ai-teal); color: white; }
.btn-gold { background: var(--ai-gold); color: white; }
.btn-gray { background: var(--ai-history); color: #000; }
.btn-game { background: var(--ai-game); color: #fff; }
.btn-carrot { background: var(--ai-carrot); color: #fff; } 
.btn-security { background: var(--ai-security); color: #fff; }

.ai-input-wrapper { 
    background: #282a36; padding: 5px; border-radius: 10px; 
    border: 1px solid #444; display: flex; flex-direction: column; gap: 5px; 
}

.ai-input-group { display: flex; gap: 5px; align-items: center; width: 100%; }

.ai-input-group input { 
    background: transparent !important; border: none !important; 
    outline: none !important; box-shadow: none !important; margin: 0 !important; 
}

#ai-attachment-preview { 
    display: none; padding: 5px 10px; background: #333; border-radius: 5px; 
    font-size: 12px; color: #ccc; align-items: center; justify-content: space-between; 
    margin-bottom: 5px; 
}

.ai-header-btn { 
    background: transparent; border: none; color: #fff; cursor: pointer; 
    padding: 6px; transition: 0.2s; border-radius: 4px; 
}

.ai-header-btn:hover { background: rgba(255,255,255,0.1); }

#ai-send-btn, #ai-stop-btn, #ai-mic-btn {
    border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 14px;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}

#ai-send-btn { 
    background: linear-gradient(135deg, var(--primary), #5e81ac); 
    color: #181825; 
    text-shadow: none;
}

#ai-mic-btn { background: #444; color: #fff; }
#ai-mic-btn.recording { background: var(--rec-color); animation: pulse-rec 1s infinite; }

#ai-stop-btn { 
    background: var(--stop-color); color: #fff; display: none; 
    animation: pulse-red 1.5s infinite; 
}

@keyframes pulse-red { 
    0% { box-shadow: 0 0 0 0 rgba(255, 85, 85, 0.7); } 
    70% { box-shadow: 0 0 0 10px rgba(255, 85, 85, 0); } 
    100% { box-shadow: 0 0 0 0 rgba(255, 85, 85, 0); } 
}
@keyframes pulse-rec { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

@keyframes magic-pulse {
    0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 5px var(--ai-purple)); }
    25% { transform: scale(1.1) rotate(-10deg); }
    50% { transform: scale(1.2) rotate(10deg); filter: drop-shadow(0 0 20px var(--ai-purple)); }
    75% { transform: scale(1.1) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 5px var(--ai-purple)); }
}

.wand-anim {
    animation: magic-pulse 2s infinite ease-in-out;
}

.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.status-disconnected { background-color: #ff5555; }
.status-connected { background-color: #50fa7b; box-shadow: 0 0 5px #50fa7b; }

#cropper-modal .modal { max-width: 500px; }
.cropper-container-box { height: 300px; background: #333; margin-bottom: 10px; }
#cropper-img { max-width: 100%; }

#pyodide-loader { display: none; margin: 0 10px; font-size: 12px; color: var(--warning); }

.security-score-container {
    margin-top: 15px;
    padding: 10px;
    background: #111;
    border-radius: 8px;
    border: 1px solid #444;
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
    direction: ltr;
}
.security-level-high { color: #ff5555; font-weight: bold; }
.security-level-med { color: #f1fa8c; font-weight: bold; }
.security-level-low { color: #50fa7b; font-weight: bold; }

@media (max-width: 768px) {
    header { flex-direction: column; gap: 15px; }
    .header-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
    .network-status { order: 1; flex-basis: 100%; justify-content: center; margin-bottom: 5px; }
    .header-controls .btn { order: 2; flex: 1; min-width: auto; padding: 10px; font-size: 12px; white-space: nowrap; }
    .editor-header { height: auto; padding: 10px; flex-wrap: wrap; gap: 5px; justify-content: center; }
    #editor-project-name { display: none; }
    .editor-full-btn span, .btn-deploy span, .run-btn span, .ai-btn span { display: none; }
    .editor-full-btn, .btn-deploy, .run-btn { padding: 8px 12px; }
    .editor-workspace { flex-direction: column !important; }
    .code-section { width: 100% !important; height: 50% !important; border-right: none; border-bottom: 1px solid #444; }
    .preview-section { width: 100% !important; height: 50% !important; }
    .resizer { width: 100% !important; height: 10px !important; cursor: row-resize !important; border-left: none; border-right: none; border-top: 1px solid #444; border-bottom: 1px solid #444; }
    .trash-code-btn { width: 35px; height: 35px; bottom: 50px; left: 10px; font-size: 12px; }
    .copy-code-btn { width: 35px; height: 35px; bottom: 50px; left: 55px; font-size: 12px; }
    .auto-fix-btn { width: 35px; height: 35px; bottom: 50px; left: 100px; font-size: 12px; }
    .zoom-in-btn { width: 35px; height: 35px; bottom: 50px; left: 145px; font-size: 12px; }
    .zoom-out-btn { width: 35px; height: 35px; bottom: 50px; left: 190px; font-size: 12px; }
    .download-code-btn { width: 35px; height: 35px; bottom: 50px; left: 145px; font-size: 12px; }
    .preview-controls { bottom: 10px !important; right: 10px !important; gap: 5px !important; }
    .floating-btn { padding: 6px 10px !important; font-size: 12px !important; }
    .modal { width: 95%; max-width: 95%; padding: 15px; }
    .ai-dropdown-content { grid-template-columns: repeat(3, 1fr); gap: 5px; bottom: auto; top: 100%; margin-top: 5px; margin-bottom: 0; }
    .ai-tool-item { font-size: 9px; padding: 8px 2px; height: 60px; }
    .tabs { height: 35px; }
    .tab { padding: 0 15px; font-size: 12px; }
}

/* --- تصغير الأزرار العائمة على الهواتف --- */
@media (max-width: 768px) {
    .floating-actions {
        bottom: 15px;
        inset-inline-start: 15px;
        gap: 8px;
    }
    .mem-btn-round,
    .reddit-btn-round {
        width: 35px;
        height: 35px;
        font-size: 14px; 
    }
    .bmc-btn-link img {
        height: 35px; 
    }
}

/* =========================================
   Welcome Modal Styles
========================================= */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(17, 17, 27, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    backdrop-filter: blur(8px);
}

.welcome-box {
    position: relative;
    width: 90%;
    max-width: 650px;
    min-height: 400px;
    border-radius: 20px;
    overflow: hidden;
    background-image: url('welcome-bg.jpg'); 
    background-size: cover;
    background-position: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    border: 2px solid var(--primary);
    display: flex;
    align-items: flex-end; 
}

.welcome-content {
    width: 100%;
    padding: 50px 30px 30px 30px;
    background: linear-gradient(to top, rgba(17, 17, 27, 1) 0%, rgba(17, 17, 27, 0.9) 50%, transparent 100%);
    text-align: center;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.welcome-content h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 22px;
    background: linear-gradient(90deg, var(--primary), #5e81ac);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
    text-shadow: 0 0 15px rgba(137, 180, 250, 0.3);
    line-height: 1.5;
}

.welcome-content p {
    font-size: 15px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 15px;
    max-width: 90%;
}

.welcome-btn {
    background: linear-gradient(135deg, var(--primary), #5e81ac);
    color: #181825;
    border: none;
    padding: 14px 35px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(137, 180, 250, 0.5);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.welcome-btn:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 10px 25px rgba(137, 180, 250, 0.8);
    filter: brightness(1.2);
}

/* التوافق مع الهواتف الذكية */
@media (max-width: 768px) {
    .welcome-box {
        width: 95%;
        min-height: 450px;
    }
    .welcome-content {
        padding: 40px 20px 25px 20px;
    }
    .welcome-content h2 {
        font-size: 16px;
    }
    .welcome-content p {
        font-size: 13px;
        max-width: 100%;
    }
    .welcome-btn {
        padding: 12px 25px;
        font-size: 14px;
    }
}

/* =========================================
   القوة الجبرية لإظهار زر الكونسول في كل الشاشات
========================================= */

.preview-controls-nuclear {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    z-index: 2147483647 !important; 
    display: flex !important;
    gap: 10px !important;
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.btn-nuclear {
    background: rgba(0, 0, 0, 0.85) !important;
    color: white !important;
    border: 1px solid #555 !important;
    padding: 10px 15px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5) !important;
    backdrop-filter: blur(5px) !important;
    transition: all 0.2s !important;
}

/* تحويل لون زر الكونسول إلى الأزرق */
.console-nuclear {
    border-color: var(--primary) !important; /* اللون الأزرق */
    color: var(--primary) !important;       /* اللون الأزرق */
}

/* تحويل الظل عند تمرير الماوس (Hover) إلى الأزرق */
.btn-nuclear:hover {
    transform: translateY(-3px) !important;
    background: rgba(0, 0, 0, 1) !important;
    box-shadow: 0 10px 25px rgba(137, 180, 250, 0.5) !important; /* ظل أزرق */
    border-color: var(--primary) !important;
}

/* --- 2. منطقة عرض الكونسول (Output) --- */
#console-area { 
    position: absolute !important; /* جعلها تطفو فوق المعاينة */
    bottom: 80px !important;       /* ترك مساحة للأزرار تحتها */
    right: 15px !important;
    left: 15px !important;         /* تمتد بعرض الشاشة مع هوامش */
    height: 250px !important;      /* ارتفاع مناسب للقراءة */
    max-height: 50vh !important;
    background: rgba(17, 17, 27, 0.95) !important; /* لون داكن شبه شفاف */
    color: #cdd6f4 !important;     /* لون النص الأساسي */
    padding: 15px !important; 
    font-family: 'Monaco', 'Menlo', monospace !important; 
    overflow-y: auto !important; 
    border: 2px solid var(--primary) !important; /* حدود زرقاء */
    border-radius: 12px !important;
    z-index: 2147483646 !important; /* تظهر تحت الأزرار مباشرة */
    box-shadow: 0 -10px 30px rgba(0,0,0,0.6) !important;
    backdrop-filter: blur(10px) !important;
    display: none; /* يتم التحكم بها عبر JS */
    flex-direction: column !important; 
    font-size: 13px !important; 
    direction: ltr !important; 
    text-align: left !important; 
}

/* رأس الكونسول */
.console-header { 
    display: flex !important; 
    justify-content: space-between !important; 
    align-items: center !important;
    background: #181825 !important; 
    padding: 8px 12px !important; 
    font-size: 12px !important; 
    font-weight: bold !important;
    color: var(--primary) !important; /* عنوان أزرق */
    margin: -15px -15px 10px -15px !important; /* تمديد للرأس */
    border-bottom: 1px solid #444 !important;
    border-radius: 10px 10px 0 0 !important;
}

/* تنسيق سطور الأخطاء والرسائل */
.log-entry { 
    border-bottom: 1px solid rgba(255,255,255,0.05) !important; 
    padding: 6px 0 !important; 
    white-space: pre-wrap !important; 
    display: flex !important; 
    justify-content: space-between !important; 
    align-items: flex-start !important; 
    line-height: 1.4 !important;
}

/* زر إصلاح الأخطاء (Fix) */
.log-explain-btn {
    background: rgba(255, 85, 85, 0.2) !important; /* خلفية حمراء خفيفة */
    color: #ff5555 !important; /* نص أحمر */
    border: 1px solid #ff5555 !important; 
    padding: 4px 8px !important; 
    font-size: 11px !important; 
    border-radius: 5px !important; 
    cursor: pointer !important; 
    margin-left: 10px !important;
    font-weight: bold !important;
    transition: all 0.2s !important;
}

.log-explain-btn:hover { 
    background: #ff5555 !important; 
    color: #fff !important; 
    box-shadow: 0 0 10px rgba(255,85,85,0.5) !important;
}

/* ألوان أنواع الرسائل داخل الكونسول */
.log-log span { color: #cdd6f4 !important; }
.log-warn span { color: #fab387 !important; }
.log-error span { color: #f38ba8 !important; }
.log-info span { color: #89b4fa !important; } /* لون أزرق للمعلومات */

/* توافق الشاشات للكونسول الجديد */
@media (max-width: 768px) {
    .preview-controls-nuclear {
        bottom: 15px !important;
        right: 15px !important;
        gap: 5px !important;
    }
    .btn-nuclear {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    #console-area {
        bottom: 60px !important;
        right: 10px !important;
        left: 10px !important;
        height: 200px !important;
    }
}

/* =========================================
   إصلاح نافذة الكود (النافذة السوداء) للذكاء الاصطناعي على الهواتف
========================================= */

/* ضمان أن الحاوية الأكبر للرسالة لا تتجاوز عرض الشاشة أبداً */
.ai-message {
    max-width: 95% !important; /* السماح بمساحة أكبر قليلاً على الهاتف */
}

/* تنسيق النافذة السوداء (حاوية الكود) */
.ai-message pre {
    max-width: 100% !important; /* لا تتجاوز عرض الرسالة أبداً */
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: auto !important; /* السماح بالتمرير الأفقي بسلاسة */
    -webkit-overflow-scrolling: touch !important; /* تمرير ناعم على أجهزة أبل */
}

/* تنسيق النص داخل النافذة السوداء */
.ai-message pre code {
    white-space: pre !important; /* الحفاظ على تنسيق الكود الأصلي والتمرير الأفقي */
    word-break: normal !important; /* منع تكسير الكلمات البرمجية بشكل عشوائي */
    max-width: 100% !important;
    display: inline-block !important; /* ضروري ليعمل التمرير الأفقي بشكل صحيح */
}

/* التعديلات الخاصة بشاشات الهواتف فقط */
@media (max-width: 768px) {
    .ai-message {
        max-width: 100% !important; /* أخذ كامل المساحة المتاحة في الشات */
        padding: 10px 12px !important; /* تقليل الحواف لزيادة مساحة الكود */
    }
    
    .ai-message pre {
        margin-top: 8px !important;
        border-radius: 6px !important;
    }

    /* تصغير الشريط العلوي للنافذة السوداء (الذي يحتوي على الأزرار الوهمية) */
    .ai-message pre::before {
        height: 20px !important;
    }
    
    /* تصغير الأزرار الوهمية الحمراء والصفراء والخضراء لتناسب الهاتف */
    .ai-message pre::after {
        height: 8px !important;
        width: 8px !important;
        top: 6px !important;
        left: 8px !important;
        box-shadow: 12px 0 0 #ffbd2e, 24px 0 0 #27c93f !important;
    }

    /* تصغير حجم خط الكود وتقليل الحواف ليتسع أكبر قدر من الكود في الشاشة */
    .ai-message pre code {
        font-size: 6px !important; /* تصغير الخط ليكون مناسباً للهاتف */
        padding: 30px 10px 10px 10px !important; /* تقليل المسافات الداخلية */
        line-height: 1.4 !important;
    }
}

/* --- الإعداد النهائي لترتيب ومسافات أزرار المحرر العائمة --- */
.trash-code-btn { left: 20px !important; }
.copy-code-btn { left: 75px !important; }
.auto-fix-btn { left: 130px !important; }
.zoom-in-btn { left: 185px !important; }
.zoom-out-btn { left: 240px !important; }
.download-code-btn { left: 295px !important; }

/* المسافات الخاصة بشاشات الهواتف المحمولة */
@media (max-width: 768px) {
    .trash-code-btn { left: 10px !important; }
    .copy-code-btn { left: 55px !important; }
    .auto-fix-btn { left: 100px !important; }
    .zoom-in-btn { left: 145px !important; }
    .zoom-out-btn { left: 190px !important; }
    .download-code-btn { left: 235px !important; }
}