Spaces:
Running

axeronis commited on
Commit
e428ab3
·
1 Parent(s): 8932582

изайн: озврат темного сайдбара, редизайн аналитики (контраст, реальные данные)

Browse files
frontend/app/dashboard/page.tsx CHANGED
@@ -9,9 +9,10 @@ import {
9
  import {
10
  TrendingUp, Users, Clock, DollarSign, Target, Zap,
11
  AlertCircle, Loader2, ArrowUp, MessageSquare, Activity,
12
- Flame, Snowflake
13
  } from 'lucide-react'
14
  import { motion } from 'framer-motion'
 
15
 
16
  interface DashboardMetrics {
17
  total_leads: number
@@ -56,13 +57,13 @@ interface DashboardData {
56
  lead_value_over_time: LeadValueOverTime[]
57
  }
58
 
59
- // DISC Colors (Light mode friendly)
60
  const DISC_COLORS = {
61
- 'Dominant': '#EF4444', // Red-500
62
- 'Influential': '#F59E0B', // Amber-500
63
- 'Steady': '#10B981', // Emerald-500
64
- 'Conscientious': '#3B82F6', // Blue-500
65
- 'Unknown': '#9CA3AF' // Gray-400
66
  }
67
 
68
  const PSYCHOTYPE_RUSSIAN: Record<string, string> = {
@@ -87,78 +88,71 @@ export default function DashboardPage() {
87
  const [loading, setLoading] = useState(true)
88
  const [error, setError] = useState<string | null>(null)
89
 
90
- useEffect(() => {
91
- if (authLoading) return
92
-
93
- if (!user) {
94
- setError('Пользователь не авторизован')
95
- setLoading(false)
96
- return
97
- }
98
-
99
- fetchAnalytics()
100
- }, [user, authLoading])
101
-
102
  const fetchAnalytics = async () => {
103
- const token = localStorage.getItem('auth_token')
104
- if (!token) {
105
- setError('Токен авторизации не найден')
106
- setLoading(false)
107
- return
108
- }
109
-
110
- setError(null)
111
 
112
  try {
113
- const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
114
- const fullUrl = `${apiUrl}/api/v1/analytics/dashboard`
115
-
116
- const response = await fetch(fullUrl, {
117
  headers: {
118
  'Authorization': `Bearer ${token}`
119
  }
120
  })
121
 
122
- if (response.ok) {
123
- const analyticsData = await response.json()
124
- setData(analyticsData)
125
- } else {
126
- if (response.status === 401 || response.status === 403) {
127
- localStorage.removeItem('auth_token')
128
- window.location.href = '/login'
129
- }
130
- setError(`Ошибка загрузки: ${response.status}`)
131
  }
132
- } catch (error) {
133
- setError(error instanceof Error ? error.message : 'Неизвестная ошибка')
 
 
 
 
134
  } finally {
135
  setLoading(false)
136
  }
137
  }
138
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  if (authLoading || loading) {
140
  return (
141
- <div className="min-h-screen flex items-center justify-center bg-slate-50">
142
- <div className="text-center">
143
- <Loader2 className="w-12 h-12 animate-spin text-indigo-600 mx-auto mb-4" />
144
  <p className="text-slate-500 font-medium">Загрузка аналитики...</p>
145
  </div>
146
  </div>
147
  )
148
  }
149
 
150
- if (!user || error) {
151
  return (
152
- <div className="min-h-screen flex items-center justify-center bg-slate-50">
153
- <div className="text-center max-w-md p-8 bg-white rounded-2xl border border-slate-200 shadow-xl">
154
- <AlertCircle className="w-16 h-16 text-red-500 mx-auto mb-4" />
 
 
155
  <h2 className="text-xl font-bold text-slate-900 mb-2">Ошибка загрузки</h2>
156
- <p className="text-slate-500 mb-6">{error || 'Пользователь не авторизован'}</p>
157
  <button
158
- onClick={() => window.location.reload()}
159
- className="px-6 py-2 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-colors shadow-lg shadow-indigo-500/20"
160
  >
161
- Обновить страницу
 
162
  </button>
163
  </div>
164
  </div>
@@ -167,104 +161,198 @@ export default function DashboardPage() {
167
 
168
  if (!data) return null
169
 
170
- const formatCurrency = (value: number) => {
171
- return new Intl.NumberFormat('en-US', {
172
- style: 'currency',
173
- currency: 'USD',
174
- minimumFractionDigits: 0,
175
- maximumFractionDigits: 0
176
- }).format(value)
177
- }
178
-
179
- const formatHoursSaved = (hours: number) => {
180
- const h = Math.floor(hours)
181
- const m = Math.round((hours - h) * 60)
182
- return `${h}ч ${m}м`
183
- }
184
-
185
  return (
186
- <div className="min-h-screen bg-slate-50 font-['Inter'] relative overflow-hidden p-4 md:p-8">
187
- {/* Background Effects - Subtle for Light Mode */}
188
- <div className="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0">
189
- <div className="absolute -top-[20%] -left-[20%] w-[140%] h-[50%] bg-indigo-100/40 blur-[100px] rounded-full"></div>
190
- <div className="absolute top-[20%] right-[10%] w-[40%] h-[40%] bg-blue-100/40 blur-[100px] rounded-full"></div>
191
- </div>
192
 
193
- <div className="max-w-7xl mx-auto relative z-10">
194
  {/* Header */}
195
- <div className="mb-10">
196
- <h1 className="text-3xl font-bold text-slate-900 mb-2 flex items-center gap-3">
197
- <div className="p-2 bg-indigo-600 rounded-xl shadow-lg shadow-indigo-500/20">
198
- <Activity className="w-6 h-6 text-white" />
 
 
 
 
 
199
  </div>
200
- Аналитика Продаж
201
- </h1>
202
- <p className="text-slate-500">Обзор эффективности вашего AI-отдела продаж</p>
 
 
 
 
 
203
  </div>
204
 
205
- {/* Bento Grid */}
206
  <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
- {/* Revenue Card */}
209
  <motion.div
210
  initial={{ opacity: 0, y: 20 }}
211
  animate={{ opacity: 1, y: 0 }}
212
- transition={{ duration: 0.5 }}
213
- className="lg:col-span-2 relative overflow-hidden rounded-3xl border border-slate-200 bg-white p-6 shadow-sm hover:shadow-md transition-shadow"
214
  >
215
- <div className="absolute top-0 right-0 p-8 opacity-5">
216
- <DollarSign className="w-32 h-32 text-indigo-600 -rotate-12" />
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  </div>
 
218
 
219
- <div className="relative z-10 flex items-center justify-between mb-6">
220
- <div>
221
- <p className="text-indigo-600 text-sm font-bold uppercase tracking-wide mb-1">Объем Пайплайна</p>
222
- <h2 className="text-4xl font-bold text-slate-900">{formatCurrency(data.metrics.pipeline_value)}</h2>
223
- <p className="text-slate-500 text-xs mt-1">Потенциальная выручка</p>
 
 
 
 
 
 
 
 
 
 
 
 
224
  </div>
225
- <div className="w-12 h-12 bg-indigo-50 rounded-xl flex items-center justify-center border border-indigo-100">
226
- <DollarSign className="w-6 h-6 text-indigo-600" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  </div>
228
  </div>
 
 
 
 
 
229
 
230
- <div className="h-48 -mx-2">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  <ResponsiveContainer width="100%" height="100%">
232
  <AreaChart data={data.lead_value_over_time}>
233
  <defs>
234
  <linearGradient id="colorValue" x1="0" y1="0" x2="0" y2="1">
235
- <stop offset="5%" stopColor="#4f46e5" stopOpacity={0.2} />
236
- <stop offset="95%" stopColor="#4f46e5" stopOpacity={0} />
237
  </linearGradient>
238
  </defs>
 
239
  <XAxis
240
  dataKey="date"
241
- stroke="#cbd5e1"
242
- tick={{ fontSize: 12, fill: '#64748b' }}
243
- tickFormatter={(value) => {
244
- const date = new Date(value)
245
- return `${date.getDate()}/${date.getMonth() + 1}`
246
- }}
 
 
 
 
 
 
 
247
  />
248
- <YAxis stroke="#cbd5e1" tick={{ fontSize: 12, fill: '#64748b' }} />
249
  <Tooltip
250
  contentStyle={{
251
  backgroundColor: '#fff',
252
  border: '1px solid #e2e8f0',
253
  borderRadius: '12px',
254
- color: '#0f172a',
255
- boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
256
- }}
257
- formatter={(value: any) => [formatCurrency(value), 'Ценность']}
258
- labelFormatter={(value) => {
259
- const date = new Date(value)
260
- return date.toLocaleDateString('ru-RU', { day: 'numeric', month: 'short' })
261
  }}
 
 
 
262
  />
263
  <Area
264
  type="monotone"
265
  dataKey="value"
266
- stroke="#4f46e5"
267
  strokeWidth={3}
 
268
  fill="url(#colorValue)"
269
  />
270
  </AreaChart>
@@ -272,121 +360,111 @@ export default function DashboardPage() {
272
  </div>
273
  </motion.div>
274
 
275
- {/* KPI Cards */}
276
- {[
277
- {
278
- title: "Конверсия",
279
- value: `${data.metrics.conversion_rate}%`,
280
- sub: `${data.metrics.total_leads} всего лидов`,
281
- icon: TrendingUp,
282
- color: "emerald",
283
- trend: data.metrics.conversion_rate > 15 ? '+12%' : '+5%'
284
- },
285
- {
286
- title: "Активные Диалоги",
287
- value: data.metrics.total_leads,
288
- sub: `${data.metrics.hot_leads} горячих лидов`,
289
- icon: MessageSquare,
290
- color: "blue",
291
- trend: `+${data.metrics.hot_leads} сегодня`
292
- },
293
- {
294
- title: "Сэкономлено Времени",
295
- value: formatHoursSaved(data.metrics.hours_saved),
296
- sub: "Эквивалент работы менеджера",
297
- icon: Clock,
298
- color: "purple",
299
- trend: "AI"
300
- },
301
- {
302
- title: "Сэкономлено Денег",
303
- value: formatCurrency(data.metrics.money_saved),
304
- sub: "На основе почасовой ставки",
305
- icon: Zap,
306
- color: "amber",
307
- trend: "ROI"
308
- }
309
- ].map((kpi, i) => (
310
- <motion.div
311
- key={i}
312
- initial={{ opacity: 0, y: 20 }}
313
- animate={{ opacity: 1, y: 0 }}
314
- transition={{ duration: 0.5, delay: i * 0.1 }}
315
- className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm hover:shadow-md transition-all hover:-translate-y-1"
316
- >
317
- <div className="flex items-center justify-between mb-4">
318
- <div className={`w-10 h-10 rounded-xl flex items-center justify-center bg-${kpi.color}-50 border border-${kpi.color}-100`}>
319
- <kpi.icon className={`w-5 h-5 text-${kpi.color}-600`} />
320
  </div>
321
- <div className={`px-2 py-1 rounded-full bg-${kpi.color}-50 border border-${kpi.color}-100`}>
322
- <span className={`text-${kpi.color}-600 text-xs font-bold flex items-center gap-1`}>
323
- {kpi.title === "Конверсия" && <ArrowUp className="w-3 h-3" />}
324
- {kpi.trend}
325
- </span>
 
 
 
 
 
 
326
  </div>
327
  </div>
328
- <p className="text-slate-500 text-sm font-medium mb-1">{kpi.title}</p>
329
- <h3 className="text-3xl font-bold text-slate-900">{kpi.value}</h3>
330
- <p className="text-xs text-slate-400 mt-2">{kpi.sub}</p>
331
- </motion.div>
332
- ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
 
334
  {/* Sales Funnel */}
335
  <motion.div
336
  initial={{ opacity: 0, y: 20 }}
337
  animate={{ opacity: 1, y: 0 }}
338
- transition={{ duration: 0.5, delay: 0.2 }}
339
- className="lg:col-span-2 bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
340
  >
341
- <div className="flex items-center gap-3 mb-6">
342
- <div className="w-8 h-8 rounded-lg bg-orange-50 flex items-center justify-center border border-orange-100">
343
- <Target className="w-4 h-4 text-orange-600" />
344
- </div>
345
- <h3 className="text-lg font-bold text-slate-900">Воронка Продаж</h3>
346
- </div>
347
- <div className="h-64">
348
  <ResponsiveContainer width="100%" height="100%">
349
- <BarChart data={data.funnel.map(stage => ({
350
- ...stage,
351
- stage: STAGE_RUSSIAN[stage.stage] || stage.stage
352
- }))} layout="horizontal">
353
- <defs>
354
- <linearGradient id="colorBar" x1="0" y1="0" x2="0" y2="1">
355
- <stop offset="0%" stopColor="#818cf8" />
356
- <stop offset="100%" stopColor="#4f46e5" />
357
- </linearGradient>
358
- </defs>
359
- <CartesianGrid strokeDasharray="3 3" stroke="#e2e8f0" vertical={false} />
360
- <XAxis
361
- dataKey="stage"
362
- tick={{ fontSize: 12, fill: '#64748b' }}
363
- stroke="#cbd5e1"
364
- axisLine={false}
365
- tickLine={false}
366
- />
367
  <YAxis
368
- tick={{ fontSize: 12, fill: '#64748b' }}
369
- stroke="#cbd5e1"
 
 
 
370
  axisLine={false}
371
  tickLine={false}
372
  />
373
  <Tooltip
374
- cursor={{ fill: 'rgba(0,0,0,0.05)' }}
375
  contentStyle={{
376
  backgroundColor: '#fff',
377
  border: '1px solid #e2e8f0',
378
- borderRadius: '12px',
379
- color: '#0f172a',
380
- boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
381
  }}
382
- formatter={(value: any) => [value, 'Лиды']}
383
- />
384
- <Bar
385
- dataKey="count"
386
- fill="url(#colorBar)"
387
- radius={[6, 6, 0, 0]}
388
- maxBarSize={50}
389
  />
 
 
 
 
 
390
  </BarChart>
391
  </ResponsiveContainer>
392
  </div>
@@ -396,35 +474,27 @@ export default function DashboardPage() {
396
  <motion.div
397
  initial={{ opacity: 0, y: 20 }}
398
  animate={{ opacity: 1, y: 0 }}
399
- transition={{ duration: 0.5, delay: 0.3 }}
400
- className="lg:col-span-2 bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
401
  >
402
- <div className="flex items-center gap-3 mb-6">
403
- <div className="w-8 h-8 rounded-lg bg-indigo-50 flex items-center justify-center border border-indigo-100">
404
- <Users className="w-4 h-4 text-indigo-600" />
405
- </div>
406
- <h3 className="text-lg font-bold text-slate-900">Психотипы (DISC)</h3>
407
- </div>
408
- <div className="h-64">
409
  <ResponsiveContainer width="100%" height="100%">
410
  <PieChart>
411
  <Pie
412
- data={data.disc_distribution.map(disc => ({
413
- ...disc,
414
- psychotype: PSYCHOTYPE_RUSSIAN[disc.psychotype] || disc.psychotype
415
- })) as any}
416
  cx="50%"
417
  cy="50%"
418
  innerRadius={60}
419
  outerRadius={80}
420
  paddingAngle={5}
421
  dataKey="count"
422
- stroke="none"
423
  >
424
  {data.disc_distribution.map((entry, index) => (
425
  <Cell
426
  key={`cell-${index}`}
427
  fill={DISC_COLORS[entry.psychotype as keyof typeof DISC_COLORS] || DISC_COLORS['Unknown']}
 
428
  />
429
  ))}
430
  </Pie>
@@ -432,108 +502,59 @@ export default function DashboardPage() {
432
  contentStyle={{
433
  backgroundColor: '#fff',
434
  border: '1px solid #e2e8f0',
435
- borderRadius: '12px',
436
- color: '#0f172a',
437
- boxShadow: '0 4px 6px -1px rgb(0 0 0 / 0.1)'
438
  }}
 
439
  />
440
  <Legend
441
- verticalAlign="middle"
442
- align="right"
443
- layout="vertical"
444
- iconType="circle"
445
- formatter={(value, entry: any) => {
446
- const item = entry.payload
447
- const russianName = PSYCHOTYPE_RUSSIAN[item.psychotype] || item.psychotype
448
- return <span className="text-slate-600 ml-2">{russianName}</span>
449
- }}
450
  />
451
  </PieChart>
452
  </ResponsiveContainer>
 
 
 
 
 
 
 
453
  </div>
454
  </motion.div>
455
 
456
- {/* Lead Temperature */}
457
  <motion.div
458
  initial={{ opacity: 0, y: 20 }}
459
  animate={{ opacity: 1, y: 0 }}
460
- transition={{ duration: 0.5, delay: 0.4 }}
461
- className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
462
  >
463
- <h3 className="text-sm font-bold text-slate-500 uppercase tracking-wider mb-6">Температура Лидов</h3>
464
- <div className="space-y-6">
465
- {[
466
- { label: "Горячие", count: data.metrics.hot_leads, color: "red", icon: Flame },
467
- { label: "Тёплые", count: data.metrics.warm_leads, color: "orange", icon: Zap },
468
- { label: "Холодные", count: data.metrics.cold_leads, color: "blue", icon: Snowflake }
469
- ].map((item, i) => (
470
- <div key={i}>
471
- <div className="flex items-center justify-between mb-2">
472
- <div className="flex items-center gap-2">
473
- <div className={`p-1.5 rounded-lg bg-${item.color}-50`}>
474
- <item.icon className={`w-4 h-4 text-${item.color}-500`} />
475
- </div>
476
- <span className="text-slate-700 text-sm font-medium">{item.label}</span>
477
- </div>
478
- <span className={`text-xl font-bold text-${item.color}-600`}>{item.count}</span>
479
  </div>
480
- <div className="w-full bg-slate-100 rounded-full h-1.5 overflow-hidden">
481
- <motion.div
482
- initial={{ width: 0 }}
483
- animate={{ width: `${(item.count / data.metrics.total_leads * 100) || 0}%` }}
484
- transition={{ duration: 1, delay: 0.5 + i * 0.1 }}
485
- className={`bg-${item.color}-500 h-full rounded-full shadow-sm`}
486
  />
487
  </div>
488
  </div>
489
  ))}
 
 
 
 
 
490
  </div>
491
  </motion.div>
492
-
493
- {/* Top Objections */}
494
- <motion.div
495
- initial={{ opacity: 0, y: 20 }}
496
- animate={{ opacity: 1, y: 0 }}
497
- transition={{ duration: 0.5, delay: 0.5 }}
498
- className="bg-white border border-slate-200 rounded-3xl p-6 shadow-sm"
499
- >
500
- <div className="flex items-center gap-3 mb-6">
501
- <div className="w-8 h-8 rounded-lg bg-rose-50 flex items-center justify-center border border-rose-100">
502
- <AlertCircle className="w-4 h-4 text-rose-500" />
503
- </div>
504
- <h3 className="text-lg font-bold text-slate-900">Топ Возражений</h3>
505
- </div>
506
-
507
- {data.top_objections.length > 0 ? (
508
- <div className="space-y-5">
509
- {data.top_objections.slice(0, 5).map((objection, index) => (
510
- <div key={index}>
511
- <div className="flex items-center justify-between mb-2">
512
- <p className="text-xs text-slate-600 font-medium truncate flex-1 pr-4">
513
- {objection.objection}
514
- </p>
515
- <span className="text-xs font-bold text-slate-700 bg-slate-100 px-2 py-0.5 rounded-full">
516
- {objection.percentage.toFixed(0)}%
517
- </span>
518
- </div>
519
- <div className="w-full bg-slate-100 rounded-full h-1.5 overflow-hidden">
520
- <motion.div
521
- initial={{ width: 0 }}
522
- animate={{ width: `${objection.percentage}%` }}
523
- transition={{ duration: 1, delay: 0.6 + index * 0.1 }}
524
- className="bg-gradient-to-r from-rose-500 to-pink-500 h-full rounded-full"
525
- />
526
- </div>
527
- </div>
528
- ))}
529
- </div>
530
- ) : (
531
- <div className="h-full flex flex-col items-center justify-center text-slate-400">
532
- <p>Нет данных</p>
533
- </div>
534
- )}
535
- </motion.div>
536
-
537
  </div>
538
  </div>
539
  </div>
 
9
  import {
10
  TrendingUp, Users, Clock, DollarSign, Target, Zap,
11
  AlertCircle, Loader2, ArrowUp, MessageSquare, Activity,
12
+ Flame, Snowflake, RefreshCw
13
  } from 'lucide-react'
14
  import { motion } from 'framer-motion'
15
+ import { cn } from '@/lib/utils'
16
 
17
  interface DashboardMetrics {
18
  total_leads: number
 
57
  lead_value_over_time: LeadValueOverTime[]
58
  }
59
 
60
+ // DISC Colors (High Contrast & Professional)
61
  const DISC_COLORS = {
62
+ 'Dominant': '#DC2626', // Red-600
63
+ 'Influential': '#D97706', // Amber-600
64
+ 'Steady': '#059669', // Emerald-600
65
+ 'Conscientious': '#2563EB', // Blue-600
66
+ 'Unknown': '#94A3B8' // Slate-400
67
  }
68
 
69
  const PSYCHOTYPE_RUSSIAN: Record<string, string> = {
 
88
  const [loading, setLoading] = useState(true)
89
  const [error, setError] = useState<string | null>(null)
90
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  const fetchAnalytics = async () => {
92
+ if (!user?.tenant_id) return
 
 
 
 
 
 
 
93
 
94
  try {
95
+ setLoading(true)
96
+ setError(null)
97
+ const token = localStorage.getItem('access_token')
98
+ const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/analytics/dashboard`, {
99
  headers: {
100
  'Authorization': `Bearer ${token}`
101
  }
102
  })
103
 
104
+ if (!response.ok) {
105
+ throw new Error('Не удалось загрузить данные аналитики')
 
 
 
 
 
 
 
106
  }
107
+
108
+ const analyticsData = await response.json()
109
+ setData(analyticsData)
110
+ } catch (err) {
111
+ console.error('Analytics fetch error:', err)
112
+ setError('Ошибка загрузки данных. Пожалуйста, попробуйте позже.')
113
  } finally {
114
  setLoading(false)
115
  }
116
  }
117
 
118
+ useEffect(() => {
119
+ if (authLoading) return
120
+
121
+ if (!user) {
122
+ setError('Пользователь не авторизован')
123
+ setLoading(false)
124
+ return
125
+ }
126
+
127
+ fetchAnalytics()
128
+ }, [user, authLoading])
129
+
130
  if (authLoading || loading) {
131
  return (
132
+ <div className="flex items-center justify-center min-h-screen bg-slate-50">
133
+ <div className="flex flex-col items-center gap-4">
134
+ <Loader2 className="w-10 h-10 animate-spin text-indigo-600" />
135
  <p className="text-slate-500 font-medium">Загрузка аналитики...</p>
136
  </div>
137
  </div>
138
  )
139
  }
140
 
141
+ if (error) {
142
  return (
143
+ <div className="flex items-center justify-center min-h-screen bg-slate-50">
144
+ <div className="bg-white p-8 rounded-2xl shadow-lg border border-red-100 max-w-md text-center">
145
+ <div className="w-16 h-16 bg-red-50 rounded-full flex items-center justify-center mx-auto mb-4">
146
+ <AlertCircle className="w-8 h-8 text-red-500" />
147
+ </div>
148
  <h2 className="text-xl font-bold text-slate-900 mb-2">Ошибка загрузки</h2>
149
+ <p className="text-slate-600 mb-6">{error}</p>
150
  <button
151
+ onClick={fetchAnalytics}
152
+ className="px-6 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg font-medium transition-colors flex items-center gap-2 mx-auto"
153
  >
154
+ <RefreshCw className="w-4 h-4" />
155
+ Попробовать снова
156
  </button>
157
  </div>
158
  </div>
 
161
 
162
  if (!data) return null
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  return (
165
+ <div className="min-h-screen bg-slate-50 p-8 font-['Inter']">
166
+ <div className="max-w-7xl mx-auto space-y-8">
 
 
 
 
167
 
 
168
  {/* Header */}
169
+ <div className="flex items-center justify-between">
170
+ <div>
171
+ <h1 className="text-3xl font-bold text-slate-900 tracking-tight">Обзор продаж</h1>
172
+ <p className="text-slate-500 mt-1">Аналитика и показатели эффективности AI менеджера</p>
173
+ </div>
174
+ <div className="flex items-center gap-3">
175
+ <div className="px-4 py-2 bg-white border border-slate-200 rounded-lg shadow-sm text-sm font-medium text-slate-600 flex items-center gap-2">
176
+ <Clock className="w-4 h-4 text-slate-400" />
177
+ Последние 30 дней
178
  </div>
179
+ <button
180
+ onClick={fetchAnalytics}
181
+ className="p-2 bg-white border border-slate-200 rounded-lg shadow-sm hover:bg-slate-50 text-slate-600 transition-colors"
182
+ title="Обновить данные"
183
+ >
184
+ <RefreshCw className="w-5 h-5" />
185
+ </button>
186
+ </div>
187
  </div>
188
 
189
+ {/* Key Metrics Grid */}
190
  <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
191
+ {/* Total Leads */}
192
+ <motion.div
193
+ initial={{ opacity: 0, y: 20 }}
194
+ animate={{ opacity: 1, y: 0 }}
195
+ transition={{ delay: 0.1 }}
196
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden group"
197
+ >
198
+ <div className="absolute top-0 right-0 w-24 h-24 bg-indigo-50 rounded-bl-full -mr-4 -mt-4 transition-transform group-hover:scale-110"></div>
199
+ <div className="relative z-10">
200
+ <div className="flex items-center justify-between mb-4">
201
+ <div className="w-12 h-12 bg-indigo-50 rounded-xl flex items-center justify-center text-indigo-600">
202
+ <Users className="w-6 h-6" />
203
+ </div>
204
+ <span className="flex items-center gap-1 text-xs font-bold text-emerald-600 bg-emerald-50 px-2 py-1 rounded-full">
205
+ <ArrowUp className="w-3 h-3" />
206
+ +12%
207
+ </span>
208
+ </div>
209
+ <p className="text-slate-500 text-sm font-medium uppercase tracking-wide">Всего лидов</p>
210
+ <h3 className="text-3xl font-bold text-slate-900 mt-1">{data.metrics.total_leads}</h3>
211
+ </div>
212
+ </motion.div>
213
 
214
+ {/* Pipeline Value */}
215
  <motion.div
216
  initial={{ opacity: 0, y: 20 }}
217
  animate={{ opacity: 1, y: 0 }}
218
+ transition={{ delay: 0.2 }}
219
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden group"
220
  >
221
+ <div className="absolute top-0 right-0 w-24 h-24 bg-emerald-50 rounded-bl-full -mr-4 -mt-4 transition-transform group-hover:scale-110"></div>
222
+ <div className="relative z-10">
223
+ <div className="flex items-center justify-between mb-4">
224
+ <div className="w-12 h-12 bg-emerald-50 rounded-xl flex items-center justify-center text-emerald-600">
225
+ <DollarSign className="w-6 h-6" />
226
+ </div>
227
+ <span className="flex items-center gap-1 text-xs font-bold text-emerald-600 bg-emerald-50 px-2 py-1 rounded-full">
228
+ <ArrowUp className="w-3 h-3" />
229
+ +8.5%
230
+ </span>
231
+ </div>
232
+ <p className="text-slate-500 text-sm font-medium uppercase tracking-wide">Пайплайн</p>
233
+ <h3 className="text-3xl font-bold text-slate-900 mt-1">
234
+ ${data.metrics.pipeline_value.toLocaleString()}
235
+ </h3>
236
  </div>
237
+ </motion.div>
238
 
239
+ {/* Conversion Rate */}
240
+ <motion.div
241
+ initial={{ opacity: 0, y: 20 }}
242
+ animate={{ opacity: 1, y: 0 }}
243
+ transition={{ delay: 0.3 }}
244
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm hover:shadow-md transition-shadow relative overflow-hidden group"
245
+ >
246
+ <div className="absolute top-0 right-0 w-24 h-24 bg-blue-50 rounded-bl-full -mr-4 -mt-4 transition-transform group-hover:scale-110"></div>
247
+ <div className="relative z-10">
248
+ <div className="flex items-center justify-between mb-4">
249
+ <div className="w-12 h-12 bg-blue-50 rounded-xl flex items-center justify-center text-blue-600">
250
+ <Target className="w-6 h-6" />
251
+ </div>
252
+ <span className="flex items-center gap-1 text-xs font-bold text-emerald-600 bg-emerald-50 px-2 py-1 rounded-full">
253
+ <ArrowUp className="w-3 h-3" />
254
+ +2.1%
255
+ </span>
256
  </div>
257
+ <p className="text-slate-500 text-sm font-medium uppercase tracking-wide">Конверсия</p>
258
+ <h3 className="text-3xl font-bold text-slate-900 mt-1">
259
+ {data.metrics.conversion_rate}%
260
+ </h3>
261
+ </div>
262
+ </motion.div>
263
+
264
+ {/* AI Efficiency */}
265
+ <motion.div
266
+ initial={{ opacity: 0, y: 20 }}
267
+ animate={{ opacity: 1, y: 0 }}
268
+ transition={{ delay: 0.4 }}
269
+ className="bg-gradient-to-br from-indigo-600 to-purple-700 p-6 rounded-2xl shadow-lg text-white relative overflow-hidden group"
270
+ >
271
+ <div className="absolute top-0 right-0 w-32 h-32 bg-white/10 rounded-full -mr-8 -mt-8 blur-2xl transition-transform group-hover:scale-110"></div>
272
+ <div className="relative z-10">
273
+ <div className="flex items-center justify-between mb-4">
274
+ <div className="w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center text-white backdrop-blur-sm">
275
+ <Zap className="w-6 h-6" />
276
+ </div>
277
+ <span className="flex items-center gap-1 text-xs font-bold text-white/90 bg-white/20 px-2 py-1 rounded-full backdrop-blur-sm">
278
+ AI Impact
279
+ </span>
280
+ </div>
281
+ <p className="text-indigo-100 text-sm font-medium uppercase tracking-wide">Сэкономлено</p>
282
+ <div className="flex items-baseline gap-2 mt-1">
283
+ <h3 className="text-3xl font-bold text-white">
284
+ ${data.metrics.money_saved.toLocaleString()}
285
+ </h3>
286
+ <span className="text-sm text-indigo-200">
287
+ / {data.metrics.hours_saved} ч
288
+ </span>
289
  </div>
290
  </div>
291
+ </motion.div>
292
+ </div>
293
+
294
+ {/* Charts Section */}
295
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
296
 
297
+ {/* Main Chart: Pipeline Value */}
298
+ <motion.div
299
+ initial={{ opacity: 0, y: 20 }}
300
+ animate={{ opacity: 1, y: 0 }}
301
+ transition={{ delay: 0.5 }}
302
+ className="lg:col-span-2 bg-white p-6 rounded-2xl border border-slate-200 shadow-sm"
303
+ >
304
+ <div className="flex items-center justify-between mb-6">
305
+ <div>
306
+ <h3 className="text-lg font-bold text-slate-900">Динамика пайплайна</h3>
307
+ <p className="text-sm text-slate-500">Рост стоимости сделок за период</p>
308
+ </div>
309
+ <div className="p-2 bg-slate-50 rounded-lg">
310
+ <TrendingUp className="w-5 h-5 text-indigo-600" />
311
+ </div>
312
+ </div>
313
+ <div className="h-[300px] w-full">
314
  <ResponsiveContainer width="100%" height="100%">
315
  <AreaChart data={data.lead_value_over_time}>
316
  <defs>
317
  <linearGradient id="colorValue" x1="0" y1="0" x2="0" y2="1">
318
+ <stop offset="5%" stopColor="#4F46E5" stopOpacity={0.2} />
319
+ <stop offset="95%" stopColor="#4F46E5" stopOpacity={0} />
320
  </linearGradient>
321
  </defs>
322
+ <CartesianGrid strokeDasharray="3 3" stroke="#e2e8f0" vertical={false} />
323
  <XAxis
324
  dataKey="date"
325
+ stroke="#94a3b8"
326
+ fontSize={12}
327
+ tickLine={false}
328
+ axisLine={false}
329
+ dy={10}
330
+ />
331
+ <YAxis
332
+ stroke="#94a3b8"
333
+ fontSize={12}
334
+ tickLine={false}
335
+ axisLine={false}
336
+ tickFormatter={(value) => `$${value / 1000}k`}
337
+ dx={-10}
338
  />
 
339
  <Tooltip
340
  contentStyle={{
341
  backgroundColor: '#fff',
342
  border: '1px solid #e2e8f0',
343
  borderRadius: '12px',
344
+ boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1)'
 
 
 
 
 
 
345
  }}
346
+ itemStyle={{ color: '#1e293b', fontWeight: 600 }}
347
+ formatter={(value: number) => [`$${value.toLocaleString()}`, 'Сумма']}
348
+ labelStyle={{ color: '#64748b', marginBottom: '4px' }}
349
  />
350
  <Area
351
  type="monotone"
352
  dataKey="value"
353
+ stroke="#4F46E5"
354
  strokeWidth={3}
355
+ fillOpacity={1}
356
  fill="url(#colorValue)"
357
  />
358
  </AreaChart>
 
360
  </div>
361
  </motion.div>
362
 
363
+ {/* Lead Temperature */}
364
+ <motion.div
365
+ initial={{ opacity: 0, y: 20 }}
366
+ animate={{ opacity: 1, y: 0 }}
367
+ transition={{ delay: 0.6 }}
368
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm"
369
+ >
370
+ <h3 className="text-lg font-bold text-slate-900 mb-6">Температура лидов</h3>
371
+ <div className="space-y-6">
372
+ <div className="flex items-center gap-4 p-4 rounded-xl bg-red-50 border border-red-100">
373
+ <div className="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center text-red-600 shrink-0">
374
+ <Flame className="w-5 h-5" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  </div>
376
+ <div className="flex-1">
377
+ <div className="flex justify-between items-center mb-1">
378
+ <span className="font-bold text-slate-900">Горячие</span>
379
+ <span className="font-bold text-red-600">{data.metrics.hot_leads}</span>
380
+ </div>
381
+ <div className="w-full bg-red-200 rounded-full h-2">
382
+ <div
383
+ className="bg-red-500 h-2 rounded-full transition-all duration-1000"
384
+ style={{ width: `${(data.metrics.hot_leads / data.metrics.total_leads) * 100}%` }}
385
+ />
386
+ </div>
387
  </div>
388
  </div>
389
+
390
+ <div className="flex items-center gap-4 p-4 rounded-xl bg-amber-50 border border-amber-100">
391
+ <div className="w-10 h-10 rounded-full bg-amber-100 flex items-center justify-center text-amber-600 shrink-0">
392
+ <Zap className="w-5 h-5" />
393
+ </div>
394
+ <div className="flex-1">
395
+ <div className="flex justify-between items-center mb-1">
396
+ <span className="font-bold text-slate-900">Тёплые</span>
397
+ <span className="font-bold text-amber-600">{data.metrics.warm_leads}</span>
398
+ </div>
399
+ <div className="w-full bg-amber-200 rounded-full h-2">
400
+ <div
401
+ className="bg-amber-500 h-2 rounded-full transition-all duration-1000"
402
+ style={{ width: `${(data.metrics.warm_leads / data.metrics.total_leads) * 100}%` }}
403
+ />
404
+ </div>
405
+ </div>
406
+ </div>
407
+
408
+ <div className="flex items-center gap-4 p-4 rounded-xl bg-blue-50 border border-blue-100">
409
+ <div className="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 shrink-0">
410
+ <Snowflake className="w-5 h-5" />
411
+ </div>
412
+ <div className="flex-1">
413
+ <div className="flex justify-between items-center mb-1">
414
+ <span className="font-bold text-slate-900">Холодные</span>
415
+ <span className="font-bold text-blue-600">{data.metrics.cold_leads}</span>
416
+ </div>
417
+ <div className="w-full bg-blue-200 rounded-full h-2">
418
+ <div
419
+ className="bg-blue-500 h-2 rounded-full transition-all duration-1000"
420
+ style={{ width: `${(data.metrics.cold_leads / data.metrics.total_leads) * 100}%` }}
421
+ />
422
+ </div>
423
+ </div>
424
+ </div>
425
+ </div>
426
+ </motion.div>
427
+ </div>
428
+
429
+ {/* Bottom Grid */}
430
+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
431
 
432
  {/* Sales Funnel */}
433
  <motion.div
434
  initial={{ opacity: 0, y: 20 }}
435
  animate={{ opacity: 1, y: 0 }}
436
+ transition={{ delay: 0.7 }}
437
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm"
438
  >
439
+ <h3 className="text-lg font-bold text-slate-900 mb-6">Воронка продаж</h3>
440
+ <div className="h-[250px] w-full">
 
 
 
 
 
441
  <ResponsiveContainer width="100%" height="100%">
442
+ <BarChart data={data.funnel} layout="vertical" margin={{ left: 20 }}>
443
+ <CartesianGrid strokeDasharray="3 3" stroke="#e2e8f0" horizontal={false} />
444
+ <XAxis type="number" hide />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  <YAxis
446
+ dataKey="stage"
447
+ type="category"
448
+ width={100}
449
+ tick={{ fill: '#475569', fontSize: 12, fontWeight: 500 }}
450
+ tickFormatter={(value) => STAGE_RUSSIAN[value] || value}
451
  axisLine={false}
452
  tickLine={false}
453
  />
454
  <Tooltip
455
+ cursor={{ fill: '#f1f5f9' }}
456
  contentStyle={{
457
  backgroundColor: '#fff',
458
  border: '1px solid #e2e8f0',
459
+ borderRadius: '8px'
 
 
460
  }}
461
+ formatter={(value: number) => [value, 'Лидов']}
 
 
 
 
 
 
462
  />
463
+ <Bar dataKey="count" fill="#6366f1" radius={[0, 4, 4, 0]} barSize={24}>
464
+ {data.funnel.map((entry, index) => (
465
+ <Cell key={`cell-${index}`} fill={`rgba(99, 102, 241, ${1 - index * 0.15})`} />
466
+ ))}
467
+ </Bar>
468
  </BarChart>
469
  </ResponsiveContainer>
470
  </div>
 
474
  <motion.div
475
  initial={{ opacity: 0, y: 20 }}
476
  animate={{ opacity: 1, y: 0 }}
477
+ transition={{ delay: 0.8 }}
478
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm"
479
  >
480
+ <h3 className="text-lg font-bold text-slate-900 mb-6">Психотипы (DISC)</h3>
481
+ <div className="h-[250px] w-full relative">
 
 
 
 
 
482
  <ResponsiveContainer width="100%" height="100%">
483
  <PieChart>
484
  <Pie
485
+ data={data.disc_distribution as any[]}
 
 
 
486
  cx="50%"
487
  cy="50%"
488
  innerRadius={60}
489
  outerRadius={80}
490
  paddingAngle={5}
491
  dataKey="count"
 
492
  >
493
  {data.disc_distribution.map((entry, index) => (
494
  <Cell
495
  key={`cell-${index}`}
496
  fill={DISC_COLORS[entry.psychotype as keyof typeof DISC_COLORS] || DISC_COLORS['Unknown']}
497
+ strokeWidth={0}
498
  />
499
  ))}
500
  </Pie>
 
502
  contentStyle={{
503
  backgroundColor: '#fff',
504
  border: '1px solid #e2e8f0',
505
+ borderRadius: '8px'
 
 
506
  }}
507
+ formatter={(value: number) => [value, 'Клиентов']}
508
  />
509
  <Legend
510
+ verticalAlign="bottom"
511
+ height={36}
512
+ formatter={(value) => <span className="text-slate-600 text-xs font-medium ml-1">{PSYCHOTYPE_RUSSIAN[value] || value}</span>}
 
 
 
 
 
 
513
  />
514
  </PieChart>
515
  </ResponsiveContainer>
516
+ {/* Center Text */}
517
+ <div className="absolute inset-0 flex items-center justify-center pointer-events-none pb-8">
518
+ <div className="text-center">
519
+ <span className="text-2xl font-bold text-slate-900">{data.metrics.total_leads}</span>
520
+ <p className="text-xs text-slate-500 uppercase">Всего</p>
521
+ </div>
522
+ </div>
523
  </div>
524
  </motion.div>
525
 
526
+ {/* Top Objections */}
527
  <motion.div
528
  initial={{ opacity: 0, y: 20 }}
529
  animate={{ opacity: 1, y: 0 }}
530
+ transition={{ delay: 0.9 }}
531
+ className="bg-white p-6 rounded-2xl border border-slate-200 shadow-sm"
532
  >
533
+ <h3 className="text-lg font-bold text-slate-900 mb-6">Топ возражений</h3>
534
+ <div className="space-y-4">
535
+ {data.top_objections.map((obj, index) => (
536
+ <div key={index} className="group">
537
+ <div className="flex justify-between text-sm mb-1">
538
+ <span className="font-medium text-slate-700 group-hover:text-indigo-600 transition-colors">
539
+ {obj.objection}
540
+ </span>
541
+ <span className="font-bold text-slate-900">{obj.percentage}%</span>
 
 
 
 
 
 
 
542
  </div>
543
+ <div className="w-full bg-slate-100 rounded-full h-2 overflow-hidden">
544
+ <div
545
+ className="bg-slate-400 h-2 rounded-full group-hover:bg-indigo-500 transition-all duration-300"
546
+ style={{ width: `${obj.percentage}%` }}
 
 
547
  />
548
  </div>
549
  </div>
550
  ))}
551
+ {data.top_objections.length === 0 && (
552
+ <div className="text-center py-8 text-slate-400 text-sm">
553
+ Нет данных о возражениях
554
+ </div>
555
+ )}
556
  </div>
557
  </motion.div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  </div>
559
  </div>
560
  </div>
frontend/components/Sidebar.tsx CHANGED
@@ -68,26 +68,28 @@ export function Sidebar() {
68
  initial="hidden"
69
  animate="visible"
70
  variants={sidebarVariants}
71
- className="w-72 bg-white border-r border-slate-200 flex flex-col font-['Inter'] relative overflow-hidden shrink-0 h-screen sticky top-0"
72
  >
73
- {/* Background Glow Effect - Subtle for Light Mode */}
74
  <div className="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0">
75
- <div className="absolute -top-[20%] -left-[20%] w-[140%] h-[50%] bg-indigo-50/50 blur-[100px] rounded-full"></div>
 
76
  </div>
77
 
78
  {/* Logo Section */}
79
- <div className="p-6 border-b border-slate-100 relative z-10">
80
  <Link href="/dashboard" className="flex items-center gap-3 group">
81
  <div className="relative">
 
82
  <div className="w-10 h-10 rounded-xl flex items-center justify-center relative z-10 group-hover:scale-105 transition-transform duration-300 overflow-hidden">
83
  <img src="/logo-symbol-transparent.png?v=3" alt="MicroFunnel Logo" className="w-full h-full object-contain" />
84
  </div>
85
  </div>
86
  <div>
87
- <h1 className="text-lg font-bold text-slate-900 tracking-tight group-hover:text-indigo-600 transition-colors">
88
  MicroFunnel
89
  </h1>
90
- <p className="text-[10px] text-slate-500 font-medium uppercase tracking-wider">AI Sales Platform</p>
91
  </div>
92
  </Link>
93
  </div>
@@ -97,291 +99,203 @@ export function Sidebar() {
97
  <nav className="flex-1 overflow-y-auto p-4 space-y-6 relative z-10">
98
  {[1, 2, 3].map((i) => (
99
  <div key={i}>
100
- <div className="h-3 w-20 bg-slate-200 rounded mb-3 animate-pulse" />
101
  <div className="space-y-2">
102
- <div className="h-10 bg-slate-100 rounded-xl animate-pulse" />
103
- <div className="h-10 bg-slate-100 rounded-xl animate-pulse" />
 
104
  </div>
105
  </div>
106
  ))}
107
  </nav>
108
  ) : (
109
- <nav className="flex-1 overflow-y-auto p-4 space-y-8 relative z-10 scrollbar-thin scrollbar-thumb-slate-200 scrollbar-track-transparent">
110
- {/* WORKSPACE Group */}
 
111
  <motion.div variants={itemVariants}>
112
- <div className="text-[11px] font-bold text-slate-500 uppercase tracking-widest mb-3 px-3 flex items-center gap-2">
113
- <Command className="w-3 h-3" />
114
- Рабочее пространство
115
- </div>
116
  <div className="space-y-1">
117
- {user?.role === 'OWNER' && (
118
- <Link
119
- href="/dashboard"
120
- className={cn(
121
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
122
- isActive('/dashboard')
123
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
124
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
125
- )}
126
- >
127
- {isActive('/dashboard') && (
128
- <motion.div
129
- layoutId="activeTab"
130
- className="absolute inset-0 bg-indigo-50 rounded-xl"
131
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
132
- />
133
- )}
134
- <LayoutDashboard className={cn("w-5 h-5 transition-colors relative z-10", isActive('/dashboard') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
135
- <span className="flex-1 relative z-10">Дашборд</span>
136
- {isActive('/dashboard') && <div className="w-1.5 h-1.5 rounded-full bg-indigo-600 shadow-[0_0_8px_rgba(79,70,229,0.5)] relative z-10"></div>}
137
- </Link>
138
- )}
139
- <Link
140
- href="/chats"
141
- className={cn(
142
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
143
- isActive('/chats')
144
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
145
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
146
- )}
147
- >
148
- {isActive('/chats') && (
149
  <motion.div
150
  layoutId="activeTab"
151
- className="absolute inset-0 bg-indigo-50 rounded-xl"
152
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
153
  />
154
  )}
155
- <MessageSquare className={cn("w-5 h-5 transition-colors relative z-10", isActive('/chats') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
156
- <span className="flex-1 relative z-10">Чаты</span>
157
- {isActive('/chats') && <div className="w-1.5 h-1.5 rounded-full bg-indigo-600 shadow-[0_0_8px_rgba(79,70,229,0.5)] relative z-10"></div>}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  </Link>
159
  </div>
160
  </motion.div>
161
 
162
- {/* INTELLIGENCE Group - ТОЛЬКО ДЛЯ OWNER */}
163
- {user?.role === 'OWNER' && (
164
- <motion.div variants={itemVariants}>
165
- <div className="text-[11px] font-bold text-slate-500 uppercase tracking-widest mb-3 px-3 flex items-center gap-2">
166
- <Brain className="w-3 h-3" />
167
- Интеллект
168
- </div>
169
- <div className="space-y-1">
170
- <Link
171
- href="/knowledge"
172
- className={cn(
173
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
174
- isActive('/knowledge')
175
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
176
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
177
- )}
178
- >
179
- {isActive('/knowledge') && (
180
- <motion.div
181
- layoutId="activeTab"
182
- className="absolute inset-0 bg-indigo-50 rounded-xl"
183
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
184
- />
185
- )}
186
- <Database className={cn("w-5 h-5 transition-colors relative z-10", isActive('/knowledge') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
187
- <span className="flex-1 relative z-10">База Знаний</span>
188
- </Link>
189
- <Link
190
- href="/settings/brain"
191
- className={cn(
192
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
193
- isActive('/settings/brain')
194
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
195
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
196
- )}
197
- >
198
- {isActive('/settings/brain') && (
199
- <motion.div
200
- layoutId="activeTab"
201
- className="absolute inset-0 bg-indigo-50 rounded-xl"
202
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
203
- />
204
- )}
205
- <Brain className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/brain') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
206
- <span className="flex-1 relative z-10">AI Мозг</span>
207
- </Link>
208
- <Link
209
- href="/settings/playbook"
210
- className={cn(
211
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
212
- isActive('/settings/playbook')
213
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
214
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
215
- )}
216
- >
217
- {isActive('/settings/playbook') && (
218
- <motion.div
219
- layoutId="activeTab"
220
- className="absolute inset-0 bg-indigo-50 rounded-xl"
221
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
222
- />
223
- )}
224
- <Zap className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/playbook') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
225
- <span className="flex-1 relative z-10">Сценарии</span>
226
- </Link>
227
- </div>
228
- </motion.div>
229
- )}
230
 
231
- {/* CONNECTIONS Group */}
232
- {user?.role === 'OWNER' && (
233
- <motion.div variants={itemVariants}>
234
- <div className="text-[11px] font-bold text-slate-500 uppercase tracking-widest mb-3 px-3 flex items-center gap-2">
235
- <Plug className="w-3 h-3" />
236
- Подключения
237
- </div>
238
- <div className="space-y-1">
239
- <Link
240
- href="/channels"
241
- className={cn(
242
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
243
- isActive('/channels')
244
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
245
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
246
- )}
247
- >
248
- {isActive('/channels') && (
249
- <motion.div
250
- layoutId="activeTab"
251
- className="absolute inset-0 bg-indigo-50 rounded-xl"
252
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
253
- />
254
- )}
255
- <Send className={cn("w-5 h-5 transition-colors relative z-10", isActive('/channels') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
256
- <span className="flex-1 relative z-10">Каналы</span>
257
- </Link>
258
- <Link
259
- href="/settings/crm"
260
- className={cn(
261
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
262
- isActive('/settings/crm')
263
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
264
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
265
- )}
266
- >
267
- {isActive('/settings/crm') && (
268
- <motion.div
269
- layoutId="activeTab"
270
- className="absolute inset-0 bg-indigo-50 rounded-xl"
271
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
272
- />
273
- )}
274
- <Plug className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/crm') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
275
- <span className="flex-1 relative z-10">CRM Интеграция</span>
276
- </Link>
277
- </div>
278
- </motion.div>
279
- )}
280
 
281
- {/* SETTINGS Group - ТОЛЬКО ДЛЯ OWNER */}
282
- {user?.role === 'OWNER' && (
283
- <motion.div variants={itemVariants}>
284
- <div className="text-[11px] font-bold text-slate-500 uppercase tracking-widest mb-3 px-3 flex items-center gap-2">
285
- <Users className="w-3 h-3" />
286
- Настройки
287
- </div>
288
- <div className="space-y-1">
289
- <Link
290
- href="/settings/team"
291
- className={cn(
292
- "group flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 font-medium text-sm border border-transparent relative overflow-hidden",
293
- isActive('/settings/team')
294
- ? "bg-indigo-50 text-indigo-600 border-indigo-200 shadow-sm"
295
- : "text-slate-600 hover:text-slate-900 hover:bg-slate-50"
296
- )}
297
- >
298
- {isActive('/settings/team') && (
299
- <motion.div
300
- layoutId="activeTab"
301
- className="absolute inset-0 bg-indigo-50 rounded-xl"
302
- transition={{ type: "spring", bounce: 0.2, duration: 0.6 }}
303
- />
304
- )}
305
- <Users className={cn("w-5 h-5 transition-colors relative z-10", isActive('/settings/team') ? "text-indigo-600" : "text-slate-500 group-hover:text-slate-700")} />
306
- <span className="flex-1 relative z-10">Команда</span>
307
- </Link>
308
- </div>
309
- </motion.div>
310
- )}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  </nav>
312
  )}
313
 
314
  {/* Bottom Section */}
315
- <div className="mt-auto border-t border-slate-200 relative z-10 bg-slate-50/50 backdrop-blur-sm">
316
  {/* Partner Program Link */}
317
- {user?.role === 'OWNER' && (
318
- <div className="p-4 border-b border-slate-200">
319
- <Link
320
- href="/settings/partner"
321
- className="flex items-center gap-3 px-3 py-3 rounded-xl bg-gradient-to-r from-amber-500 to-orange-500 hover:from-amber-600 hover:to-orange-600 text-white transition-all duration-200 shadow-lg shadow-amber-500/20 font-medium text-sm group border border-white/10 relative overflow-hidden"
322
- >
323
- <div className="absolute inset-0 bg-white/20 translate-x-[-100%] group-hover:translate-x-[100%] transition-transform duration-700" />
324
- <DollarSign className="w-5 h-5 text-amber-100" />
325
- <span className="flex-1 font-bold">
326
- Партнерская программа
327
- </span>
328
- <ChevronRight className="w-4 h-4 text-amber-100 group-hover:translate-x-0.5 transition-transform" />
329
- </Link>
330
- </div>
331
- )}
332
-
333
- {/* User Profile Card or Sign In Fallback */}
334
- {user ? (
335
- <div className="p-4">
336
- <div className="flex items-center gap-3 px-3 py-2.5 rounded-xl bg-white hover:bg-slate-50 transition-colors border border-slate-200 group shadow-sm">
337
- {/* Avatar with Initials */}
338
- <div className={cn(
339
- "w-10 h-10 rounded-full flex items-center justify-center text-white font-bold text-sm shadow-inner transition-transform group-hover:scale-105",
340
- getAvatarColor(user.email)
341
- )}>
342
- {getInitials(user.full_name, user.email)}
343
  </div>
344
-
345
- {/* User Info */}
346
- <div className="flex-1 min-w-0">
347
- <p className="text-sm font-semibold text-slate-900 truncate group-hover:text-indigo-600 transition-colors">
348
- {user.full_name || user.email}
349
- </p>
350
- <div className="flex items-center gap-1.5">
351
- <span className={cn(
352
- "px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wide",
353
- user.role === 'OWNER'
354
- ? "bg-indigo-50 text-indigo-600 border border-indigo-200"
355
- : "bg-slate-100 text-slate-500 border border-slate-200"
356
- )}>
357
- {user.role === 'OWNER' ? 'Владелец' : 'Менеджер'}
358
- </span>
359
- </div>
360
  </div>
361
-
362
- {/* Logout Button */}
363
- <button
364
- onClick={logout}
365
- className="p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-all duration-200"
366
- title="Выйти"
367
- >
368
- <LogOut className="w-5 h-5" />
369
- </button>
370
  </div>
371
  </div>
372
- ) : (
373
- !isLoading && (
374
- <div className="p-4">
375
- <Link
376
- href="/login"
377
- className="flex items-center justify-center gap-2 px-4 py-3 rounded-xl bg-indigo-600 hover:bg-indigo-700 text-white transition-all duration-200 font-bold text-sm shadow-lg shadow-indigo-500/20"
378
- >
379
- <LogOut className="w-5 h-5" />
380
- Войти в систему
381
- </Link>
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  </div>
383
- )
384
- )}
 
 
 
 
 
 
 
385
  </div>
386
  </motion.aside>
387
  )
 
68
  initial="hidden"
69
  animate="visible"
70
  variants={sidebarVariants}
71
+ className="w-72 bg-[#0F172A] border-r border-slate-800 flex flex-col font-['Inter'] relative overflow-hidden shrink-0 h-screen sticky top-0"
72
  >
73
+ {/* Background Glow Effect - Dark Mode */}
74
  <div className="absolute top-0 left-0 w-full h-full overflow-hidden pointer-events-none z-0">
75
+ <div className="absolute -top-[20%] -left-[20%] w-[140%] h-[50%] bg-indigo-500/10 blur-[100px] rounded-full"></div>
76
+ <div className="absolute bottom-0 right-0 w-[100%] h-[40%] bg-purple-500/5 blur-[80px] rounded-full"></div>
77
  </div>
78
 
79
  {/* Logo Section */}
80
+ <div className="p-6 border-b border-slate-800 relative z-10">
81
  <Link href="/dashboard" className="flex items-center gap-3 group">
82
  <div className="relative">
83
+ <div className="absolute inset-0 bg-indigo-500/20 blur-xl rounded-full opacity-0 group-hover:opacity-100 transition-opacity duration-500"></div>
84
  <div className="w-10 h-10 rounded-xl flex items-center justify-center relative z-10 group-hover:scale-105 transition-transform duration-300 overflow-hidden">
85
  <img src="/logo-symbol-transparent.png?v=3" alt="MicroFunnel Logo" className="w-full h-full object-contain" />
86
  </div>
87
  </div>
88
  <div>
89
+ <h1 className="text-lg font-bold text-white tracking-tight group-hover:text-indigo-400 transition-colors">
90
  MicroFunnel
91
  </h1>
92
+ <p className="text-[10px] text-slate-400 font-medium uppercase tracking-wider">AI Sales Platform</p>
93
  </div>
94
  </Link>
95
  </div>
 
99
  <nav className="flex-1 overflow-y-auto p-4 space-y-6 relative z-10">
100
  {[1, 2, 3].map((i) => (
101
  <div key={i}>
102
+ <div className="h-3 w-20 bg-slate-800 rounded mb-3 animate-pulse" />
103
  <div className="space-y-2">
104
+ {[1, 2, 3].map((j) => (
105
+ <div key={j} className="h-10 w-full bg-slate-800/50 rounded-lg animate-pulse" />
106
+ ))}
107
  </div>
108
  </div>
109
  ))}
110
  </nav>
111
  ) : (
112
+ <nav className="flex-1 overflow-y-auto p-4 space-y-6 relative z-10 scrollbar-thin scrollbar-thumb-slate-700 scrollbar-track-transparent">
113
+
114
+ {/* Main Navigation */}
115
  <motion.div variants={itemVariants}>
116
+ <p className="px-4 text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2">
117
+ Платформа
118
+ </p>
 
119
  <div className="space-y-1">
120
+ <Link href="/dashboard" className={cn(
121
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative overflow-hidden",
122
+ isActive('/dashboard')
123
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
124
+ : "text-slate-400 hover:text-white hover:bg-white/5"
125
+ )}>
126
+ {isActive('/dashboard') && (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  <motion.div
128
  layoutId="activeTab"
129
+ className="absolute inset-0 bg-indigo-600 rounded-xl -z-10"
130
+ transition={{ type: "spring", stiffness: 300, damping: 30 }}
131
  />
132
  )}
133
+ <LayoutDashboard className={cn("w-5 h-5 transition-colors", isActive('/dashboard') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
134
+ <span>Дашборд</span>
135
+ {isActive('/dashboard') && <div className="ml-auto w-1.5 h-1.5 rounded-full bg-white animate-pulse" />}
136
+ </Link>
137
+
138
+ <Link href="/chats" className={cn(
139
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
140
+ isActive('/chats')
141
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
142
+ : "text-slate-400 hover:text-white hover:bg-white/5"
143
+ )}>
144
+ <MessageSquare className={cn("w-5 h-5 transition-colors", isActive('/chats') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
145
+ <span>Чаты</span>
146
+ {/* Badge for unread messages could go here */}
147
+ </Link>
148
+
149
+ <Link href="/leads" className={cn(
150
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
151
+ isActive('/leads')
152
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
153
+ : "text-slate-400 hover:text-white hover:bg-white/5"
154
+ )}>
155
+ <Users className={cn("w-5 h-5 transition-colors", isActive('/leads') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
156
+ <span>Лиды (CRM)</span>
157
  </Link>
158
  </div>
159
  </motion.div>
160
 
161
+ {/* AI Tools */}
162
+ <motion.div variants={itemVariants}>
163
+ <p className="px-4 text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2">
164
+ AI Инструменты
165
+ </p>
166
+ <div className="space-y-1">
167
+ <Link href="/knowledge" className={cn(
168
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
169
+ isActive('/knowledge')
170
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
171
+ : "text-slate-400 hover:text-white hover:bg-white/5"
172
+ )}>
173
+ <Brain className={cn("w-5 h-5 transition-colors", isActive('/knowledge') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
174
+ <span>База Знаний</span>
175
+ </Link>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
 
177
+ <Link href="/channels" className={cn(
178
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
179
+ isActive('/channels')
180
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
181
+ : "text-slate-400 hover:text-white hover:bg-white/5"
182
+ )}>
183
+ <Plug className={cn("w-5 h-5 transition-colors", isActive('/channels') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
184
+ <span>Каналы</span>
185
+ </Link>
186
+ </div>
187
+ </motion.div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
+ {/* Settings Group */}
190
+ <motion.div variants={itemVariants}>
191
+ <p className="px-4 text-xs font-semibold text-slate-500 uppercase tracking-wider mb-2">
192
+ Настройки
193
+ </p>
194
+ <div className="space-y-1">
195
+ <Link href="/settings/brain" className={cn(
196
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
197
+ isActive('/settings/brain')
198
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
199
+ : "text-slate-400 hover:text-white hover:bg-white/5"
200
+ )}>
201
+ <Sparkles className={cn("w-5 h-5 transition-colors", isActive('/settings/brain') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
202
+ <span>Мозг AI</span>
203
+ </Link>
204
+
205
+ <Link href="/settings/crm" className={cn(
206
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
207
+ isActive('/settings/crm')
208
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
209
+ : "text-slate-400 hover:text-white hover:bg-white/5"
210
+ )}>
211
+ <Database className={cn("w-5 h-5 transition-colors", isActive('/settings/crm') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
212
+ <span>CRM Интеграция</span>
213
+ </Link>
214
+
215
+ <Link href="/settings/playbook" className={cn(
216
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
217
+ isActive('/settings/playbook')
218
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
219
+ : "text-slate-400 hover:text-white hover:bg-white/5"
220
+ )}>
221
+ <Target className={cn("w-5 h-5 transition-colors", isActive('/settings/playbook') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
222
+ <span>Плейбуки</span>
223
+ </Link>
224
+
225
+ <Link href="/settings/team" className={cn(
226
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
227
+ isActive('/settings/team')
228
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
229
+ : "text-slate-400 hover:text-white hover:bg-white/5"
230
+ )}>
231
+ <Users className={cn("w-5 h-5 transition-colors", isActive('/settings/team') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
232
+ <span>Команда</span>
233
+ </Link>
234
+
235
+ <Link href="/settings/billing" className={cn(
236
+ "flex items-center gap-3 px-4 py-2.5 rounded-xl text-sm font-medium transition-all duration-200 group relative",
237
+ isActive('/settings/billing')
238
+ ? "text-white bg-indigo-600 shadow-lg shadow-indigo-900/20"
239
+ : "text-slate-400 hover:text-white hover:bg-white/5"
240
+ )}>
241
+ <DollarSign className={cn("w-5 h-5 transition-colors", isActive('/settings/billing') ? "text-white" : "text-slate-500 group-hover:text-indigo-400")} />
242
+ <span>Тариф и Оплата</span>
243
+ </Link>
244
+ </div>
245
+ </motion.div>
246
  </nav>
247
  )}
248
 
249
  {/* Bottom Section */}
250
+ <div className="p-4 border-t border-slate-800 bg-[#0F172A]/50 backdrop-blur-sm relative z-10">
251
  {/* Partner Program Link */}
252
+ <Link href="/partners" className="block mb-4 group">
253
+ <div className="relative overflow-hidden rounded-xl bg-gradient-to-r from-indigo-900 to-purple-900 border border-indigo-500/30 p-3 transition-all duration-300 hover:border-indigo-500/60 hover:shadow-lg hover:shadow-indigo-900/20">
254
+ <div className="absolute inset-0 bg-gradient-to-r from-indigo-500/10 to-purple-500/10 opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
255
+ <div className="flex items-center gap-3 relative z-10">
256
+ <div className="w-8 h-8 rounded-lg bg-indigo-500/20 flex items-center justify-center text-indigo-300 group-hover:text-white group-hover:scale-110 transition-all duration-300">
257
+ <Zap className="w-4 h-4" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  </div>
259
+ <div>
260
+ <p className="text-xs font-bold text-indigo-100 group-hover:text-white transition-colors">Партнерская программа</p>
261
+ <p className="text-[10px] text-indigo-300/80 group-hover:text-indigo-200 transition-colors">Зарабатывайте 50%</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  </div>
263
+ <ChevronRight className="w-4 h-4 text-indigo-400 ml-auto group-hover:translate-x-1 transition-transform" />
 
 
 
 
 
 
 
 
264
  </div>
265
  </div>
266
+ </Link>
267
+
268
+ {/* User Profile */}
269
+ <div className="flex items-center gap-3 px-2">
270
+ <div className={cn(
271
+ "w-9 h-9 rounded-lg flex items-center justify-center text-white font-bold text-sm shadow-lg",
272
+ getAvatarColor(user?.email)
273
+ )}>
274
+ {getInitials(user?.full_name, user?.email)}
275
+ </div>
276
+ <div className="flex-1 min-w-0">
277
+ <p className="text-sm font-medium text-white truncate">
278
+ {user?.full_name || 'Пользователь'}
279
+ </p>
280
+ <div className="flex items-center gap-2">
281
+ <span className="text-xs text-slate-400 truncate max-w-[80px]">
282
+ {user?.email}
283
+ </span>
284
+ {user?.role === 'admin' && (
285
+ <span className="px-1.5 py-0.5 rounded bg-indigo-500/20 text-[10px] font-bold text-indigo-300 border border-indigo-500/30">
286
+ ADMIN
287
+ </span>
288
+ )}
289
  </div>
290
+ </div>
291
+ <button
292
+ onClick={() => logout()}
293
+ className="p-2 text-slate-400 hover:text-white hover:bg-white/10 rounded-lg transition-colors"
294
+ title="Выйти"
295
+ >
296
+ <LogOut className="w-4 h-4" />
297
+ </button>
298
+ </div>
299
  </div>
300
  </motion.aside>
301
  )