/* ═══════════════════════════════════════════════════════════════
   TeamAnalytics – Premium Dark Theme
   CFMOTO Team WhatsApp Grup Analiz Paneli
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── CSS Değişkenleri ───────────────────────────────────────── */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1f2a40;
  --bg-sidebar: #0d1321;
  --bg-input: #1e293b;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #f97316;
  --accent-hover: #fb923c;
  --accent-glow: rgba(249, 115, 22, 0.3);
  --accent-subtle: rgba(249, 115, 22, 0.1);

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #eab308;
  --warning-bg: rgba(234, 179, 8, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);

  --border: #1e293b;
  --border-light: #334155;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(249, 115, 22, 0.15);

  --sidebar-width: 260px;
  --header-height: 70px;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--accent-hover);
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(249, 115, 22, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -2%) rotate(1deg); }
  66% { transform: translate(-1%, 1%) rotate(-1deg); }
}

.login-container {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem;
}

.login-logo {
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #fb923c, #fbbf24);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

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

.qr-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 400px;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

.qr-display {
  width: 264px;
  height: 264px;
  margin: 0 auto 1.5rem;
  background: white;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.qr-display img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-display .qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
}

.qr-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.status-badge.initializing {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status-badge.qr {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.status-badge.ready {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-badge.disconnected,
.status-badge.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
}

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

.login-instructions {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.login-instructions h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
}

.login-instructions ol {
  text-align: left;
  list-style: none;
  counter-reset: step;
}

.login-instructions ol li {
  counter-increment: step;
  padding: 0.4rem 0;
  padding-left: 2rem;
  position: relative;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.login-instructions ol li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 22px;
  height: 22px;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT: SIDEBAR + MAIN
   ═══════════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

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

.sidebar-header h1 {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-header .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}

.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.nav-link .nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 0.8rem;
}

.connection-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.connection-status .dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

.connection-status .dot.offline {
  background: var(--danger);
}

.connection-status .dot.loading {
  background: var(--warning);
  animation: pulse 1s ease-in-out infinite;
}

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.page-header {
  padding: 1.8rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.page-body {
  padding: 2rem;
}

/* ─── Mobile Sidebar Toggle ──────────────────────────────────── */
.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4);
  transition: var(--transition);
}

.mobile-toggle:hover {
  transform: scale(1.1);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ═══════════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.stat-card .stat-icon {
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
}

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

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  font-weight: 500;
}

.stat-card.orange { --card-accent: #f97316; }
.stat-card.blue { --card-accent: #3b82f6; }
.stat-card.green { --card-accent: #22c55e; }
.stat-card.purple { --card-accent: #8b5cf6; }

.stat-card.orange::after { background: linear-gradient(90deg, #f97316, #fb923c); }
.stat-card.blue::after { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.stat-card.green::after { background: linear-gradient(90deg, #22c55e, #4ade80); }
.stat-card.purple::after { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }

/* ═══════════════════════════════════════════════════════════════
   CONTENT CARDS
   ═══════════════════════════════════════════════════════════════ */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.content-card:hover {
  border-color: var(--border-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.25rem 1.5rem;
}

.card-body.no-pad {
  padding: 0;
}

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

.data-table thead th {
  padding: 0.8rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table tbody td {
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.data-table tbody td:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ─── Table Full Width Card ──────────────────────────────────── */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-card .data-table thead th {
  background: var(--bg-card);
}

/* ═══════════════════════════════════════════════════════════════
   LISTS
   ═══════════════════════════════════════════════════════════════ */
.rank-list {
  list-style: none;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.rank-item:last-child {
  border-bottom: none;
}

.rank-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.rank-number.gold { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.rank-number.silver { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.rank-number.bronze { background: rgba(217, 119, 6, 0.15); color: #d97706; }

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

.rank-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.rank-value {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════ */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

/* ═══════════════════════════════════════════════════════════════
   TOGGLE SWITCH
   ═══════════════════════════════════════════════════════════════ */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 12px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 3px;
  left: 3px;
  transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge.active {
  background: var(--success-bg);
  color: var(--success);
}

.badge.inactive {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.multi-group {
  background: rgba(139, 92, 246, 0.12);
  color: #a78bfa;
}

.badge.count {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(249, 115, 22, 0.3);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* ═══════════════════════════════════════════════════════════════
   LIVE FEED
   ═══════════════════════════════════════════════════════════════ */
.live-feed {
  max-height: 300px;
  overflow-y: auto;
}

.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  animation: feedIn 0.3s ease-out;
}

@keyframes feedIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.4rem;
  flex-shrink: 0;
}

.feed-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.feed-text strong {
  color: var(--text-primary);
}

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

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

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

.empty-state h4 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

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

/* ═══════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.6rem 1.2rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.tab-btn.active {
  background: var(--accent);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .page-body {
    padding: 1.25rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-header {
    padding: 1.25rem 1.5rem;
  }

  .page-header h2 {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .qr-card {
    padding: 1.5rem;
  }

  .qr-display {
    width: 220px;
    height: 220px;
  }
}
