File size: 28,921 Bytes
5ba9d00
 
fdc7871
 
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
977232b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
 
 
 
 
 
 
977232b
 
fdc7871
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ba9d00
 
 
fdc7871
5ba9d00
 
fdc7871
 
 
5ba9d00
fdc7871
5ba9d00
 
 
 
 
 
fdc7871
5ba9d00
 
 
fdc7871
5ba9d00
 
 
 
 
 
 
fdc7871
5ba9d00
fdc7871
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
5ba9d00
 
 
 
977232b
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
5ba9d00
 
 
fdc7871
5ba9d00
 
 
fdc7871
5ba9d00
 
fdc7871
 
5ba9d00
 
fdc7871
 
 
 
5ba9d00
 
fdc7871
 
 
 
 
 
 
5ba9d00
 
 
 
 
 
 
fdc7871
5ba9d00
 
fdc7871
 
 
 
 
 
 
 
5ba9d00
 
 
 
 
 
fdc7871
 
 
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
977232b
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
 
 
 
 
 
5ba9d00
 
 
 
fdc7871
 
 
5ba9d00
fdc7871
 
 
 
 
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
977232b
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
 
 
 
5ba9d00
fdc7871
 
5ba9d00
fdc7871
 
 
 
5ba9d00
fdc7871
 
 
5ba9d00
 
fdc7871
5ba9d00
 
 
 
 
fdc7871
 
 
 
 
 
5ba9d00
fdc7871
5ba9d00
fdc7871
 
 
 
 
 
 
 
 
 
5ba9d00
 
 
 
 
fdc7871
 
5ba9d00
fdc7871
 
 
 
 
5ba9d00
fdc7871
 
 
 
 
5ba9d00
fdc7871
 
 
 
 
5ba9d00
fdc7871
 
 
 
5ba9d00
 
 
 
 
 
 
 
 
 
 
 
 
fdc7871
5ba9d00
 
 
fdc7871
5ba9d00
 
 
fdc7871
5ba9d00
 
 
fdc7871
 
 
 
 
 
5ba9d00
fdc7871
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
import React, { useEffect } from 'react';
import { Lock, LogIn, ShieldAlert, UserCheck, Clock, Zap, MessageSquare, Award, Shield } from 'lucide-react';
import { Radar } from 'react-chartjs-2';

