/* ============================================
   Obuna Bot Admin Panel — Zamonaviy qorong'i tema
   ============================================ */

/* ------- RESET & VARS ------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --bg-input: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --border-color: #334155;
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.3);
  --transition: .2s ease;
}

html { font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

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

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

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

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

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.user-info {
  margin-top: .5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.user-name {
  font-size: .9rem;
  color: var(--text-secondary);
}

.nav-links {
  list-style: none;
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-links li a {
  display: block;
  padding: .75rem 1.5rem;
  color: var(--text-secondary);
  font-size: .95rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-links li a:hover,
.nav-links li.active a {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
  border-left-color: var(--accent-blue);
}

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

/* ------- CONTENT ------- */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-height: 100vh;
}

.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem; left: 1rem;
  z-index: 200;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-size: 1.5rem;
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ------- PAGE HEADER ------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

/* ------- BADGES ------- */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: .02em;
}
.badge-gold   { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-blue   { background: rgba(59,130,246,.15);  color: #3b82f6; }
.badge-green  { background: rgba(16,185,129,.15);  color: #10b981; }
.badge-yellow { background: rgba(245,158,11,.15);  color: #f59e0b; }
.badge-red    { background: rgba(239,68,68,.15);   color: #ef4444; }
.badge-gray   { background: rgba(100,116,139,.15); color: #94a3b8; }

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

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--border-color);
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-icon { font-size: 2.2rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--text-secondary); font-size: .85rem; }
.stat-sub   { color: var(--text-muted); font-size: .78rem; margin-top: .25rem; }

.stat-blue   { border-left: 4px solid var(--accent-blue); }
.stat-green  { border-left: 4px solid var(--accent-green); }
.stat-yellow { border-left: 4px solid var(--accent-yellow); }
.stat-purple { border-left: 4px solid var(--accent-purple); }

/* ------- CHARTS ------- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

/* ------- TABLES ------- */
.table-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: .85rem 1rem;
  text-align: left;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: rgba(255,255,255,.02);
}

.data-table td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: .9rem;
}

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

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.text-center { text-align: center; }

.actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ------- DETAIL PAGE ------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.detail-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.detail-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.detail-items { display: flex; flex-direction: column; gap: .5rem; }
.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .4rem 0;
  border-bottom: 1px dashed var(--border-color);
}
.detail-item:last-child { border-bottom: none; }
.detail-item span { color: var(--text-secondary); font-size: .9rem; }
.detail-item strong { color: var(--text-primary); }
.detail-item pre {
  background: var(--bg-dark);
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  white-space: pre-wrap;
  max-width: 300px;
}

/* ------- BUTTONS ------- */
.btn {
  display: inline-block;
  padding: .5rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .9rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  text-align: center;
  line-height: 1.5;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary  { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #2563eb; }

.btn-success  { background: var(--accent-green); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger   { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #dc2626; }

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

.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-full { width: 100%; }

/* ------- FORMS ------- */
.form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.form-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.form-inline {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  flex: 1;
  min-width: 150px;
}

.form-group label {
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: .6rem .8rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .9rem;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ------- FILTERS ------- */
.filters {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ------- PAGINATION ------- */
.pagination {
  display: flex;
  gap: .4rem;
  justify-content: center;
  padding: 1rem 0;
}

/* ------- ALERTS ------- */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error   { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(16,185,129,.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }

/* ------- LOGIN PAGE ------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-container { width: 100%; max-width: 420px; padding: 1rem; }

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo { font-size: 3.5rem; margin-bottom: .5rem; }
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.login-subtitle { color: var(--text-muted); margin-bottom: 1.5rem; }

.login-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .75rem;
}

/* Login tabs */
.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: .65rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

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

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

#tab-telegram {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ------- ERROR PAGE ------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.error-icon { font-size: 4rem; margin-bottom: 1rem; }
.error-page h1 { font-size: 2rem; margin-bottom: .5rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

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

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

  .content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 3.5rem;
  }

  .mobile-menu-btn {
    display: block;
  }

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

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

  .form-inline {
    flex-direction: column;
  }

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  html { font-size: 14px; }

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

  .login-card {
    padding: 1.5rem;
  }

  .data-table th:nth-child(n+4),
  .data-table td:nth-child(n+4) {
    display: none;
  }
}
