AnesKAM commited on
Commit
5cd4d00
·
verified ·
1 Parent(s): b5448f3

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +1076 -292
index.html CHANGED
@@ -2,198 +2,893 @@
2
  <html data-theme="light" dir="rtl" lang="ar">
3
  <head>
4
  <meta charset="utf-8" />
5
- <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0" name="viewport" />
6
- <title>SurfGO | نتائج البحث</title>
7
  <link rel="preconnect" href="https://fonts.googleapis.com" />
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
  <link href="https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Tajawal:wght@300;400;500;700&display=swap" rel="stylesheet" />
10
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
11
  <style>
 
12
  :root {
13
  --bg-base: #f0f2f8;
14
- --bg-nav: rgba(255,255,255,0.82);
15
  --bg-card: #ffffff;
16
  --bg-input: #e8ebf5;
17
  --bg-input-focus: #ffffff;
18
- --border: rgba(99,102,241,0.12);
19
- --border-hover: rgba(99,102,241,0.4);
20
  --accent: #5b5ef4;
21
  --accent-2: #e0427a;
22
- --accent-glow: rgba(91,94,244,0.18);
23
  --text-main: #12132a;
24
  --text-sub: #6b7280;
25
  --text-faint: #9ca3af;
26
- --shadow-card: 0 2px 12px rgba(91,94,244,0.07),0 1px 3px rgba(0,0,0,0.04);
27
- --shadow-hover: 0 8px 32px rgba(91,94,244,0.13),0 2px 8px rgba(0,0,0,0.06);
28
  --radius-nav: 22px;
29
  --radius-card: 18px;
30
  --radius-pill: 100px;
31
- --transition: 0.28s cubic-bezier(0.4,0,0.2,1);
32
  }
 