// Custom SVG Circular Progress Component
function CircularProgress({ percentage, size = 68, strokeWidth = 5, color = 'var(--color-brand)' }) {
  const radius = (size - strokeWidth) / 2;
  const circumference = radius * 2 * Math.PI;
  const offset = circumference - (percentage / 100) * circumference;

  return (
    <div style={{ position: 'relative', width: size, height: size, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
      <svg width={size} height={size} style={{ transform: 'rotate(-90deg)' }}>
        {/* Background Circle */}
        <circle
          cx={size / 2}
          cy={size / 2}
          r={radius}
          fill="transparent"
          stroke="rgba(255, 255, 255, 0.05)"
          strokeWidth={strokeWidth}
        />
        {/* Foreground Circle */}
        <circle
          cx={size / 2}
          cy={size / 2}
          r={radius}
          fill="transparent"
          stroke={color}
          strokeWidth={strokeWidth}
          strokeDasharray={circumference}
          strokeDashoffset={offset}
          strokeLinecap="round"
          style={{ transition: 'stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1)' }}
        />
      </svg>
      <div style={{ position: 'absolute', fontSize: `${size * 0.23}px`, fontWeight: '800', fontFamily: 'var(--font-family-display)', color: 'var(--color-text-main)' }}>
        {percentage}%
      </div>
    </div>
  );
}

// Custom Initials Avatar Generator
function InitialsAvatar({ name, size = 40, border = '1px solid var(--color-border)' }) {
  const initials = (name || '??').substring(0, 2).toUpperCase();
  
  // Deterministic background gradient based on username string
  let hash = 0;
  for (let i = 0; i < name.length; i++) {
    hash = name.charCodeAt(i) + ((hash << 5) - hash);
  }
  const hue = Math.abs(hash % 360);
  const background = `linear-gradient(135deg, hsl(${hue}, 65%, 45%) 0%, hsl(${(hue + 40) % 360}, 75%, 30%) 100%)`;

  return (
    <div style={{
      width: size,
      height: size,
      borderRadius: '50%',
      background,
      border,
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      fontWeight: '700',
      fontSize: `${size * 0.38}px`,
      color: '#ffffff',
      textShadow: '0 1px 2px rgba(0,0,0,0.3)',
      boxShadow: 'inset 0 1px 3px rgba(255,255,255,0.2)',
      fontFamily: 'var(--font-family-display)',
      flexShrink: 0
    }}>
      {initials}
    </div>
  );
}

// Custom Avatar Component that fetches from Twitch API Proxy, falls back to initials
function ModeratorAvatar({ name, size = 40, border = '1px solid var(--color-border)', API_BASE }) {
  const [imgSrc, setImgSrc] = React.useState('');
  const [hasError, setHasError] = React.useState(false);
  const [loading, setLoading] = React.useState(true);

  React.useEffect(() => {
    if (!name) return;
    const base = API_BASE || '';
    setImgSrc(`${base}/api/avatar/${name.toLowerCase()}`);
    setHasError(false);
    setLoading(true);
  }, [name, API_BASE]);

  if (hasError || !name) {
    return <InitialsAvatar name={name} size={size} border={border} />;
  }

  return (
    <div style={{
      width: size,
      height: size,
      borderRadius: '50%',
      border,
      display: 'inline-flex',
      alignItems: 'center',
      justifyContent: 'center',
      overflow: 'hidden',
      flexShrink: 0,
      backgroundColor: 'rgba(255, 255, 255, 0.05)',
      position: 'relative'
    }}>
      {loading && (
        <div style={{
          position: 'absolute',
          inset: 0,
          background: 'rgba(255, 255, 255, 0.05)',
          borderRadius: '50%'
        }} />
      )}
      <img
        src={imgSrc}
        alt={name}
        onLoad={() => setLoading(false)}
        onError={() => setHasError(true)}
        style={{
          width: '100%',
          height: '100%',
          objectFit: 'cover',
          opacity: loading ? 0 : 1,
          transition: 'opacity 0.2s ease-in-out'
        }}
      />
    </div>
  );
}

export default function ModeratorTab({
  twitchConfigured,
  auth,
  handleLogin,
  TWITCH_CHANNEL,
  modProfiles,
  selectedMod,
  setSelectedMod,
  API_BASE
}) {
  
  // Set default selected moderator if not set yet
  useEffect(() => {
    if (modProfiles && modProfiles.length > 0 && !selectedMod) {
      setSelectedMod(modProfiles[0]);
    }
  }, [modProfiles, selectedMod, setSelectedMod]);

  // Calculate composite KPI score
  const getKpiScore = (mod) => {
    if (!mod || !mod.scores) return 0;
    const { speed = 50, activity = 50, watchfulness = 50 } = mod.scores;
    return Math.round((speed + activity + watchfulness) / 3);
  };

  return (
    <div className="tab-content">
      {twitchConfigured && !auth.loggedIn ? (
        <div className="login-overlay">
          <div className="login-card">
            <Lock size={48} style={{ color: 'var(--color-brand)', marginBottom: '1.5rem' }} />
            <h2 className="login-title">Доступ Ограничен</h2>
            <p className="login-description">
              Лог действий модераторов и статистика банов/удалений доступны только стримеру и официальным модераторам канала **winx_prinx**. 
              Пожалуйста, авторизуйтесь через Twitch для проверки прав.
            </p>
            <button className="btn" onClick={handleLogin}>
              <LogIn size={16} /> Войти через Twitch
            </button>
          </div>
        </div>
      ) : twitchConfigured && (auth.user?.role !== 'streamer' && auth.user?.role !== 'moderator' && auth.user?.role !== 'admin') ? (
        <div className="status-msg">
          <ShieldAlert size={48} className="status-msg-icon" />
          <h2>Недостаточно прав</h2>
          <p>Вы успешно вошли как <strong>{auth.user?.displayName}</strong>, но вы не являетесь модератором канала {TWITCH_CHANNEL}.</p>
        </div>
      ) : (
        <div>
          {(!modProfiles || modProfiles.length <= 2) && (
            <div style={{ background: 'rgba(145, 70, 255, 0.08)', border: '1px solid rgba(145, 70, 255, 0.25)', borderRadius: '12px', padding: '1.25rem', marginBottom: '2rem', display: 'flex', gap: '1rem', alignItems: 'center' }}>
              <ShieldAlert size={26} style={{ color: 'var(--color-brand)', flexShrink: 0 }} />
              <div>
                <h4 style={{ margin: '0 0 0.25rem 0', color: 'var(--color-text-main)', fontSize: '0.95rem', fontWeight: 600 }}>Данные накапливаются</h4>
                <p style={{ margin: 0, fontSize: '0.82rem', color: 'var(--color-text-muted)' }}>Информация о модераторах появляется по мере их активности в выбранном стриме.</p>
              </div>
            </div>
          )}

          {/* TOP 3 PODIUM */}
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(280px, 1fr))', gap: '1.5rem', marginBottom: '2.5rem' }}>
            {modProfiles && modProfiles.slice(0, 3).map((mod, idx) => {
              const trophyColor = idx === 0 ? '#FFD700' : idx === 1 ? '#D1D1D6' : '#EAA96E';
              const rankName = idx === 0 ? 'Глава патруля' : idx === 1 ? 'Старший мод' : 'Защитник чата';
              const isSelected = selectedMod && selectedMod.moderator === mod.moderator;
              
              const glowStyle = {
                borderColor: isSelected ? 'var(--color-brand)' : 'var(--color-border)',
                background: isSelected ? 'rgba(145, 70, 255, 0.05)' : 'var(--color-bg-card)',
                boxShadow: isSelected ? '0 8px 30px rgba(145, 70, 255, 0.15)' : 'var(--shadow-md)',
                position: 'relative',
                overflow: 'hidden',
                borderWidth: '1px',
                borderStyle: 'solid',
                borderRadius: 'var(--radius-lg)',
                padding: '1.75rem',
                transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
                cursor: 'pointer'
              };

              return (
                <div key={idx} style={glowStyle} onClick={() => setSelectedMod(mod)}>
                  {/* Rank background watermark */}
                  <div style={{ 
                    position: 'absolute', 
                    top: '-15px', 
                    right: '-5px', 
                    fontSize: '6.5rem', 
                    opacity: isSelected ? 0.14 : 0.06, 
                    color: trophyColor, 
                    fontWeight: 900,
                    fontFamily: 'var(--font-family-display)',
                    userSelect: 'none'
                  }}>
                    0{idx + 1}
                  </div>

                  {/* Header metadata */}
                  <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '1.5rem' }}>
                    <div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
                      <ModeratorAvatar name={mod.moderator} size={48} border={`2px solid ${trophyColor}`} API_BASE={API_BASE} />
                      <div>
                        <h4 style={{ margin: 0, fontSize: '1.1rem', fontWeight: 700, letterSpacing: '-0.01em' }}>{mod.moderator}</h4>
                        <span style={{ 
                          fontSize: '0.68rem', 
                          fontWeight: '700',
                          color: trophyColor, 
                          textTransform: 'uppercase', 
                          letterSpacing: '0.08em',
                          display: 'flex',
                          alignItems: 'center',
                          gap: '0.2rem',
                          marginTop: '0.15rem'
                        }}>
                          <Award size={10} /> {rankName}
                        </span>
                      </div>
                    </div>
                    
                    {/* Circular KPI progress */}
                    <CircularProgress percentage={getKpiScore(mod)} size={62} color={trophyColor} />
                  </div>

                  {/* Quick stats grid */}
                  <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '1rem', borderTop: '1px solid rgba(255,255,255,0.06)', paddingTop: '1.25rem' }}>
                    <div>
                      <div style={{ color: 'var(--color-text-muted)', fontSize: '0.72rem', textTransform: 'uppercase', fontWeight: 600, letterSpacing: '0.02em', marginBottom: '0.2rem' }}>Действий</div>
                      <div style={{ fontSize: '1.15rem', fontWeight: 800, color: 'var(--color-text-main)' }}>{mod.total_actions}</div>
                    </div>
                    <div>
                      <div style={{ color: 'var(--color-text-muted)', fontSize: '0.72rem', textTransform: 'uppercase', fontWeight: 600, letterSpacing: '0.02em', marginBottom: '0.2rem' }}>Реакция</div>
                      <div style={{ fontSize: '1.15rem', fontWeight: 800, color: '#00F5D4' }}>
                        {mod.reaction_time_avg ? `${mod.reaction_time_avg}с` : '—'}
                      </div>
                    </div>
                    <div>
                      <div style={{ color: 'var(--color-text-muted)', fontSize: '0.72rem', textTransform: 'uppercase', fontWeight: 600, letterSpacing: '0.02em', marginBottom: '0.2rem' }}>Муты/Баны</div>
                      <div style={{ fontSize: '1.15rem', fontWeight: 800, color: '#e91e63' }}>{mod.bans_count + mod.timeouts_count}</div>
                    </div>
                  </div>
                </div>
              );
            })}
          </div>

          {/* MAIN GRID */}
          <div className="grid-2col" style={{ gridTemplateColumns: '1.1fr 0.9fr', gap: '1.75rem', alignItems: 'start' }}>
            
            {/* Left Column: Leaderboard Table */}
            <div className="panel" style={{ padding: '1.75rem' }}>
              <div className="panel-header" style={{ marginBottom: '1.5rem', paddingBottom: '1rem' }}>
                <h3 className="panel-title" style={{ fontSize: '1.1rem', fontWeight: 700 }}><Shield size={20} style={{ color: 'var(--color-brand)' }} /> Рейтинг модераторов</h3>
              </div>
              {(!modProfiles || modProfiles.length === 0) ? (
                <div className="status-msg" style={{ padding: '3rem 1.5rem' }}>
                  <ShieldAlert size={40} className="status-msg-icon" />
                  <p>Модераторы еще не совершали действий в этом периоде</p>
                </div>
              ) : (
                <div className="table-wrapper">
                  <table className="data-table">
                    <thead>
                      <tr>
                        <th style={{ width: '60px', padding: '0.75rem 0.5rem' }}>Ранг</th>
                        <th style={{ padding: '0.75rem 0.5rem' }}>Модератор</th>
                        <th style={{ textAlign: 'center', padding: '0.75rem 0.5rem' }}>Реакция</th>
                        <th style={{ textAlign: 'center', padding: '0.75rem 0.5rem' }}>Действий</th>
                        <th style={{ textAlign: 'center', padding: '0.75rem 0.5rem' }}>Бан/Мут</th>
                        <th style={{ width: '130px', padding: '0.75rem 0.5rem' }}>КПД</th>
                      </tr>
                    </thead>
                    <tbody>
                      {modProfiles.map((mod, idx) => {
                        const isSelected = selectedMod && selectedMod.moderator === mod.moderator;
                        const kpi = getKpiScore(mod);
                        return (
                          <tr 
                            key={idx} 
                            onClick={() => setSelectedMod(mod)}
                            style={{ 
                              cursor: 'pointer',
                              background: isSelected ? 'rgba(145, 70, 255, 0.06)' : 'transparent',
                              transition: 'background-color 0.2s ease'
                            }}
                          >
                            <td style={{ 
                              fontWeight: 700, 
                              color: isSelected ? 'var(--color-brand)' : 'var(--color-text-muted)',
                              padding: '0.9rem 0.5rem'
                            }}>
                              #{idx + 1}
                            </td>
                            <td style={{ padding: '0.9rem 0.5rem' }}>
                              <div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
                                <ModeratorAvatar name={mod.moderator} size={32} API_BASE={API_BASE} />
                                <span style={{ fontWeight: 600, color: isSelected ? 'var(--color-text-main)' : 'var(--color-text-muted)' }}>{mod.moderator}</span>
                              </div>
                            </td>
                            <td style={{ textAlign: 'center', fontWeight: 700, color: '#00F5D4', padding: '0.9rem 0.5rem' }}>
                              {mod.reaction_time_avg ? `${mod.reaction_time_avg}с` : '—'}
                            </td>
                            <td style={{ textAlign: 'center', fontWeight: 700, padding: '0.9rem 0.5rem' }}>{mod.total_actions}</td>
                            <td style={{ textAlign: 'center', color: '#ff7f50', fontWeight: 600, padding: '0.9rem 0.5rem' }}>
                              {mod.bans_count}/{mod.timeouts_count}
                            </td>
                            <td style={{ padding: '0.9rem 0.5rem' }}>
                              <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
                                <div style={{ flex: 1, height: '6px', background: 'rgba(255,255,255,0.06)', borderRadius: '3px', overflow: 'hidden' }}>
                                  <div style={{ 
                                    width: `${kpi}%`, 
                                    background: 'linear-gradient(90deg, var(--color-brand) 0%, #00e5ff 100%)', 
                                    height: '100%',
                                    borderRadius: '3px'
                                  }} />
                                </div>
                                <span style={{ fontSize: '0.75rem', fontWeight: 700, width: '28px', textAlign: 'right' }}>{kpi}%</span>
                              </div>
                            </td>
                          </tr>
                        );
                      })}
                    </tbody>
                  </table>
                </div>
              )}
            </div>

            {/* Right Column: Detailed Dossier */}
            <div className="panel" style={{ padding: '1.75rem' }}>
              <div className="panel-header" style={{ marginBottom: '1.5rem', paddingBottom: '1rem' }}>
                <h3 className="panel-title" style={{ fontSize: '1.1rem', fontWeight: 700 }}><UserCheck size={20} style={{ color: 'var(--color-brand)' }} /> Личное досье модератора</h3>
              </div>
              
              {!selectedMod ? (
                <div className="status-msg" style={{ padding: '4rem 1.5rem' }}>
                  <UserCheck size={40} className="status-msg-icon" />
                  <p>Выберите модератора слева для просмотра досье</p>
                </div>
              ) : (
                <div>
                  {/* Moderator Card Summary */}
                  <div style={{ 
                    display: 'flex', 
                    justifyContent: 'space-between', 
                    alignItems: 'center', 
                    marginBottom: '1.75rem',
                    background: 'rgba(255,255,255,0.02)',
                    border: '1px solid var(--color-border)',
                    borderRadius: 'var(--radius-md)',
                    padding: '1.25rem'
                  }}>
                    <div style={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
                      <ModeratorAvatar name={selectedMod.moderator} size={54} border="2px solid var(--color-brand)" API_BASE={API_BASE} />
                      <div>
                        <h3 style={{ margin: 0, fontSize: '1.25rem', fontWeight: 800 }}>{selectedMod.moderator}</h3>
                        <span className="badge badge-mod" style={{ marginTop: '0.35rem', fontSize: '0.65rem' }}>Модератор</span>
                      </div>
                    </div>
                    
                    {/* Circle KPI indicator */}
                    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '0.15rem' }}>
                      <CircularProgress percentage={getKpiScore(selectedMod)} size={64} color="var(--color-brand)" />
                      <span style={{ fontSize: '0.65rem', color: 'var(--color-text-muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.05em' }}>КПД</span>
                    </div>
                  </div>

                  {/* 3-column Detailed Metrics */}
                  <div style={{ 
                    display: 'grid', 
                    gridTemplateColumns: 'repeat(3, 1fr)', 
                    gap: '1rem', 
                    marginBottom: '1.75rem',
                    textAlign: 'center'
                  }}>
                    <div style={{ background: 'rgba(255,255,255,0.02)', border: '1px solid var(--color-border)', borderRadius: 'var(--radius-md)', padding: '0.75rem' }}>
                      <div style={{ fontSize: '0.65rem', color: 'var(--color-text-muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: '0.25rem', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.2rem' }}>
                        <Clock size={10} /> Реакция
                      </div>
                      <div style={{ fontSize: '1.2rem', fontWeight: 800, color: '#00F5D4' }}>
                        {selectedMod.reaction_time_avg ? `${selectedMod.reaction_time_avg}с` : '—'}
                      </div>
                    </div>
                    <div style={{ background: 'rgba(255,255,255,0.02)', border: '1px solid var(--color-border)', borderRadius: 'var(--radius-md)', padding: '0.75rem' }}>
                      <div style={{ fontSize: '0.65rem', color: 'var(--color-text-muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: '0.25rem', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.2rem' }}>
                        <Zap size={10} /> Действий
                      </div>
                      <div style={{ fontSize: '1.2rem', fontWeight: 800, color: 'var(--color-text-main)' }}>
                        {selectedMod.total_actions}
                      </div>
                    </div>
                    <div style={{ background: 'rgba(255,255,255,0.02)', border: '1px solid var(--color-border)', borderRadius: 'var(--radius-md)', padding: '0.75rem' }}>
                      <div style={{ fontSize: '0.65rem', color: 'var(--color-text-muted)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.05em', marginBottom: '0.25rem', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.2rem' }}>
                        <MessageSquare size={10} /> Муты/Баны
                      </div>
                      <div style={{ fontSize: '1.2rem', fontWeight: 800, color: '#e91e63' }}>
                        {selectedMod.bans_count + selectedMod.timeouts_count}
                      </div>
                    </div>
                  </div>

                  {/* Radar chart */}
                  <div style={{ height: '270px', display: 'flex', justifyContent: 'center', marginBottom: '2rem' }}>
                    <Radar 
                      data={{
                        labels: ['Скорость', 'Активность', 'Присутствие', 'Жесткость', 'Внимательность'],
                        datasets: [{
                          data: [
                            selectedMod.scores.speed,
                            selectedMod.scores.activity,
                            Math.min(100, Math.round(selectedMod.scores.activity * 1.15)), // Presence mapped based on activity
                            selectedMod.scores.harshness,
                            selectedMod.scores.watchfulness
                          ],
                          backgroundColor: 'rgba(145, 70, 255, 0.15)',
                          borderColor: '#9146ff',
                          borderWidth: 2,
                          pointBackgroundColor: '#9146ff',
                          pointBorderColor: '#ffffff',
                          pointHoverBackgroundColor: '#ffffff',
                          pointHoverBorderColor: '#9146ff',
                          pointRadius: 3
                        }]
                      }}
                      options={{
                        plugins: { legend: { display: false } },
                        scales: {
                          r: {
                            angleLines: { color: 'rgba(47, 47, 53, 0.5)' },
                            grid: { color: '#2F2F35' },
                            pointLabels: { color: '#ADADB8', font: { family: 'var(--font-family-sans)', size: 9, weight: 'bold' } },
                            ticks: { display: false },
                            min: 0,
                            max: 100
                          }
                        }
                      }}
                    />
                  </div>

                  {/* Actions distribution */}
                  <div style={{ borderTop: '1px solid rgba(255,255,255,0.06)', paddingTop: '1.5rem' }}>
                    <h4 style={{ margin: '0 0 0.75rem 0', fontSize: '0.82rem', fontWeight: 700, textTransform: 'uppercase', color: 'var(--color-text-muted)', letterSpacing: '0.03em' }}>Распределение действий:</h4>
                    
                    {/* Stacked Horizontal Bar */}
                    <div style={{ height: '18px', display: 'flex', borderRadius: '9px', overflow: 'hidden', background: 'rgba(255,255,255,0.04)', border: '1px solid var(--color-border)' }}>
                      {selectedMod.bans_count > 0 && (
                        <div 
                          style={{ width: `${(selectedMod.bans_count / selectedMod.total_actions) * 100}%`, background: '#FF0055', height: '100%', transition: 'width 0.5s ease' }} 
                          title={`Баны: ${selectedMod.bans_count}`} 
                        />
                      )}
                      {selectedMod.timeouts_count > 0 && (
                        <div 
                          style={{ width: `${(selectedMod.timeouts_count / selectedMod.total_actions) * 100}%`, background: '#FFAA00', height: '100%', transition: 'width 0.5s ease' }} 
                          title={`Муты/Таймауты: ${selectedMod.timeouts_count}`} 
                        />
                      )}
                      {selectedMod.deletions_count > 0 && (
                        <div 
                          style={{ width: `${(selectedMod.deletions_count / selectedMod.total_actions) * 100}%`, background: '#00AAFF', height: '100%', transition: 'width 0.5s ease' }} 
                          title={`Удаления сообщений: ${selectedMod.deletions_count}`} 
                        />
                      )}
                      {selectedMod.unbans_count > 0 && (
                        <div 
                          style={{ width: `${(selectedMod.unbans_count / selectedMod.total_actions) * 100}%`, background: '#00FF88', height: '100%', transition: 'width 0.5s ease' }} 
                          title={`Разбаны: ${selectedMod.unbans_count}`} 
                        />
                      )}
                    </div>

                    {/* Legend Grid */}
                    <div style={{ 
                      display: 'grid', 
                      gridTemplateColumns: 'repeat(2, 1fr)', 
                      gap: '0.6rem 1rem', 
                      marginTop: '1rem', 
                      fontSize: '0.75rem', 
                      color: 'var(--color-text-muted)' 
                    }}>
                      <div style={{ display: 'flex', alignItems: 'center', gap: '0.4rem' }}>
                        <span style={{ display: 'inline-block', width: '8px', height: '8px', borderRadius: '50%', background: '#FF0055' }}></span>
                        <span>Баны: <strong>{selectedMod.bans_count}</strong> ({Math.round((selectedMod.bans_count / selectedMod.total_actions) * 100) || 0}%)</span>
                      </div>
                      <div style={{ display: 'flex', alignItems: 'center', gap: '0.4rem' }}>
                        <span style={{ display: 'inline-block', width: '8px', height: '8px', borderRadius: '50%', background: '#FFAA00' }}></span>
                        <span>Муты: <strong>{selectedMod.timeouts_count}</strong> ({Math.round((selectedMod.timeouts_count / selectedMod.total_actions) * 100) || 0}%)</span>
                      </div>
                      <div style={{ display: 'flex', alignItems: 'center', gap: '0.4rem' }}>
                        <span style={{ display: 'inline-block', width: '8px', height: '8px', borderRadius: '50%', background: '#00AAFF' }}></span>
                        <span>Удаления: <strong>{selectedMod.deletions_count}</strong> ({Math.round((selectedMod.deletions_count / selectedMod.total_actions) * 100) || 0}%)</span>
                      </div>
                      <div style={{ display: 'flex', alignItems: 'center', gap: '0.4rem' }}>
                        <span style={{ display: 'inline-block', width: '8px', height: '8px', borderRadius: '50%', background: '#00FF88' }}></span>
                        <span>Разбаны: <strong>{selectedMod.unbans_count}</strong> ({Math.round((selectedMod.unbans_count / selectedMod.total_actions) * 100) || 0}%)</span>
                      </div>
                    </div>
                  </div>
                </div>
              )}
            </div>

          </div>
        </div>
      )}
    </div>
  );
}