@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 35, 0.8);
  --bg-card-hover: rgba(30, 30, 50, 0.9);
  --bg-input: rgba(15, 15, 25, 0.9);
  --border: rgba(100, 100, 255, 0.1);
  --border-focus: rgba(0, 230, 255, 0.4);
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555570;
  --accent-cyan: #00e6ff;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --accent-green: #22c55e;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
  --gradient-main: linear-gradient(135deg, #00e6ff, #a855f7);
  --gradient-card: linear-gradient(135deg, rgba(0,230,255,0.05), rgba(168,85,247,0.05));
  --shadow-glow: 0 0 20px rgba(0, 230, 255, 0.15);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, sans-serif;
}

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

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

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(0,230,255,0.03) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(168,85,247,0.03) 0%, transparent 50%);
  z-index: -1;
  animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, -2%); }
}

/* ===================== LOGIN PAGE ===================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  animation: fadeInUp 0.6s ease-out;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 8px;
}

/* ===================== FORMS ===================== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0, 230, 255, 0.1);
}

.form-input::placeholder { color: var(--text-muted); }

textarea.form-input {
  min-height: 100px;
  resize: vertical;
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-main);
  color: #0a0a0f;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 230, 255, 0.3);
}

.btn-secondary {
  background: rgba(100, 100, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(100, 100, 255, 0.2);
}

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

.error-msg {
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}

/* ===================== APP LAYOUT ===================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand h2 {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand span {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-section {
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 8px 12px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: pointer;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(100, 100, 255, 0.08);
}

.nav-link.active {
  color: var(--accent-cyan);
  background: rgba(0, 230, 255, 0.08);
  border-left: 3px solid var(--accent-cyan);
}

.nav-link .nav-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.main-content {
  margin-left: 260px;
  width: calc(100% - 260px);
  padding: 32px;
  min-height: 100vh;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ===================== PAGE HEADER ===================== */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===================== STATS CARDS ===================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 230, 255, 0.2);
  box-shadow: var(--shadow-glow);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-main);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover::before { opacity: 1; }

.stat-card .stat-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.stat-card.purple .stat-value { color: var(--accent-purple); }
.stat-card.green .stat-value { color: var(--accent-green); }
.stat-card.orange .stat-value { color: var(--accent-orange); }
.stat-card.pink .stat-value { color: var(--accent-pink); }

/* ===================== CARDS ===================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-cyan { background: rgba(0,230,255,0.1); color: var(--accent-cyan); }
.badge-green { background: rgba(34,197,94,0.1); color: var(--accent-green); }
.badge-purple { background: rgba(168,85,247,0.1); color: var(--accent-purple); }
.badge-red { background: rgba(239,68,68,0.1); color: var(--accent-red); }

/* ===================== GRID LAYOUTS ===================== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}

/* ===================== CHART ===================== */
.chart-container {
  position: relative;
  height: 250px;
  width: 100%;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===================== TABLE ===================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.data-table td { font-size: 0.9rem; }

.data-table tr:hover td {
  background: rgba(100, 100, 255, 0.04);
}

.data-table .rank-1 { color: #ffd700; font-weight: 700; }
.data-table .rank-2 { color: #c0c0c0; font-weight: 700; }
.data-table .rank-3 { color: #cd7f32; font-weight: 700; }

/* ===================== CONVERSATION LIST ===================== */
.convo-list {
  list-style: none;
}

.convo-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.convo-item:hover {
  background: rgba(100, 100, 255, 0.05);
}

.convo-item.active {
  background: rgba(0, 230, 255, 0.06);
  border-left: 3px solid var(--accent-cyan);
}

.convo-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #0a0a0f;
  flex-shrink: 0;
}

.convo-avatar.group { border-radius: var(--radius-sm); }

.convo-info { flex: 1; min-width: 0; }

.convo-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.convo-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.convo-unread {
  background: var(--accent-cyan);
  color: #0a0a0f;
  font-size: 0.7rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================== MESSAGES ===================== */
.messages-container {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - 140px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.messages-sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}

.messages-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.messages-sidebar-list {
  flex: 1;
  overflow-y: auto;
}

.messages-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.messages-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  gap: 12px;
}

.messages-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-bubble {
  max-width: 65%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  animation: fadeIn 0.3s ease;
}

.message-bubble.incoming {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-bubble.outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0,230,255,0.15), rgba(168,85,247,0.15));
  border: 1px solid rgba(0,230,255,0.2);
  border-bottom-right-radius: 4px;
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.no-selection {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ===================== RANKING ===================== */
.ranking-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

.ranking-card:hover {
  border-color: rgba(0, 230, 255, 0.2);
}

.ranking-position {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.ranking-position.gold { background: rgba(255,215,0,0.15); color: #ffd700; }
.ranking-position.silver { background: rgba(192,192,192,0.15); color: #c0c0c0; }
.ranking-position.bronze { background: rgba(205,127,50,0.15); color: #cd7f32; }
.ranking-position.normal { background: rgba(100,100,255,0.1); color: var(--text-secondary); }

.ranking-info { flex: 1; }
.ranking-name { font-weight: 600; font-size: 0.95rem; }
.ranking-stats { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.ranking-value { font-size: 1.2rem; font-weight: 700; color: var(--accent-cyan); }

/* ===================== STATUS INDICATORS ===================== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.online { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-dot.offline { background: var(--accent-red); }
.status-dot.connecting { background: var(--accent-orange); animation: pulse 1.5s infinite; }

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

/* ===================== SETTINGS SECTIONS ===================== */
.settings-section {
  margin-bottom: 32px;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.status-card .status-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-card .status-value {
  font-size: 0.95rem;
  font-weight: 600;
}

/* ===================== EMPTY STATES ===================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
}

/* ===================== SEARCH ===================== */
.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--border-focus);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  opacity: 0.5;
}

/* ===================== LOADING ===================== */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text-secondary);
}

/* ===================== ANIMATIONS ===================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.fade-in { animation: fadeIn 0.4s ease-out; }
.fade-in-up { animation: fadeInUp 0.5s ease-out; }

/* ===================== LIVE INDICATOR ===================== */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
}

.live-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font-size: 0.9rem;
  z-index: 1000;
  animation: fadeInUp 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(100, 100, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(100, 100, 255, 0.3); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    transform: translateX(-100%);
    transition: var(--transition);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .messages-container { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