33
  [data-theme="dark"] {
34
  --bg-base: #0c0d1d;
35
- --bg-nav: rgba(18,20,40,0.92);
36
  --bg-card: #13152e;
37
  --bg-input: #1c1f3d;
38
  --bg-input-focus: #13152e;
39
- --border: rgba(130,133,255,0.13);
40
- --border-hover: rgba(130,133,255,0.4);
41
  --accent: #8284fc;
42
  --accent-2: #f472b6;
43
- --accent-glow: rgba(130,133,255,0.16);
44
  --text-main: #eef0ff;
45
  --text-sub: #9099c0;
46
  --text-faint: #5a6080;
47
- --shadow-card: 0 2px 14px rgba(0,0,0,0.28);
48
- --shadow-hover: 0 10px 36px rgba(130,133,255,0.14);
49
- }
50
- *{margin:0;padding:0;box-sizing:border-box}
51
- body{font-family:'Tajawal',sans-serif;background:var(--bg-base);color:var(--text-main);min-height:100vh;overflow-x:hidden;transition:background 0.35s,color 0.35s}
52
- .bg-mesh{position:fixed;inset:0;z-index:0;pointer-events:none;overflow:hidden}
53
- .orb{position:absolute;border-radius:50%;filter:blur(85px);opacity:0.4;animation:drift 20s ease-in-out infinite alternate}
54
- .orb-1{width:55vw;height:55vw;background:radial-gradient(circle,rgba(91,94,244,0.15) 0%,transparent 70%);top:-20%;right:-15%}
55
- .orb-2{width:45vw;height:45vw;background:radial-gradient(circle,rgba(224,66,122,0.12) 0%,transparent 70%);bottom:-15%;left:-10%}
56
- .orb-3{width:35vw;height:35vw;background:radial-gradient(circle,rgba(167,139,250,0.1) 0%,transparent 70%);top:55%;left:55%}
57
- @keyframes drift{0%{transform:translate(0,0) scale(1)}100%{transform:translate(4%,3%) scale(1.06)}}
58
- .navbar{position:fixed;top:14px;left:50%;transform:translateX(-50%);width:95%;max-width:1280px;min-height:68px;background:var(--bg-nav);backdrop-filter:blur(28px) saturate(1.6);-webkit-backdrop-filter:blur(28px) saturate(1.6);border:1px solid var(--border);border-radius:var(--radius-nav);display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;padding:10px 18px;z-index:1000;box-shadow:0 4px 24px rgba(0,0,0,0.06),0 1px 0 rgba(255,255,255,0.6) inset;gap:12px;transition:background 0.35s,border-color 0.35s}
59
- .brand{font-family:'Syne',sans-serif;font-weight:400;font-size:21px;text-decoration:none;color:var(--text-main);display:flex;align-items:center;gap:10px;letter-spacing:-0.01em;flex-shrink:0;transition:transform 0.2s}
60
- .brand:hover{transform:scale(1.03)}
61
- .brand-icon{width:36px;height:36px;background:linear-gradient(135deg,var(--accent),var(--accent-2));border-radius:10px;display:flex;align-items:center;justify-content:center;color:#fff;font-size:15px;flex-shrink:0;box-shadow:0 4px 14px var(--accent-glow)}
62
- .search-container{flex:1;max-width:580px;width:100%}
63
- .search-bar{display:flex;align-items:center;background:var(--bg-input);border:1.5px solid var(--border);border-radius:var(--radius-pill);padding:4px 4px 4px 16px;transition:var(--transition);width:100%}
64
- .search-bar:focus-within{border-color:var(--accent);background:var(--bg-input-focus);box-shadow:0 0 0 4px var(--accent-glow)}
65
- .search-bar input{flex:1;background:transparent;border:none;padding:9px 0;color:var(--text-main);font-size:14.5px;min-width:0;font-family:'Tajawal',sans-serif}
66
- .search-btn{background:linear-gradient(135deg,var(--accent),var(--accent-2));border:none;color:#fff;cursor:pointer;width:40px;height:36px;border-radius:var(--radius-pill);display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0;transition:var(--transition);box-shadow:0 2px 8px var(--accent-glow)}
67
- .search-btn:hover{opacity:0.88;transform:scale(1.06)}
68
- #theme-toggle{background:var(--bg-input);border:1.5px solid var(--border);color:var(--text-sub);cursor:pointer;width:38px;height:38px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:15px;transition:var(--transition)}
69
- #theme-toggle:hover{border-color:var(--accent);color:var(--accent)}
70
- .tabs-bar{position:fixed;top:98px;left:50%;transform:translateX(-50%);width:95%;max-width:1280px;display:flex;gap:6px;z-index:999;overflow-x:auto;padding:6px 10px;backdrop-filter:blur(16px);background:rgba(255,255,255,0.2);border:1px solid var(--border);border-radius:40px;scrollbar-width:none}
71
- [data-theme="dark"] .tabs-bar{background:rgba(18,20,40,0.35)}
72
- .tab-pill{padding:7px 16px;border-radius:var(--radius-pill);background:var(--bg-card);border:1.5px solid var(--border);color:var(--text-sub);font-family:'Tajawal',sans-serif;font-size:13px;font-weight:500;cursor:pointer;transition:var(--transition);display:flex;align-items:center;gap:6px;white-space:nowrap;box-shadow:var(--shadow-card)}
73
- .tab-pill:hover{border-color:var(--border-hover);color:var(--accent)}
74
- .tab-pill.active{background:var(--accent);color:#fff;border-color:var(--accent);box-shadow:0 4px 16px var(--accent-glow)}
75
- .page-wrapper{position:relative;z-index:1;max-width:1280px;margin:170px auto 60px;padding:0 16px;display:flex;flex-direction:column;gap:24px}
76
- .results-area{min-width:0;width:100%}
77
- #loading-text{color:var(--text-sub);font-size:13.5px;margin-bottom:18px;display:flex;align-items:center;gap:8px}
78
- #loading-text.spinning::before{content:'';display:inline-block;width:14px;height:14px;border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin 0.8s linear infinite}
79
- @keyframes spin{to{transform:rotate(360deg)}}
80
- .search-result,.image-card,.video-card{opacity:0;transform:translateY(20px);transition:opacity 0.5s ease,transform 0.5s ease}
81
- .search-result.visible,.image-card.visible,.video-card.visible{opacity:1;transform:translateY(0)}
82
- .search-result{background:var(--bg-card);border:1.5px solid var(--border);border-radius:var(--radius-card);padding:18px 20px;margin-bottom:12px;transition:var(--transition);box-shadow:var(--shadow-card);display:flex;gap:14px;align-items:flex-start}
83
- .search-result:hover{border-color:var(--border-hover);box-shadow:var(--shadow-hover);transform:translateY(-2px)}
84
- .favicon-wrap{width:22px;height:22px;border-radius:5px;overflow:hidden;flex-shrink:0;margin-top:3px;background:var(--bg-input);display:flex;align-items:center;justify-content:center}
85
- .favicon-wrap img{width:16px;height:16px;object-fit:contain}
86
- .fallback-icon{color:var(--text-faint);font-size:11px}
87
- .result-content{flex:1;min-width:0}
88
- .result-domain{font-size:11.5px;color:var(--text-faint);margin-bottom:4px;display:flex;align-items:center;gap:4px}
89
- .result-title{font-size:16px;font-weight:700;color:var(--accent);text-decoration:none;display:inline-block;margin-bottom:6px;line-height:1.4;transition:color 0.2s}
90
- .result-title:hover{color:var(--accent-2);text-decoration:underline}
91
- .result-snippet{font-size:13.5px;color:var(--text-sub);line-height:1.65}
92
- .copy-link-btn{background:none;border:none;color:var(--text-faint);cursor:pointer;font-size:13px;margin-right:8px;transition:color 0.2s}
93
- .copy-link-btn:hover{color:var(--accent)}
94
- .images-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:12px;width:100%}
95
- .image-card{background:var(--bg-card);border:1.5px solid var(--border);border-radius:var(--radius-card);overflow:hidden;transition:var(--transition);box-shadow:var(--shadow-card);display:flex;flex-direction:column}
96
- .image-card:hover{border-color:var(--border-hover);box-shadow:var(--shadow-hover);transform:translateY(-5px)}
97
- .image-card-link{display:block;width:100%;height:150px;overflow:hidden;background:var(--bg-input);position:relative}
98
- .image-card-link img{width:100%;height:100%;object-fit:cover;transition:transform 0.4s ease}
99
- .image-card:hover .image-card-link img{transform:scale(1.06)}
100
- .image-info{padding:8px 10px;font-size:11px;color:var(--text-sub);border-top:1px solid var(--border)}
101
- .img-error-overlay{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:var(--bg-input);color:var(--text-faint);flex-direction:column;gap:6px;font-size:13px}
102
- .videos-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:18px;width:100%}
103
- .video-card{background:var(--bg-card);border:1.5px solid var(--border);border-radius:var(--radius-card);overflow:hidden;transition:var(--transition);box-shadow:var(--shadow-card)}
104
- .video-card:hover{border-color:var(--border-hover);box-shadow:var(--shadow-hover);transform:translateY(-3px)}
105
- .video-thumb-wrap{position:relative;width:100%;height:150px;background:var(--bg-input);display:block;overflow:hidden}
106
- .video-thumb-wrap img{width:100%;height:100%;object-fit:cover;opacity:0.85;transition:0.3s}
107
- .video-card:hover .video-thumb-wrap img{opacity:1}
108
- .play-overlay{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:42px;height:42px;background:rgba(91,94,244,0.92);color:white;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:16px;box-shadow:0 0 20px var(--accent-glow)}
109
- .video-details{padding:10px}
110
- .video-title{font-size:14px;font-weight:700;color:var(--text-main);text-decoration:none;display:block;line-height:1.4}
111
- .video-title:hover{color:var(--accent)}
112
- .section-title{font-size:18px;font-weight:700;margin:20px 0 12px;color:var(--text-main);display:flex;align-items:center;gap:10px}
113
- .section-title a{color:var(--accent);text-decoration:none;font-size:14px;font-weight:500;margin-right:auto;transition:color 0.2s}
114
- .section-title a:hover{color:var(--accent-2)}
115
- .sidebar{width:100%;order:2;margin-top:12px}
116
- .ai-widget-wrap{position:relative;border-radius:var(--radius-card)}
117
- .ai-glow-ring{position:absolute;inset:-2px;border-radius:calc(var(--radius-card) + 2px);background:conic-gradient(from var(--angle,0deg),var(--accent),var(--accent-2),#a78bfa,var(--accent),var(--accent-2),var(--accent));z-index:0;animation:spin-glow 4s linear infinite;filter:blur(1px)}
118
- @property --angle{syntax:'<angle>';initial-value:0deg;inherits:false}
119
- @keyframes spin-glow{to{--angle:360deg}}
120
- .ai-widget{position:relative;z-index:1;background:var(--bg-card);border-radius:var(--radius-card);padding:18px 18px 16px;box-shadow:var(--shadow-card)}
121
- .ai-widget-header{display:flex;align-items:center;gap:9px;margin-bottom:14px}
122
- .ai-widget-icon{width:30px;height:30px;border-radius:8px;background:linear-gradient(135deg,var(--accent),var(--accent-2));display:flex;align-items:center;justify-content:center;color:#fff;font-size:12px}
123
- .ai-widget-badge{margin-right:auto;font-size:10px;padding:2px 8px;border-radius:20px;background:var(--accent-glow);color:var(--accent);font-weight:600;border:1px solid rgba(91,94,244,0.2)}
124
- .ai-answer-body{font-size:13.5px;color:var(--text-sub);line-height:1.75;min-height:60px}
125
- .ai-answer-body.loading{display:flex;flex-direction:column;gap:8px}
126
- .ai-skeleton{height:12px;border-radius:6px;background:linear-gradient(90deg,var(--bg-input) 25%,var(--border) 50%,var(--bg-input) 75%);background-size:200% 100%;animation:shimmer 1.4s ease-in-out infinite}
127
- @keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
128
- .ai-copy-btn{margin-top:14px;padding:8px 16px;background:var(--bg-input);border:1px solid var(--border);border-radius:30px;cursor:pointer;font-size:12px;color:var(--text-sub);display:inline-flex;align-items:center;gap:6px;transition:var(--transition)}
129
- .ai-copy-btn:hover{background:var(--accent);color:#fff;border-color:var(--accent)}
130
- .ai-widget-footer{font-size:10.5px;color:var(--text-faint);margin-top:12px;padding-top:10px;border-top:1px solid var(--border);display:flex;align-items:center;gap:5px}
131
- .ai-sources{margin-top:10px;display:flex;flex-wrap:wrap;gap:6px}
132
- .ai-source-chip{font-size:11px;padding:3px 10px;border-radius:20px;background:var(--bg-input);border:1px solid var(--border);color:var(--text-faint);text-decoration:none;display:flex;align-items:center;gap:5px;transition:var(--transition)}
133
- .ai-source-chip:hover{border-color:var(--accent);color:var(--accent)}
134
- .ai-mobile-wrap{display:none;border-radius:var(--radius-card);margin-bottom:16px;position:relative}
135
- .back-to-top{position:fixed;bottom:30px;right:30px;z-index:999;width:46px;height:46px;border-radius:50%;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;font-size:18px;cursor:pointer;opacity:0;visibility:hidden;transition:0.3s;box-shadow:0 6px 20px var(--accent-glow);border:none}
136
- .back-to-top.show{opacity:1;visibility:visible}
137
- @media(max-width:767px){
138
- .navbar{top:10px;border-radius:16px;padding:10px 14px}
139
- .tabs-bar{top:125px}
140
- .page-wrapper{margin-top:176px}
141
- .sidebar{display:none!important}
142
- .ai-mobile-wrap{display:block}
143
- .images-grid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr))}
144
- .videos-grid{grid-template-columns:1fr}
145
- }
146
- @media(min-width:768px){
147
- .navbar{flex-wrap:nowrap;padding:0 22px;height:68px}
148
- .page-wrapper{display:grid;grid-template-columns:1fr 300px;gap:24px;margin:176px auto 60px}
149
- .sidebar{order:unset;margin-top:0}
150
- .ai-mobile-wrap{display:none!important}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
  </style>
153
  </head>
154
  <body>
155
- <div class="bg-mesh"><div class="orb orb-1"></div><div class="orb orb-2"></div><div class="orb orb-3"></div></div>
156
 
 
 
 
 
 
 
 
 
157
  <nav class="navbar">
158
- <a class="brand" href="#"><div class="brand-icon"><i class="fa-solid fa-bolt"></i></div><span>SurfGO</span></a>
 
 
 
159
  <div class="search-container">
160
  <form class="search-bar" id="search-form">
161
  <input id="main-input" placeholder="ابحث في الويب..." type="text" autocomplete="off" />
162
- <button class="search-btn" type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
 
 
163
  </form>
164
  </div>
165
- <div class="nav-actions"><button id="theme-toggle"></button></div>
 
 
166
  </nav>
167
 
168
- <div class="tabs-bar">
169
- <button class="tab-pill active" data-tab="all"><i class="fa-solid fa-globe"></i> الكل</button>
170
- <button class="tab-pill" data-tab="news"><i class="fa-solid fa-newspaper"></i> أخبار</button>
171
- <button class="tab-pill" data-tab="images"><i class="fa-solid fa-image"></i> صور</button>
172
- <button class="tab-pill" data-tab="videos"><i class="fa-solid fa-play"></i> فيديو</button>
 
173
  </div>
174
 
 
175
  <div class="page-wrapper">
176
- <main class="results-area">
 
177
  <div id="loading-text" class="spinning">جاري جلب النتائج…</div>
 
 
178
  <div class="ai-mobile-wrap" id="ai-mobile-wrap">
179
  <div class="ai-glow-ring"></div>
180
  <div class="ai-widget">
181
- <div class="ai-widget-header"><div class="ai-widget-icon"><i class="fa-solid fa-robot"></i></div><span>إجابة الذكاء الاصطناعي</span><span class="ai-widget-badge">AI</span></div>
182
- <div class="ai-answer-body loading" id="ai-answer-body-mobile"><div class="ai-skeleton"></div><div class="ai-skeleton"></div><div class="ai-skeleton"></div></div>
 
 
 
 
 
 
183
  <div class="ai-sources" id="ai-sources-mobile"></div>
184
  <button class="ai-copy-btn" id="ai-copy-mobile" style="display:none"><i class="fa-regular fa-copy"></i> نسخ</button>
185
  <div class="ai-widget-footer"><i class="fa-solid fa-bolt"></i> مدعوم بواسطة AnesNT</div>
186
  </div>
187
  </div>
 
 
188
  <div id="results-container"></div>
189
  </main>
190
 
191
- <aside class="sidebar" id="sidebar">
 
192
  <div class="ai-widget-wrap">
193
  <div class="ai-glow-ring"></div>
194
  <div class="ai-widget">
195
- <div class="ai-widget-header"><div class="ai-widget-icon"><i class="fa-solid fa-robot"></i></div><span>إجابة الذكاء الاصطناعي</span><span class="ai-widget-badge">AI</span></div>
196
- <div class="ai-answer-body loading" id="ai-answer-body"><div class="ai-skeleton"></div><div class="ai-skeleton"></div><div class="ai-skeleton"></div></div>
 
 
 
 
 
 
197
  <div class="ai-sources" id="ai-sources-desktop"></div>
198
  <button class="ai-copy-btn" id="ai-copy-desktop" style="display:none"><i class="fa-regular fa-copy"></i> نسخ</button>
199
  <div class="ai-widget-footer"><i class="fa-solid fa-bolt"></i> مدعوم بواسطة AnesNT</div>
@@ -202,45 +897,78 @@
202
  </aside>
203
  </div>
204
 
205
- <button class="back-to-top" id="backToTop"><i class="fa-solid fa-arrow-up"></i></button>
 
206
 
 
207
  <script>
208
  (() => {
 
209
  const SEARXNG_URL = "https://cjj-on-hf-searxng.hf.space/search";
210
  const GEMINI_API = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent";
211
- const GEMINI_KEY = ""; // ضع مفتاح Gemini هنا
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
- // --- السمة ---
214
  const themeBtn = document.getElementById('theme-toggle');
215
  const setTheme = (t) => {
216
  document.documentElement.setAttribute('data-theme', t);
217
- localStorage.setItem('surfgo-theme', t);
218
  themeBtn.innerHTML = t === 'dark' ? '<i class="fa-solid fa-sun"></i>' : '<i class="fa-solid fa-moon"></i>';
219
  };
220
- setTheme(localStorage.getItem('surfgo-theme') || 'light');
221
- themeBtn.addEventListener('click', () => setTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'));
 
 
 
222
 
 
223
  const params = new URLSearchParams(window.location.search);
224
- let query = params.get('q') || localStorage.getItem('surfgo-lastq') || '';
225
  let currentTab = params.get('tab') || 'all';
 
226
  const inputEl = document.getElementById('main-input');
227
  const resultsEl = document.getElementById('results-container');
228
  const loadingEl = document.getElementById('loading-text');
229
  const sidebarEl = document.getElementById('sidebar');
230
  const aiMobileWrap = document.getElementById('ai-mobile-wrap');
231
 
 
232
  const setActiveTab = (tab) => {
233
- document.querySelectorAll('.tab-pill').forEach(b => b.classList.toggle('active', b.dataset.tab === tab));
 
 
234
  };
235
  setActiveTab(currentTab);
236
 
237
- // --- دوال مساعدة ---
238
- const esc = (s) => s ? s.replace(/[&<>'"]/g, m => ({'&':'&amp;','<':'&lt;','>':'&gt;',"'":'&#39;','"':'&quot;'}[m]||m)) : '';
239
- const domain = (url) => { try { return new URL(url).hostname.replace('www.',''); } catch { return url||''; } };
240
- const proxyImg = (url) => url && !url.startsWith('data:') ? `https://wsrv.nl/?url=${encodeURIComponent(url)}&output=webp` : url;
241
- const favicon = (d) => `https://www.google.com/s2/favicons?domain=${d}&sz=32`;
 
 
 
 
 
 
 
 
 
 
 
242
 
243
- // استخراج أفضل رابط صورة (يعيد رابطاً صالحاً قدر الإمكان)
244
  const extractBestImage = (r) => {
245
  const candidates = [r.img_src, r.thumbnail_src, r.thumbnail, r.image];
246
  for (const c of candidates) {
@@ -250,40 +978,60 @@
250
  return null;
251
  };
252
 
253
- // --- الذكاء الاصطناعي ---
254
  let currentAItext = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  const aiUpdate = (text, sources) => {
256
  currentAItext = text;
257
- ['ai-answer-body','ai-answer-body-mobile'].forEach(id => {
258
- const el = document.getElementById(id); if(el) { el.classList.remove('loading'); el.textContent = text; }
 
 
 
 
 
 
 
 
 
 
 
259
  });
260
- ['ai-copy-desktop','ai-copy-mobile'].forEach(id => { const b = document.getElementById(id); if(b) b.style.display='inline-flex'; });
261
- const chips = sources.slice(0,4).map(s => `<a class="ai-source-chip" href="${s.url}" target="_blank"><i class="fa-solid fa-link"></i>${esc(domain(s.url))}</a>`).join('');
262
- ['ai-sources-desktop','ai-sources-mobile'].forEach(id => { const el = document.getElementById(id); if(el) el.innerHTML = chips; });
263
  };
264
 
265
  const runAI = async (q, results) => {
266
- ['ai-answer-body','ai-answer-body-mobile'].forEach(id => {
267
- const el = document.getElementById(id); if(el) { el.classList.add('loading'); el.innerHTML = '<div class="ai-skeleton"></div><div class="ai-skeleton"></div><div class="ai-skeleton"></div>'; }
268
- });
269
- ['ai-copy-desktop','ai-copy-mobile'].forEach(id => { const b = document.getElementById(id); if(b) b.style.display='none'; });
270
- ['ai-sources-desktop','ai-sources-mobile'].forEach(id => { const el = document.getElementById(id); if(el) el.innerHTML = ''; });
271
-
272
  if (GEMINI_KEY.trim()) {
273
  try {
274
- const snippets = results.slice(0,5).map((r,i) => `[${i+1}] ${r.title||''}: ${r.content||''}`).join('\n');
275
  const resp = await fetch(`${GEMINI_API}?key=${GEMINI_KEY}`, {
276
- method:'POST', headers:{'Content-Type':'application/json'},
277
- body: JSON.stringify({contents:[{parts:[{text:`أجب باختصار بالعربية عن: "${q}" بناءً على:\n${snippets}`}]}], generationConfig:{maxOutputTokens:400}})
 
 
 
278
  });
279
  const data = await resp.json();
280
- aiUpdate(data.candidates?.[0]?.content?.parts?.[0]?.text || 'لا توجد إجابة.', results.slice(0,4));
281
  return;
282
- } catch(e) { console.warn('Gemini fallback'); }
283
  }
284
  const best = results[0];
285
- const summary = best ? (best.content||'').slice(0,400) : '';
286
- aiUpdate(summary ? `🔍 ${summary}` : 'لا توجد معلومات كافية.', results.slice(0,3));
287
  };
288
 
289
  const showAI = (visible) => {
@@ -291,30 +1039,51 @@
291
  if (aiMobileWrap) aiMobileWrap.style.display = visible ? '' : 'none';
292
  };
293
 
294
- // نسخ الرابط
295
  document.addEventListener('click', (e) => {
296
  if (e.target.classList.contains('copy-link-btn')) {
297
- const url = e.target.dataset.url;
298
- navigator.clipboard.writeText(url).then(() => {
299
  e.target.innerHTML = '<i class="fa-solid fa-check"></i>';
300
  setTimeout(() => { e.target.innerHTML = '<i class="fa-regular fa-copy"></i>'; }, 1500);
301
- });
302
  }
303
  });
304
 
305
- // مراقب الظهور
306
- const observer = new IntersectionObserver(entries => entries.forEach(en => { if(en.isIntersecting) en.target.classList.add('visible'); }), {threshold:0.1});
307
- const observe = () => document.querySelectorAll('.search-result,.image-card,.video-card').forEach(el => observer.observe(el));
 
 
 
 
 
308
 
309
- // العودة للأعلى
310
  const backBtn = document.getElementById('backToTop');
311
- window.addEventListener('scroll', () => backBtn.classList.toggle('show', scrollY > 400));
312
- backBtn.addEventListener('click', () => scrollTo({top:0,behavior:'smooth'}));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
 
314
- // جلب JSON مع زيادة limit
315
- const fetchJSON = (url) => fetch(url, {signal: AbortSignal.timeout(10000)}).then(r => r.json());
 
 
316
 
317
- // --- دوال العرض ---
318
  const createSectionTitle = (text, tabLink) => {
319
  const h3 = document.createElement('h3');
320
  h3.className = 'section-title';
@@ -324,193 +1093,202 @@
324
 
325
  const renderWebResults = (results) => {
326
  results.forEach(r => {
327
- const d = domain(r.url);
328
  const art = document.createElement('article');
329
  art.className = 'search-result';
330
  art.innerHTML = `
331
- <div class="favicon-wrap"><img src="${favicon(d)}" onerror="this.style.display='none';this.nextElementSibling.style.display='flex'" /><i class="fa-solid fa-globe fallback-icon" style="display:none"></i></div>
 
 
 
332
  <div class="result-content">
333
  <div class="result-domain"><i class="fa-solid fa-link"></i> ${esc(d)}</div>
334
- <a class="result-title" href="${esc(r.url)}" target="_blank">${esc(r.title)}</a>
335
- <p class="result-snippet">${esc(r.content)}</p>
336
  </div>
337
- <button class="copy-link-btn" data-url="${esc(r.url)}"><i class="fa-regular fa-copy"></i></button>
338
  `;
339
  resultsEl.appendChild(art);
340
  });
341
  };
342
 
343
- const renderImageCards = (images) => {
344
  if (!images.length) return;
345
  const title = createSectionTitle('صور', 'images');
346
- resultsEl.insertBefore(title, resultsEl.firstChild);
347
- const grid = document.createElement('div'); grid.className = 'images-grid';
 
 
 
 
 
348
  images.forEach(r => {
349
  const raw = extractBestImage(r);
350
  if (!raw) return;
351
  const proxied = proxyImg(raw);
352
- const card = document.createElement('div'); card.className = 'image-card';
 
353
  card.innerHTML = `
354
- <a class="image-card-link" href="${esc(r.url)}" target="_blank">
355
- <img src="${esc(proxied)}" loading="lazy" data-original="${esc(raw)}" onerror="handleImageError(this)" />
356
- <div class="img-error-overlay"><i class="fa-solid fa-image-slash"></i> تعذر التحميل</div>
357
  </a>
358
- <div class="image-info">${esc(r.title)}</div>
359
  `;
360
  grid.appendChild(card);
361
  });
362
- resultsEl.insertBefore(grid, resultsEl.firstChild);
363
- };
364
-
365
- // معالج خطأ الصور (يحاول التحميل المباشر)
366
- window.handleImageError = function(img) {
367
- const original = img.dataset.original;
368
- if (original && img.src !== original) {
369
- img.src = original; // حاول مرة أخرى بالرابط الأصلي
370
  } else {
371
- img.style.display = 'none';
372
- const overlay = img.nextElementSibling;
373
- if (overlay && overlay.classList.contains('img-error-overlay')) {
374
- overlay.style.display = 'flex';
375
- }
376
  }
377
  };
378
 
379
- const renderVideoCards = (videos) => {
380
  if (!videos.length) return;
381
  const title = createSectionTitle('فيديوهات', 'videos');
382
- // أدرج بعد أي عنوان صور إن وجد، وإلا في البداية
383
- const firstImageTitle = resultsEl.querySelector('.section-title');
384
- if (firstImageTitle) {
385
- resultsEl.insertBefore(title, firstImageTitle.nextSibling);
386
  } else {
387
- resultsEl.insertBefore(title, resultsEl.firstChild);
388
  }
389
- const grid = document.createElement('div'); grid.className = 'videos-grid';
 
390
  videos.forEach(r => {
391
  const thumb = proxyImg(r.thumbnail) || '';
392
- const card = document.createElement('div'); card.className = 'video-card';
 
393
  card.innerHTML = `
394
- <a href="${esc(r.url)}" target="_blank" class="video-thumb-wrap">
395
- <img src="${thumb}" /><div class="play-overlay"><i class="fa-solid fa-play"></i></div>
 
396
  </a>
397
  <div class="video-details">
398
- <a class="video-title" href="${esc(r.url)}">${esc(r.title)}</a>
399
  </div>
400
  `;
401
  grid.appendChild(card);
402
  });
403
- // أدرج الشبكة بعد العنوان المناسب
404
- if (title.nextSibling) {
405
- resultsEl.insertBefore(grid, title.nextSibling);
406
  } else {
407
  resultsEl.appendChild(grid);
408
  }
409
  };
410
 
411
- // --- البحث الرئيسي ---
412
  const performSearch = async (q, tab) => {
413
  resultsEl.innerHTML = '';
414
  loadingEl.style.display = 'flex';
415
  loadingEl.classList.add('spinning');
416
  showAI(tab === 'all');
417
 
418
- const fetchWithLimit = (cat) => {
419
- const url = `${SEARXNG_URL}?q=${encodeURIComponent(q)}&format=json&categories=${cat}&language=ar&safesearch=1&limit=100`;
420
- return fetchJSON(url).catch(() => ({ results: [] }));
421
- };
422
-
423
  try {
424
  if (tab === 'all') {
425
- // 1) جلب عام أولاً وعرضه فوراً
426
- const generalData = await fetchWithLimit('general');
427
  const webResults = generalData.results || [];
428
  loadingEl.style.display = 'none';
 
429
  if (webResults.length) {
430
  renderWebResults(webResults);
431
- runAI(q, webResults); // AI من نتائج الويب
432
  } else {
433
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد نتائج</p></div>`;
434
  }
435
- observe();
436
 
437
- // 2) جلب الصور والفيديوهات بالتوازي وإضافتها في الأعلى
438
- const [imagesData, videosData] = await Promise.all([
439
- fetchWithLimit('images'),
440
- fetchWithLimit('videos')
441
- ]);
442
- const imageResults = (imagesData.results || []).filter(r => extractBestImage(r)).slice(0, 10);
443
- const videoResults = (videosData.results || []).filter(r => r.url && r.url.includes('youtube.com/watch')).slice(0, 6);
444
 
445
- // أضف الصور والفيديوهات (الفيديوهات بعد الصور)
446
- if (imageResults.length) renderImageCards(imageResults);
447
- if (videoResults.length) renderVideoCards(videoResults);
448
- observe();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
 
450
  } else {
451
- // باقي التبويبات
452
- const cat = {news:'news', images:'images', videos:'videos'}[tab] || 'general';
453
- const data = await fetchWithLimit(cat);
454
  const results = data.results || [];
455
  loadingEl.style.display = 'none';
456
- if (results.length) {
457
- if (tab === 'images') {
458
- const validImages = results.filter(r => extractBestImage(r));
459
- if (validImages.length) {
460
- const grid = document.createElement('div'); grid.className = 'images-grid';
461
- validImages.forEach(r => {
462
- const raw = extractBestImage(r);
463
- const card = document.createElement('div'); card.className = 'image-card';
464
- card.innerHTML = `
465
- <a class="image-card-link" href="${esc(r.url)}" target="_blank">
466
- <img src="${esc(proxyImg(raw))}" loading="lazy" data-original="${esc(raw)}" onerror="handleImageError(this)" />
467
- <div class="img-error-overlay"><i class="fa-solid fa-image-slash"></i> تعذر التحميل</div>
468
- </a>
469
- <div class="image-info">${esc(r.title)}</div>
470
- `;
471
- grid.appendChild(card);
472
- });
473
- resultsEl.appendChild(grid);
474
- } else {
475
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد صور</p></div>`;
476
- }
477
- } else if (tab === 'videos') {
478
- if (results.length) {
479
- const grid = document.createElement('div'); grid.className = 'videos-grid';
480
- results.forEach(r => {
481
- const card = document.createElement('div'); card.className = 'video-card';
482
- card.innerHTML = `
483
- <a href="${esc(r.url)}" target="_blank" class="video-thumb-wrap">
484
- <img src="${proxyImg(r.thumbnail)}" /><div class="play-overlay"><i class="fa-solid fa-play"></i></div>
485
- </a>
486
- <div class="video-details">
487
- <a class="video-title" href="${esc(r.url)}">${esc(r.title)}</a>
488
- </div>
489
- `;
490
- grid.appendChild(card);
491
- });
492
- resultsEl.appendChild(grid);
493
- } else {
494
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد فيديوهات</p></div>`;
495
- }
496
  } else {
497
- renderWebResults(results);
498
  }
499
- observe();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  } else {
501
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد نتائج</p></div>`;
502
  }
 
503
  }
504
- } catch(e) {
505
  loadingEl.style.display = 'none';
506
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-triangle-exclamation"></i><p>تعذّر الاتصال</p></div>`;
507
  }
508
  };
509
 
510
- // --- التهيئة ---
511
  if (query) {
512
  inputEl.value = query;
513
- localStorage.setItem('surfgo-lastq', query);
514
  performSearch(query, currentTab);
515
  } else {
516
  loadingEl.style.display = 'block';
@@ -518,11 +1296,12 @@
518
  loadingEl.textContent = 'أدخل كلمة البحث للبدء.';
519
  }
520
 
521
- document.getElementById('search-form').addEventListener('submit', e => {
 
522
  e.preventDefault();
523
  const q = inputEl.value.trim();
524
  if (!q) return;
525
- localStorage.setItem('surfgo-lastq', q);
526
  window.history.pushState({}, '', `?q=${encodeURIComponent(q)}&tab=${currentTab}`);
527
  query = q;
528
  performSearch(q, currentTab);
@@ -538,6 +1317,11 @@
538
  if (query) performSearch(query, tab);
539
  });
540
  });
 
 
 
 
 
541
  })();
542
  </script>
543
  </body>
 
2
  <html data-theme="light" dir="rtl" lang="ar">
3
  <head>
4
  <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
6
+ <title>SurfGO | محرك بحث متكامل</title>
7
  <link rel="preconnect" href="https://fonts.googleapis.com" />
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9
  <link href="https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Tajawal:wght@300;400;500;700&display=swap" rel="stylesheet" />
10
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" />
11
  <style>
12
+ /* =============== المتغيرات الأساسية =============== */
13
  :root {
14
  --bg-base: #f0f2f8;
15
+ --bg-nav: rgba(255, 255, 255, 0.82);
16
  --bg-card: #ffffff;
17
  --bg-input: #e8ebf5;
18
  --bg-input-focus: #ffffff;
19
+ --border: rgba(99, 102, 241, 0.12);
20
+ --border-hover: rgba(99, 102, 241, 0.4);
21
  --accent: #5b5ef4;
22
  --accent-2: #e0427a;
23
+ --accent-glow: rgba(91, 94, 244, 0.18);
24
  --text-main: #12132a;
25
  --text-sub: #6b7280;
26
  --text-faint: #9ca3af;
27
+ --shadow-card: 0 2px 12px rgba(91, 94, 244, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
28
+ --shadow-hover: 0 8px 32px rgba(91, 94, 244, 0.13), 0 2px 8px rgba(0, 0, 0, 0.06);
29
  --radius-nav: 22px;
30
  --radius-card: 18px;
31
  --radius-pill: 100px;
32
+ --transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
33
  }
34
+
35
  [data-theme="dark"] {
36
  --bg-base: #0c0d1d;
37
+ --bg-nav: rgba(18, 20, 40, 0.92);
38
  --bg-card: #13152e;
39
  --bg-input: #1c1f3d;
40
  --bg-input-focus: #13152e;
41
+ --border: rgba(130, 133, 255, 0.13);
42
+ --border-hover: rgba(130, 133, 255, 0.4);
43
  --accent: #8284fc;
44
  --accent-2: #f472b6;
45
+ --accent-glow: rgba(130, 133, 255, 0.16);
46
  --text-main: #eef0ff;
47
  --text-sub: #9099c0;
48
  --text-faint: #5a6080;
49
+ --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.28);
50
+ --shadow-hover: 0 10px 36px rgba(130, 133, 255, 0.14);
51
+ }
52
+
53
+ /* =============== إعادة الضبط =============== */
54
+ *,
55
+ *::before,
56
+ *::after {
57
+ margin: 0;
58
+ padding: 0;
59
+ box-sizing: border-box;
60
+ }
61
+
62
+ body {
63
+ font-family: 'Tajawal', sans-serif;
64
+ background: var(--bg-base);
65
+ color: var(--text-main);
66
+ min-height: 100vh;
67
+ overflow-x: hidden;
68
+ transition: background 0.35s, color 0.35s;
69
+ position: relative;
70
+ }
71
+
72
+ /* =============== خلفية متحركة =============== */
73
+ .bg-mesh {
74
+ position: fixed;
75
+ inset: 0;
76
+ z-index: 0;
77
+ pointer-events: none;
78
+ overflow: hidden;
79
+ }
80
+ .orb {
81
+ position: absolute;
82
+ border-radius: 50%;
83
+ filter: blur(85px);
84
+ opacity: 0.4;
85
+ animation: drift 20s ease-in-out infinite alternate;
86
+ }
87
+ .orb-1 {
88
+ width: 55vw;
89
+ height: 55vw;
90
+ background: radial-gradient(circle, rgba(91, 94, 244, 0.15) 0%, transparent 70%);
91
+ top: -20%;
92
+ right: -15%;
93
+ }
94
+ .orb-2 {
95
+ width: 45vw;
96
+ height: 45vw;
97
+ background: radial-gradient(circle, rgba(224, 66, 122, 0.12) 0%, transparent 70%);
98
+ bottom: -15%;
99
+ left: -10%;
100
+ }
101
+ .orb-3 {
102
+ width: 35vw;
103
+ height: 35vw;
104
+ background: radial-gradient(circle, rgba(167, 139, 250, 0.1) 0%, transparent 70%);
105
+ top: 55%;
106
+ left: 55%;
107
+ }
108
+ @keyframes drift {
109
+ 0% {
110
+ transform: translate(0, 0) scale(1);
111
+ }
112
+ 100% {
113
+ transform: translate(4%, 3%) scale(1.06);
114
+ }
115
+ }
116
+
117
+ /* =============== شريط التنقل =============== */
118
+ .navbar {
119
+ position: fixed;
120
+ top: 14px;
121
+ left: 50%;
122
+ transform: translateX(-50%);
123
+ width: 95%;
124
+ max-width: 1280px;
125
+ min-height: 68px;
126
+ background: var(--bg-nav);
127
+ backdrop-filter: blur(28px) saturate(1.6);
128
+ -webkit-backdrop-filter: blur(28px) saturate(1.6);
129
+ border: 1px solid var(--border);
130
+ border-radius: var(--radius-nav);
131
+ display: flex;
132
+ flex-wrap: wrap;
133
+ align-items: center;
134
+ justify-content: space-between;
135
+ padding: 10px 18px;
136
+ z-index: 1000;
137
+ box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
138
+ gap: 12px;
139
+ transition: background 0.35s, border-color 0.35s;
140
+ }
141
+ .brand {
142
+ font-family: 'Syne', sans-serif;
143
+ font-weight: 400;
144
+ font-size: 21px;
145
+ text-decoration: none;
146
+ color: var(--text-main);
147
+ display: flex;
148
+ align-items: center;
149
+ gap: 10px;
150
+ letter-spacing: -0.01em;
151
+ flex-shrink: 0;
152
+ transition: transform 0.2s;
153
+ }
154
+ .brand:hover {
155
+ transform: scale(1.03);
156
+ }
157
+ .brand-icon {
158
+ width: 36px;
159
+ height: 36px;
160
+ background: linear-gradient(135deg, var(--accent), var(--accent-2));
161
+ border-radius: 10px;
162
+ display: flex;
163
+ align-items: center;
164
+ justify-content: center;
165
+ color: #fff;
166
+ font-size: 15px;
167
+ flex-shrink: 0;
168
+ box-shadow: 0 4px 14px var(--accent-glow);
169
+ }
170
+ .search-container {
171
+ flex: 1;
172
+ max-width: 580px;
173
+ width: 100%;
174
+ }
175
+ .search-bar {
176
+ display: flex;
177
+ align-items: center;
178
+ background: var(--bg-input);
179
+ border: 1.5px solid var(--border);
180
+ border-radius: var(--radius-pill);
181
+ padding: 4px 4px 4px 16px;
182
+ transition: var(--transition);
183
+ width: 100%;
184
+ }
185
+ .search-bar:focus-within {
186
+ border-color: var(--accent);
187
+ background: var(--bg-input-focus);
188
+ box-shadow: 0 0 0 4px var(--accent-glow);
189
+ }
190
+ .search-bar input {
191
+ flex: 1;
192
+ background: transparent;
193
+ border: none;
194
+ padding: 9px 0;
195
+ color: var(--text-main);
196
+ font-size: 14.5px;
197
+ min-width: 0;
198
+ font-family: 'Tajawal', sans-serif;
199
+ }
200
+ .search-bar input::placeholder {
201
+ color: var(--text-faint);
202
+ }
203
+ .search-btn {
204
+ background: linear-gradient(135deg, var(--accent), var(--accent-2));
205
+ border: none;
206
+ color: #fff;
207
+ cursor: pointer;
208
+ width: 40px;
209
+ height: 36px;
210
+ border-radius: var(--radius-pill);
211
+ display: flex;
212
+ align-items: center;
213
+ justify-content: center;
214
+ font-size: 14px;
215
+ flex-shrink: 0;
216
+ transition: var(--transition);
217
+ box-shadow: 0 2px 8px var(--accent-glow);
218
+ }
219
+ .search-btn:hover {
220
+ opacity: 0.88;
221
+ transform: scale(1.06);
222
+ }
223
+ .nav-actions {
224
+ display: flex;
225
+ align-items: center;
226
+ gap: 8px;
227
+ }
228
+ #theme-toggle {
229
+ background: var(--bg-input);
230
+ border: 1.5px solid var(--border);
231
+ color: var(--text-sub);
232
+ cursor: pointer;
233
+ width: 38px;
234
+ height: 38px;
235
+ border-radius: 50%;
236
+ display: flex;
237
+ align-items: center;
238
+ justify-content: center;
239
+ font-size: 15px;
240
+ transition: var(--transition);
241
+ flex-shrink: 0;
242
+ }
243
+ #theme-toggle:hover {
244
+ border-color: var(--accent);
245
+ color: var(--accent);
246
+ }
247
+
248
+ /* =============== شريط التبويبات =============== */
249
+ .tabs-bar {
250
+ position: fixed;
251
+ top: 98px;
252
+ left: 50%;
253
+ transform: translateX(-50%);
254
+ width: 95%;
255
+ max-width: 1280px;
256
+ display: flex;
257
+ gap: 6px;
258
+ z-index: 999;
259
+ overflow-x: auto;
260
+ padding: 6px 10px;
261
+ backdrop-filter: blur(16px);
262
+ background: rgba(255, 255, 255, 0.2);
263
+ border: 1px solid var(--border);
264
+ border-radius: 40px;
265
+ scrollbar-width: none;
266
+ }
267
+ [data-theme="dark"] .tabs-bar {
268
+ background: rgba(18, 20, 40, 0.35);
269
+ }
270
+ .tab-pill {
271
+ padding: 7px 16px;
272
+ border-radius: var(--radius-pill);
273
+ background: var(--bg-card);
274
+ border: 1.5px solid var(--border);
275
+ color: var(--text-sub);
276
+ font-family: 'Tajawal', sans-serif;
277
+ font-size: 13px;
278
+ font-weight: 500;
279
+ cursor: pointer;
280
+ transition: var(--transition);
281
+ display: flex;
282
+ align-items: center;
283
+ gap: 6px;
284
+ white-space: nowrap;
285
+ box-shadow: var(--shadow-card);
286
+ }
287
+ .tab-pill:hover {
288
+ border-color: var(--border-hover);
289
+ color: var(--accent);
290
+ }
291
+ .tab-pill.active {
292
+ background: var(--accent);
293
+ color: #fff;
294
+ border-color: var(--accent);
295
+ box-shadow: 0 4px 16px var(--accent-glow);
296
+ }
297
+
298
+ /* =============== التخطيط العام =============== */
299
+ .page-wrapper {
300
+ position: relative;
301
+ z-index: 1;
302
+ max-width: 1280px;
303
+ margin: 170px auto 60px;
304
+ padding: 0 16px;
305
+ display: flex;
306
+ flex-direction: column;
307
+ gap: 24px;
308
+ }
309
+ .results-area {
310
+ min-width: 0;
311
+ width: 100%;
312
+ }
313
+
314
+ /* =============== مؤشر التحميل =============== */
315
+ #loading-text {
316
+ color: var(--text-sub);
317
+ font-size: 13.5px;
318
+ margin-bottom: 18px;
319
+ display: flex;
320
+ align-items: center;
321
+ gap: 8px;
322
+ }
323
+ #loading-text.spinning::before {
324
+ content: '';
325
+ display: inline-block;
326
+ width: 14px;
327
+ height: 14px;
328
+ border: 2px solid var(--border);
329
+ border-top-color: var(--accent);
330
+ border-radius: 50%;
331
+ animation: spin 0.8s linear infinite;
332
+ flex-shrink: 0;
333
+ }
334
+ @keyframes spin {
335
+ to {
336
+ transform: rotate(360deg);
337
+ }
338
+ }
339
+
340
+ /* =============== تأثيرات الظهور =============== */
341
+ .search-result,
342
+ .image-card,
343
+ .video-card {
344
+ opacity: 0;
345
+ transform: translateY(20px);
346
+ transition: opacity 0.5s ease, transform 0.5s ease;
347
+ }
348
+ .search-result.visible,
349
+ .image-card.visible,
350
+ .video-card.visible {
351
+ opacity: 1;
352
+ transform: translateY(0);
353
+ }
354
+
355
+ /* =============== بطاقات نتائج الويب =============== */
356
+ .search-result {
357
+ background: var(--bg-card);
358
+ border: 1.5px solid var(--border);
359
+ border-radius: var(--radius-card);
360
+ padding: 18px 20px;
361
+ margin-bottom: 12px;
362
+ transition: var(--transition);
363
+ box-shadow: var(--shadow-card);
364
+ display: flex;
365
+ gap: 14px;
366
+ align-items: flex-start;
367
+ }
368
+ .search-result:hover {
369
+ border-color: var(--border-hover);
370
+ box-shadow: var(--shadow-hover);
371
+ transform: translateY(-2px);
372
+ }
373
+ .favicon-wrap {
374
+ width: 22px;
375
+ height: 22px;
376
+ border-radius: 5px;
377
+ overflow: hidden;
378
+ flex-shrink: 0;
379
+ margin-top: 3px;
380
+ background: var(--bg-input);
381
+ display: flex;
382
+ align-items: center;
383
+ justify-content: center;
384
+ }
385
+ .favicon-wrap img {
386
+ width: 16px;
387
+ height: 16px;
388
+ object-fit: contain;
389
+ }
390
+ .fallback-icon {
391
+ color: var(--text-faint);
392
+ font-size: 11px;
393
+ }
394
+ .result-content {
395
+ flex: 1;
396
+ min-width: 0;
397
+ }
398
+ .result-domain {
399
+ font-size: 11.5px;
400
+ color: var(--text-faint);
401
+ margin-bottom: 4px;
402
+ display: flex;
403
+ align-items: center;
404
+ gap: 4px;
405
+ }
406
+ .result-title {
407
+ font-size: 16px;
408
+ font-weight: 700;
409
+ color: var(--accent);
410
+ text-decoration: none;
411
+ display: inline-block;
412
+ margin-bottom: 6px;
413
+ line-height: 1.4;
414
+ transition: color 0.2s;
415
+ }
416
+ .result-title:hover {
417
+ color: var(--accent-2);
418
+ text-decoration: underline;
419
+ }
420
+ .result-snippet {
421
+ font-size: 13.5px;
422
+ color: var(--text-sub);
423
+ line-height: 1.65;
424
+ }
425
+ .copy-link-btn {
426
+ background: none;
427
+ border: none;
428
+ color: var(--text-faint);
429
+ cursor: pointer;
430
+ font-size: 13px;
431
+ margin-right: 8px;
432
+ transition: color 0.2s;
433
+ }
434
+ .copy-link-btn:hover {
435
+ color: var(--accent);
436
+ }
437
+
438
+ /* =============== شبكة الصور =============== */
439
+ .images-grid {
440
+ display: grid;
441
+ grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
442
+ gap: 12px;
443
+ width: 100%;
444
+ }
445
+ .image-card {
446
+ background: var(--bg-card);
447
+ border: 1.5px solid var(--border);
448
+ border-radius: var(--radius-card);
449
+ overflow: hidden;
450
+ transition: var(--transition);
451
+ box-shadow: var(--shadow-card);
452
+ display: flex;
453
+ flex-direction: column;
454
+ }
455
+ .image-card:hover {
456
+ border-color: var(--border-hover);
457
+ box-shadow: var(--shadow-hover);
458
+ transform: translateY(-5px);
459
+ }
460
+ .image-card-link {
461
+ display: block;
462
+ width: 100%;
463
+ height: 150px;
464
+ overflow: hidden;
465
+ background: var(--bg-input);
466
+ position: relative;
467
+ }
468
+ .image-card-link img {
469
+ width: 100%;
470
+ height: 100%;
471
+ object-fit: cover;
472
+ transition: transform 0.4s ease;
473
+ }
474
+ .image-card:hover .image-card-link img {
475
+ transform: scale(1.06);
476
+ }
477
+ .image-info {
478
+ padding: 8px 10px;
479
+ font-size: 11px;
480
+ color: var(--text-sub);
481
+ border-top: 1px solid var(--border);
482
+ }
483
+
484
+ /* =============== شبكة الفيديوهات =============== */
485
+ .videos-grid {
486
+ display: grid;
487
+ grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
488
+ gap: 18px;
489
+ width: 100%;
490
+ }
491
+ .video-card {
492
+ background: var(--bg-card);
493
+ border: 1.5px solid var(--border);
494
+ border-radius: var(--radius-card);
495
+ overflow: hidden;
496
+ transition: var(--transition);
497
+ box-shadow: var(--shadow-card);
498
+ }
499
+ .video-card:hover {
500
+ border-color: var(--border-hover);
501
+ box-shadow: var(--shadow-hover);
502
+ transform: translateY(-3px);
503
+ }
504
+ .video-thumb-wrap {
505
+ position: relative;
506
+ width: 100%;
507
+ height: 150px;
508
+ background: var(--bg-input);
509
+ display: block;
510
+ overflow: hidden;
511
+ }
512
+ .video-thumb-wrap img {
513
+ width: 100%;
514
+ height: 100%;
515
+ object-fit: cover;
516
+ opacity: 0.85;
517
+ transition: 0.3s;
518
+ }
519
+ .video-card:hover .video-thumb-wrap img {
520
+ opacity: 1;
521
+ }
522
+ .play-overlay {
523
+ position: absolute;
524
+ top: 50%;
525
+ left: 50%;
526
+ transform: translate(-50%, -50%);
527
+ width: 42px;
528
+ height: 42px;
529
+ background: rgba(91, 94, 244, 0.92);
530
+ color: white;
531
+ border-radius: 50%;
532
+ display: flex;
533
+ align-items: center;
534
+ justify-content: center;
535
+ font-size: 16px;
536
+ box-shadow: 0 0 20px var(--accent-glow);
537
+ }
538
+ .video-details {
539
+ padding: 10px;
540
+ }
541
+ .video-title {
542
+ font-size: 14px;
543
+ font-weight: 700;
544
+ color: var(--text-main);
545
+ text-decoration: none;
546
+ display: block;
547
+ line-height: 1.4;
548
+ }
549
+ .video-title:hover {
550
+ color: var(--accent);
551
+ }
552
+
553
+ /* =============== عناوين الأقسام =============== */
554
+ .section-title {
555
+ font-size: 18px;
556
+ font-weight: 700;
557
+ margin: 20px 0 12px;
558
+ color: var(--text-main);
559
+ display: flex;
560
+ align-items: center;
561
+ gap: 10px;
562
+ }
563
+ .section-title a {
564
+ color: var(--accent);
565
+ text-decoration: none;
566
+ font-size: 14px;
567
+ font-weight: 500;
568
+ margin-right: auto;
569
+ transition: color 0.2s;
570
+ }
571
+ .section-title a:hover {
572
+ color: var(--accent-2);
573
+ }
574
+
575
+ /* =============== مساعد الذكاء الاصطناعي =============== */
576
+ .sidebar {
577
+ width: 100%;
578
+ order: 2;
579
+ margin-top: 12px;
580
+ }
581
+ .ai-widget-wrap {
582
+ position: relative;
583
+ border-radius: var(--radius-card);
584
+ }
585
+ .ai-glow-ring {
586
+ position: absolute;
587
+ inset: -2px;
588
+ border-radius: calc(var(--radius-card) + 2px);
589
+ background: conic-gradient(from var(--angle, 0deg), var(--accent), var(--accent-2), #a78bfa, var(--accent), var(--accent-2), var(--accent));
590
+ z-index: 0;
591
+ animation: spin-glow 4s linear infinite;
592
+ filter: blur(1px);
593
+ }
594
+ @property --angle {
595
+ syntax: '<angle>';
596
+ initial-value: 0deg;
597
+ inherits: false;
598
+ }
599
+ @keyframes spin-glow {
600
+ to {
601
+ --angle: 360deg;
602
+ }
603
+ }
604
+ .ai-widget {
605
+ position: relative;
606
+ z-index: 1;
607
+ background: var(--bg-card);
608
+ border-radius: var(--radius-card);
609
+ padding: 18px 18px 16px;
610
+ box-shadow: var(--shadow-card);
611
+ }
612
+ .ai-widget-header {
613
+ display: flex;
614
+ align-items: center;
615
+ gap: 9px;
616
+ margin-bottom: 14px;
617
+ }
618
+ .ai-widget-icon {
619
+ width: 30px;
620
+ height: 30px;
621
+ border-radius: 8px;
622
+ background: linear-gradient(135deg, var(--accent), var(--accent-2));
623
+ display: flex;
624
+ align-items: center;
625
+ justify-content: center;
626
+ color: #fff;
627
+ font-size: 12px;
628
+ }
629
+ .ai-widget-badge {
630
+ margin-right: auto;
631
+ font-size: 10px;
632
+ padding: 2px 8px;
633
+ border-radius: 20px;
634
+ background: var(--accent-glow);
635
+ color: var(--accent);
636
+ font-weight: 600;
637
+ border: 1px solid rgba(91, 94, 244, 0.2);
638
+ }
639
+ .ai-answer-body {
640
+ font-size: 13.5px;
641
+ color: var(--text-sub);
642
+ line-height: 1.75;
643
+ min-height: 60px;
644
+ }
645
+ .ai-answer-body.loading {
646
+ display: flex;
647
+ flex-direction: column;
648
+ gap: 8px;
649
+ }
650
+ .ai-skeleton {
651
+ height: 12px;
652
+ border-radius: 6px;
653
+ background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%);
654
+ background-size: 200% 100%;
655
+ animation: shimmer 1.4s ease-in-out infinite;
656
+ }
657
+ @keyframes shimmer {
658
+ 0% {
659
+ background-position: 200% 0;
660
+ }
661
+ 100% {
662
+ background-position: -200% 0;
663
+ }
664
+ }
665
+ .ai-copy-btn {
666
+ margin-top: 14px;
667
+ padding: 8px 16px;
668
+ background: var(--bg-input);
669
+ border: 1px solid var(--border);
670
+ border-radius: 30px;
671
+ cursor: pointer;
672
+ font-size: 12px;
673
+ color: var(--text-sub);
674
+ display: inline-flex;
675
+ align-items: center;
676
+ gap: 6px;
677
+ transition: var(--transition);
678
+ }
679
+ .ai-copy-btn:hover {
680
+ background: var(--accent);
681
+ color: #fff;
682
+ border-color: var(--accent);
683
+ }
684
+ .ai-widget-footer {
685
+ font-size: 10.5px;
686
+ color: var(--text-faint);
687
+ margin-top: 12px;
688
+ padding-top: 10px;
689
+ border-top: 1px solid var(--border);
690
+ display: flex;
691
+ align-items: center;
692
+ gap: 5px;
693
+ }
694
+ .ai-sources {
695
+ margin-top: 10px;
696
+ display: flex;
697
+ flex-wrap: wrap;
698
+ gap: 6px;
699
+ }
700
+ .ai-source-chip {
701
+ font-size: 11px;
702
+ padding: 3px 10px;
703
+ border-radius: 20px;
704
+ background: var(--bg-input);
705
+ border: 1px solid var(--border);
706
+ color: var(--text-faint);
707
+ text-decoration: none;
708
+ display: flex;
709
+ align-items: center;
710
+ gap: 5px;
711
+ transition: var(--transition);
712
+ }
713
+ .ai-source-chip:hover {
714
+ border-color: var(--accent);
715
+ color: var(--accent);
716
+ }
717
+ .ai-mobile-wrap {
718
+ display: none;
719
+ border-radius: var(--radius-card);
720
+ margin-bottom: 16px;
721
+ position: relative;
722
+ }
723
+
724
+ /* =============== زر العودة للأعلى =============== */
725
+ .back-to-top {
726
+ position: fixed;
727
+ bottom: 30px;
728
+ right: 30px;
729
+ z-index: 999;
730
+ width: 46px;
731
+ height: 46px;
732
+ border-radius: 50%;
733
+ background: var(--accent);
734
+ color: #fff;
735
+ display: flex;
736
+ align-items: center;
737
+ justify-content: center;
738
+ font-size: 18px;
739
+ cursor: pointer;
740
+ opacity: 0;
741
+ visibility: hidden;
742
+ transition: 0.3s;
743
+ box-shadow: 0 6px 20px var(--accent-glow);
744
+ border: none;
745
+ }
746
+ .back-to-top.show {
747
+ opacity: 1;
748
+ visibility: visible;
749
+ }
750
+
751
+ /* =============== حالة فارغة =============== */
752
+ .empty-state {
753
+ text-align: center;
754
+ padding: 60px 20px;
755
+ color: var(--text-sub);
756
+ }
757
+ .empty-state i {
758
+ font-size: 40px;
759
+ margin-bottom: 16px;
760
+ color: var(--text-faint);
761
+ display: block;
762
+ }
763
+ .empty-state p {
764
+ font-size: 15px;
765
+ }
766
+
767
+ /* =============== استجابة للجوال =============== */
768
+ @media (max-width: 767px) {
769
+ .navbar {
770
+ top: 10px;
771
+ border-radius: 16px;
772
+ padding: 10px 14px;
773
+ }
774
+ .tabs-bar {
775
+ top: 125px;
776
+ }
777
+ .page-wrapper {
778
+ margin-top: 176px;
779
+ }
780
+ .sidebar {
781
+ display: none !important;
782
+ }
783
+ .ai-mobile-wrap {
784
+ display: block;
785
+ }
786
+ .images-grid {
787
+ grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
788
+ }
789
+ .videos-grid {
790
+ grid-template-columns: 1fr;
791
+ }
792
+ }
793
+ @media (min-width: 768px) {
794
+ .navbar {
795
+ flex-wrap: nowrap;
796
+ padding: 0 22px;
797
+ height: 68px;
798
+ }
799
+ .page-wrapper {
800
+ display: grid;
801
+ grid-template-columns: 1fr 300px;
802
+ gap: 24px;
803
+ margin: 176px auto 60px;
804
+ }
805
+ .sidebar {
806
+ order: unset;
807
+ margin-top: 0;
808
+ }
809
+ .ai-mobile-wrap {
810
+ display: none !important;
811
+ }
812
  }
813
  </style>
814
  </head>
815
  <body>
 
816
 
817
+ <!-- خلفية متحركة -->
818
+ <div class="bg-mesh">
819
+ <div class="orb orb-1"></div>
820
+ <div class="orb orb-2"></div>
821
+ <div class="orb orb-3"></div>
822
+ </div>
823
+
824
+ <!-- شريط التنقل -->
825
  <nav class="navbar">
826
+ <a class="brand" href="index.html">
827
+ <div class="brand-icon"><i class="fa-solid fa-bolt"></i></div>
828
+ <span>SurfGO</span>
829
+ </a>
830
  <div class="search-container">
831
  <form class="search-bar" id="search-form">
832
  <input id="main-input" placeholder="ابحث في الويب..." type="text" autocomplete="off" />
833
+ <button class="search-btn" type="submit" aria-label="بحث">
834
+ <i class="fa-solid fa-magnifying-glass"></i>
835
+ </button>
836
  </form>
837
  </div>
838
+ <div class="nav-actions">
839
+ <button id="theme-toggle" aria-label="تغيير السمة"></button>
840
+ </div>
841
  </nav>
842
 
843
+ <!-- شريط التبويبات -->
844
+ <div class="tabs-bar" role="tablist">
845
+ <button class="tab-pill active" data-tab="all" role="tab"><i class="fa-solid fa-globe"></i> الكل</button>
846
+ <button class="tab-pill" data-tab="news" role="tab"><i class="fa-solid fa-newspaper"></i> أخبار</button>
847
+ <button class="tab-pill" data-tab="images" role="tab"><i class="fa-solid fa-image"></i> صور</button>
848
+ <button class="tab-pill" data-tab="videos" role="tab"><i class="fa-solid fa-play"></i> فيديو</button>
849
  </div>
850
 
851
+ <!-- محتوى الصفحة -->
852
  <div class="page-wrapper">
853
+ <main class="results-area" role="main">
854
+ <!-- مؤشر التحميل -->
855
  <div id="loading-text" class="spinning">جاري جلب النتائج…</div>
856
+
857
+ <!-- مساعد AI للجوال -->
858
  <div class="ai-mobile-wrap" id="ai-mobile-wrap">
859
  <div class="ai-glow-ring"></div>
860
  <div class="ai-widget">
861
+ <div class="ai-widget-header">
862
+ <div class="ai-widget-icon"><i class="fa-solid fa-robot"></i></div>
863
+ <span>إجابة الذكاء الاصطناعي</span>
864
+ <span class="ai-widget-badge">AI</span>
865
+ </div>
866
+ <div class="ai-answer-body loading" id="ai-answer-body-mobile">
867
+ <div class="ai-skeleton"></div><div class="ai-skeleton"></div><div class="ai-skeleton"></div>
868
+ </div>
869
  <div class="ai-sources" id="ai-sources-mobile"></div>
870
  <button class="ai-copy-btn" id="ai-copy-mobile" style="display:none"><i class="fa-regular fa-copy"></i> نسخ</button>
871
  <div class="ai-widget-footer"><i class="fa-solid fa-bolt"></i> مدعوم بواسطة AnesNT</div>
872
  </div>
873
  </div>
874
+
875
+ <!-- حاوية النتائج -->
876
  <div id="results-container"></div>
877
  </main>
878
 
879
+ <!-- مساعد AI لسطح المكتب -->
880
+ <aside class="sidebar" id="sidebar" aria-label="إجابة الذكاء الاصطناعي">
881
  <div class="ai-widget-wrap">
882
  <div class="ai-glow-ring"></div>
883
  <div class="ai-widget">
884
+ <div class="ai-widget-header">
885
+ <div class="ai-widget-icon"><i class="fa-solid fa-robot"></i></div>
886
+ <span>إجابة الذكاء الاصطناعي</span>
887
+ <span class="ai-widget-badge">AI</span>
888
+ </div>
889
+ <div class="ai-answer-body loading" id="ai-answer-body">
890
+ <div class="ai-skeleton"></div><div class="ai-skeleton"></div><div class="ai-skeleton"></div>
891
+ </div>
892
  <div class="ai-sources" id="ai-sources-desktop"></div>
893
  <button class="ai-copy-btn" id="ai-copy-desktop" style="display:none"><i class="fa-regular fa-copy"></i> نسخ</button>
894
  <div class="ai-widget-footer"><i class="fa-solid fa-bolt"></i> مدعوم بواسطة AnesNT</div>
 
897
  </aside>
898
  </div>
899
 
900
+ <!-- زر العودة للأعلى -->
901
+ <button class="back-to-top" id="backToTop" aria-label="العودة للأعلى"><i class="fa-solid fa-arrow-up"></i></button>
902
 
903
+ <!-- ==================== JavaScript ==================== -->
904
  <script>
905
  (() => {
906
+ /* =============== الإعدادات =============== */
907
  const SEARXNG_URL = "https://cjj-on-hf-searxng.hf.space/search";
908
  const GEMINI_API = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent";
909
+ const GEMINI_KEY = ""; // ضع مفتاح Gemini هنا للحصول على إجابات AI حية
910
+
911
+ /* =============== نظام التخزين الآمن =============== */
912
+ const storage = {
913
+ get(key, fallback = '') {
914
+ try { return localStorage.getItem(key) || fallback; }
915
+ catch { try { return sessionStorage.getItem(key) || fallback; } catch { return fallback; } }
916
+ },
917
+ set(key, value) {
918
+ try { localStorage.setItem(key, value); }
919
+ catch { try { sessionStorage.setItem(key, value); } catch { /* الذاكرة فقط */ } }
920
+ }
921
+ };
922
 
923
+ /* =============== إدارة السمة =============== */
924
  const themeBtn = document.getElementById('theme-toggle');
925
  const setTheme = (t) => {
926
  document.documentElement.setAttribute('data-theme', t);
927
+ storage.set('surfgo-theme', t);
928
  themeBtn.innerHTML = t === 'dark' ? '<i class="fa-solid fa-sun"></i>' : '<i class="fa-solid fa-moon"></i>';
929
  };
930
+ setTheme(storage.get('surfgo-theme', 'light'));
931
+ themeBtn.addEventListener('click', () => {
932
+ const current = document.documentElement.getAttribute('data-theme');
933
+ setTheme(current === 'dark' ? 'light' : 'dark');
934
+ });
935
 
936
+ /* =============== المتغيرات العامة =============== */
937
  const params = new URLSearchParams(window.location.search);
938
+ let query = params.get('q') || storage.get('surfgo-lastq', '');
939
  let currentTab = params.get('tab') || 'all';
940
+
941
  const inputEl = document.getElementById('main-input');
942
  const resultsEl = document.getElementById('results-container');
943
  const loadingEl = document.getElementById('loading-text');
944
  const sidebarEl = document.getElementById('sidebar');
945
  const aiMobileWrap = document.getElementById('ai-mobile-wrap');
946
 
947
+ /* =============== تبويب نشط =============== */
948
  const setActiveTab = (tab) => {
949
+ document.querySelectorAll('.tab-pill').forEach(b =>
950
+ b.classList.toggle('active', b.dataset.tab === tab)
951
+ );
952
  };
953
  setActiveTab(currentTab);
954
 
955
+ /* =============== دوال مساعدة =============== */
956
+ const esc = (s) => s ? s.replace(/[&<>'"]/g, m => ({
957
+ '&': '&amp;', '<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;'
958
+ }[m] || m)) : '';
959
+
960
+ const getDomain = (url) => {
961
+ try { return new URL(url).hostname.replace('www.', ''); }
962
+ catch { return url || ''; }
963
+ };
964
+
965
+ const proxyImg = (url) => {
966
+ if (!url || url.startsWith('data:')) return url;
967
+ return `https://wsrv.nl/?url=${encodeURIComponent(url)}&output=webp`;
968
+ };
969
+
970
+ const faviconURL = (domain) => `https://www.google.com/s2/favicons?domain=${domain}&sz=32`;
971
 
 
972
  const extractBestImage = (r) => {
973
  const candidates = [r.img_src, r.thumbnail_src, r.thumbnail, r.image];
974
  for (const c of candidates) {
 
978
  return null;
979
  };
980
 
981
+ /* =============== مساعد الذكاء الاصطناعي =============== */
982
  let currentAItext = '';
983
+
984
+ const aiSetLoading = () => {
985
+ ['ai-answer-body', 'ai-answer-body-mobile'].forEach(id => {
986
+ const el = document.getElementById(id);
987
+ if (el) { el.classList.add('loading'); el.innerHTML = '<div class="ai-skeleton"></div><div class="ai-skeleton"></div><div class="ai-skeleton"></div>'; }
988
+ });
989
+ ['ai-copy-desktop', 'ai-copy-mobile'].forEach(id => {
990
+ const btn = document.getElementById(id); if (btn) btn.style.display = 'none';
991
+ });
992
+ ['ai-sources-desktop', 'ai-sources-mobile'].forEach(id => {
993
+ const el = document.getElementById(id); if (el) el.innerHTML = '';
994
+ });
995
+ };
996
+
997
  const aiUpdate = (text, sources) => {
998
  currentAItext = text;
999
+ ['ai-answer-body', 'ai-answer-body-mobile'].forEach(id => {
1000
+ const el = document.getElementById(id);
1001
+ if (el) { el.classList.remove('loading'); el.textContent = text; }
1002
+ });
1003
+ ['ai-copy-desktop', 'ai-copy-mobile'].forEach(id => {
1004
+ const btn = document.getElementById(id); if (btn) btn.style.display = 'inline-flex';
1005
+ });
1006
+ const chips = sources.slice(0, 4).map(s => {
1007
+ const d = getDomain(s.url);
1008
+ return `<a class="ai-source-chip" href="${s.url}" target="_blank" rel="noopener"><i class="fa-solid fa-link"></i>${esc(d)}</a>`;
1009
+ }).join('');
1010
+ ['ai-sources-desktop', 'ai-sources-mobile'].forEach(id => {
1011
+ const el = document.getElementById(id); if (el) el.innerHTML = chips;
1012
  });
 
 
 
1013
  };
1014
 
1015
  const runAI = async (q, results) => {
1016
+ aiSetLoading();
 
 
 
 
 
1017
  if (GEMINI_KEY.trim()) {
1018
  try {
1019
+ const snippets = results.slice(0, 5).map((r, i) => `[${i + 1}] ${r.title || ''}: ${r.content || ''}`).join('\n');
1020
  const resp = await fetch(`${GEMINI_API}?key=${GEMINI_KEY}`, {
1021
+ method: 'POST', headers: { 'Content-Type': 'application/json' },
1022
+ body: JSON.stringify({
1023
+ contents: [{ parts: [{ text: `أجب باختصار بالعربية عن: "${q}" بناءً على:\n${snippets}` }] }],
1024
+ generationConfig: { maxOutputTokens: 400, temperature: 0.4 }
1025
+ })
1026
  });
1027
  const data = await resp.json();
1028
+ aiUpdate(data.candidates?.[0]?.content?.parts?.[0]?.text || 'لا توجد إجابة.', results.slice(0, 4));
1029
  return;
1030
+ } catch (e) { /* fallback */ }
1031
  }
1032
  const best = results[0];
1033
+ const summary = best ? (best.content || '').slice(0, 400) : '';
1034
+ aiUpdate(summary ? `🔍 ${summary}` : 'لا توجد معلومات كافية.', results.slice(0, 3));
1035
  };
1036
 
1037
  const showAI = (visible) => {
 
1039
  if (aiMobileWrap) aiMobileWrap.style.display = visible ? '' : 'none';
1040
  };
1041
 
1042
+ /* =============== نسخ الرابط =============== */
1043
  document.addEventListener('click', (e) => {
1044
  if (e.target.classList.contains('copy-link-btn')) {
1045
+ navigator.clipboard.writeText(e.target.dataset.url).then(() => {
 
1046
  e.target.innerHTML = '<i class="fa-solid fa-check"></i>';
1047
  setTimeout(() => { e.target.innerHTML = '<i class="fa-regular fa-copy"></i>'; }, 1500);
1048
+ }).catch(() => {});
1049
  }
1050
  });
1051
 
1052
+ /* =============== مراقب الظهور للرسوم المتحركة =============== */
1053
+ const observer = new IntersectionObserver((entries) => {
1054
+ entries.forEach(en => { if (en.isIntersecting) en.target.classList.add('visible'); });
1055
+ }, { threshold: 0.1 });
1056
+
1057
+ const observeNew = () => {
1058
+ document.querySelectorAll('.search-result, .image-card, .video-card').forEach(el => observer.observe(el));
1059
+ };
1060
 
1061
+ /* =============== زر العودة للأعلى =============== */
1062
  const backBtn = document.getElementById('backToTop');
1063
+ window.addEventListener('scroll', () => backBtn.classList.toggle('show', window.scrollY > 400));
1064
+ backBtn.addEventListener('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }));
1065
+
1066
+ /* =============== معالج خطأ الصور =============== */
1067
+ window.handleImageError = function(img) {
1068
+ const card = img.closest('.image-card');
1069
+ if (!card) return;
1070
+ const original = img.dataset.original;
1071
+ if (original && img.src !== original) {
1072
+ img.src = original; // محاولة بالرابط الأصلي
1073
+ } else {
1074
+ card.style.display = 'none'; // إخفاء البطاقة بالكامل
1075
+ }
1076
+ };
1077
+
1078
+ /* =============== جلب البيانات =============== */
1079
+ const fetchJSON = (url) => fetch(url, { signal: AbortSignal.timeout(12000) }).then(r => r.json());
1080
 
1081
+ const fetchCategory = (cat) => {
1082
+ const url = `${SEARXNG_URL}?q=${encodeURIComponent(query)}&format=json&categories=${cat}&language=ar&safesearch=1&limit=100`;
1083
+ return fetchJSON(url).catch(() => ({ results: [] }));
1084
+ };
1085
 
1086
+ /* =============== دوال العرض =============== */
1087
  const createSectionTitle = (text, tabLink) => {
1088
  const h3 = document.createElement('h3');
1089
  h3.className = 'section-title';
 
1093
 
1094
  const renderWebResults = (results) => {
1095
  results.forEach(r => {
1096
+ const d = getDomain(r.url);
1097
  const art = document.createElement('article');
1098
  art.className = 'search-result';
1099
  art.innerHTML = `
1100
+ <div class="favicon-wrap">
1101
+ <img src="${faviconURL(d)}" onerror="this.style.display='none';this.nextElementSibling.style.display='flex'" alt="" />
1102
+ <i class="fa-solid fa-globe fallback-icon" style="display:none"></i>
1103
+ </div>
1104
  <div class="result-content">
1105
  <div class="result-domain"><i class="fa-solid fa-link"></i> ${esc(d)}</div>
1106
+ <a class="result-title" href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.title || 'بدون عنوان')}</a>
1107
+ <p class="result-snippet">${esc(r.content || 'لا يوجد وصف.')}</p>
1108
  </div>
1109
+ <button class="copy-link-btn" data-url="${esc(r.url)}" title="نسخ الرابط"><i class="fa-regular fa-copy"></i></button>
1110
  `;
1111
  resultsEl.appendChild(art);
1112
  });
1113
  };
1114
 
1115
+ const renderImageCards = (images, insertBefore = null) => {
1116
  if (!images.length) return;
1117
  const title = createSectionTitle('صور', 'images');
1118
+ if (insertBefore) {
1119
+ resultsEl.insertBefore(title, insertBefore);
1120
+ } else {
1121
+ resultsEl.appendChild(title);
1122
+ }
1123
+ const grid = document.createElement('div');
1124
+ grid.className = 'images-grid';
1125
  images.forEach(r => {
1126
  const raw = extractBestImage(r);
1127
  if (!raw) return;
1128
  const proxied = proxyImg(raw);
1129
+ const card = document.createElement('div');
1130
+ card.className = 'image-card';
1131
  card.innerHTML = `
1132
+ <a class="image-card-link" href="${esc(r.url)}" target="_blank" rel="noopener">
1133
+ <img src="${esc(proxied)}" loading="lazy" data-original="${esc(raw)}" onerror="handleImageError(this)" alt="${esc(r.title || '')}" />
 
1134
  </a>
1135
+ <div class="image-info">${esc(r.title || 'صورة')}</div>
1136
  `;
1137
  grid.appendChild(card);
1138
  });
1139
+ if (insertBefore) {
1140
+ resultsEl.insertBefore(grid, insertBefore);
 
 
 
 
 
 
1141
  } else {
1142
+ resultsEl.appendChild(grid);
 
 
 
 
1143
  }
1144
  };
1145
 
1146
+ const renderVideoCards = (videos, insertBefore = null) => {
1147
  if (!videos.length) return;
1148
  const title = createSectionTitle('فيديوهات', 'videos');
1149
+ if (insertBefore) {
1150
+ resultsEl.insertBefore(title, insertBefore);
 
 
1151
  } else {
1152
+ resultsEl.appendChild(title);
1153
  }
1154
+ const grid = document.createElement('div');
1155
+ grid.className = 'videos-grid';
1156
  videos.forEach(r => {
1157
  const thumb = proxyImg(r.thumbnail) || '';
1158
+ const card = document.createElement('div');
1159
+ card.className = 'video-card';
1160
  card.innerHTML = `
1161
+ <a href="${esc(r.url)}" target="_blank" rel="noopener" class="video-thumb-wrap">
1162
+ <img src="${thumb}" alt="${esc(r.title || '')}" />
1163
+ <div class="play-overlay"><i class="fa-solid fa-play"></i></div>
1164
  </a>
1165
  <div class="video-details">
1166
+ <a class="video-title" href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.title || 'فيديو')}</a>
1167
  </div>
1168
  `;
1169
  grid.appendChild(card);
1170
  });
1171
+ if (insertBefore) {
1172
+ resultsEl.insertBefore(grid, insertBefore);
 
1173
  } else {
1174
  resultsEl.appendChild(grid);
1175
  }
1176
  };
1177
 
1178
+ /* =============== البحث الرئيسي =============== */
1179
  const performSearch = async (q, tab) => {
1180
  resultsEl.innerHTML = '';
1181
  loadingEl.style.display = 'flex';
1182
  loadingEl.classList.add('spinning');
1183
  showAI(tab === 'all');
1184
 
 
 
 
 
 
1185
  try {
1186
  if (tab === 'all') {
1187
+ /* ---------- الخطوة 1: جلب نتائج الويب وعرضها فوراً ---------- */
1188
+ const generalData = await fetchCategory('general');
1189
  const webResults = generalData.results || [];
1190
  loadingEl.style.display = 'none';
1191
+
1192
  if (webResults.length) {
1193
  renderWebResults(webResults);
1194
+ runAI(q, webResults);
1195
  } else {
1196
+ resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد نتائج لـ "${esc(q)}"</p></div>`;
1197
  }
1198
+ observeNew();
1199
 
1200
+ /* ---------- الخطوة 2: جلب الصور وإدراجها في الأعلى ---------- */
1201
+ const imagesData = await fetchCategory('images');
1202
+ const imageResults = (imagesData.results || [])
1203
+ .filter(r => extractBestImage(r))
1204
+ .slice(0, 10);
 
 
1205
 
1206
+ if (imageResults.length) {
1207
+ // إدراج الصور قبل أول نتيجة ويب
1208
+ const firstResult = resultsEl.querySelector('.search-result');
1209
+ renderImageCards(imageResults, firstResult);
1210
+ }
1211
+
1212
+ /* ---------- الخطوة 3: جلب الفيديوهات وإدراجها بعد الصور ---------- */
1213
+ const videosData = await fetchCategory('videos');
1214
+ const videoResults = (videosData.results || [])
1215
+ .filter(r => r.url && r.url.includes('youtube.com/watch'))
1216
+ .slice(0, 6);
1217
+
1218
+ if (videoResults.length) {
1219
+ // إدراج الفيديوهات قبل أول نتيجة ويب (بعد الصور إن وجدت)
1220
+ const firstResult = resultsEl.querySelector('.search-result');
1221
+ renderVideoCards(videoResults, firstResult);
1222
+ }
1223
+
1224
+ observeNew();
1225
 
1226
  } else {
1227
+ /* ---------- باقي التبويبات ---------- */
1228
+ const cat = { news: 'news', images: 'images', videos: 'videos' }[tab] || 'general';
1229
+ const data = await fetchCategory(cat);
1230
  const results = data.results || [];
1231
  loadingEl.style.display = 'none';
1232
+
1233
+ if (!results.length) {
1234
+ resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد نتائج</p></div>`;
1235
+ return;
1236
+ }
1237
+
1238
+ if (tab === 'images') {
1239
+ const validImages = results.filter(r => extractBestImage(r));
1240
+ if (validImages.length) {
1241
+ const grid = document.createElement('div');
1242
+ grid.className = 'images-grid';
1243
+ validImages.forEach(r => {
1244
+ const raw = extractBestImage(r);
1245
+ const card = document.createElement('div');
1246
+ card.className = 'image-card';
1247
+ card.innerHTML = `
1248
+ <a class="image-card-link" href="${esc(r.url)}" target="_blank" rel="noopener">
1249
+ <img src="${esc(proxyImg(raw))}" loading="lazy" data-original="${esc(raw)}" onerror="handleImageError(this)" alt="${esc(r.title || '')}" />
1250
+ </a>
1251
+ <div class="image-info">${esc(r.title || 'صورة')}</div>
1252
+ `;
1253
+ grid.appendChild(card);
1254
+ });
1255
+ resultsEl.appendChild(grid);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1256
  } else {
1257
+ resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد صور</p></div>`;
1258
  }
1259
+ } else if (tab === 'videos') {
1260
+ const grid = document.createElement('div');
1261
+ grid.className = 'videos-grid';
1262
+ results.forEach(r => {
1263
+ const card = document.createElement('div');
1264
+ card.className = 'video-card';
1265
+ card.innerHTML = `
1266
+ <a href="${esc(r.url)}" target="_blank" rel="noopener" class="video-thumb-wrap">
1267
+ <img src="${proxyImg(r.thumbnail) || ''}" alt="${esc(r.title || '')}" />
1268
+ <div class="play-overlay"><i class="fa-solid fa-play"></i></div>
1269
+ </a>
1270
+ <div class="video-details">
1271
+ <a class="video-title" href="${esc(r.url)}" target="_blank" rel="noopener">${esc(r.title || 'فيديو')}</a>
1272
+ </div>
1273
+ `;
1274
+ grid.appendChild(card);
1275
+ });
1276
+ resultsEl.appendChild(grid);
1277
  } else {
1278
+ renderWebResults(results);
1279
  }
1280
+ observeNew();
1281
  }
1282
+ } catch (error) {
1283
  loadingEl.style.display = 'none';
1284
+ resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-triangle-exclamation"></i><p>تعذّر الاتصال. تحقق من اتصالك بالإنترنت.</p></div>`;
1285
  }
1286
  };
1287
 
1288
+ /* =============== التهيئة الأولية =============== */
1289
  if (query) {
1290
  inputEl.value = query;
1291
+ storage.set('surfgo-lastq', query);
1292
  performSearch(query, currentTab);
1293
  } else {
1294
  loadingEl.style.display = 'block';
 
1296
  loadingEl.textContent = 'أدخل كلمة البحث للبدء.';
1297
  }
1298
 
1299
+ /* =============== مستمعو الأحداث =============== */
1300
+ document.getElementById('search-form').addEventListener('submit', (e) => {
1301
  e.preventDefault();
1302
  const q = inputEl.value.trim();
1303
  if (!q) return;
1304
+ storage.set('surfgo-lastq', q);
1305
  window.history.pushState({}, '', `?q=${encodeURIComponent(q)}&tab=${currentTab}`);
1306
  query = q;
1307
  performSearch(q, currentTab);
 
1317
  if (query) performSearch(query, tab);
1318
  });
1319
  });
1320
+
1321
+ // نسخ AI
1322
+ document.getElementById('ai-copy-desktop')?.addEventListener('click', () => navigator.clipboard.writeText(currentAItext));
1323
+ document.getElementById('ai-copy-mobile')?.addEventListener('click', () => navigator.clipboard.writeText(currentAItext));
1324
+
1325
  })();
1326
  </script>
1327
  </body>