/* === Design System === */
:root {
  /* Colors */
  --primary: #8B5CF6;
  --primary-hover: #7C3AED;
  --secondary: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --bg: #0F0F0F;
  --bg-card: #1A1A1A;
  --bg-hover: #252525;
  --text: #FFFFFF;
  --text-secondary: #9CA3AF;
  --border: #2A2A2A;
  
  /* Telegram colors */
  --tg-bg: var(--tg-theme-bg-color, #0F0F0F);
  --tg-text: var(--tg-theme-text-color, #FFFFFF);
  --tg-hint: var(--tg-theme-hint-color, #9CA3AF);
  --tg-button: var(--tg-theme-button-color, #8B5CF6);
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* === Reset & Base === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--tg-bg);
  color: var(--tg-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  padding-bottom: 80px; /* Space for bottom nav */
}

/* === Loading === */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
}

.loading.show {
  display: flex;
}

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

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

/* === Screens === */
.screen {
  display: none;
  padding: var(--spacing-md);
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

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

/* === Header === */
.screen-header {
  margin-bottom: var(--spacing-lg);
}

.screen-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

.screen-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

.card-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Progress Bar === */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: var(--spacing-sm);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* === Bot Card === */
.bot-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.bot-card:active {
  transform: scale(0.98);
  background: var(--bg-hover);
}

.bot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.bot-name {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.bot-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary);
}

.bot-status.stopped {
  background: var(--text-secondary);
}

.bot-username {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-xs);
}

.bot-info {
  display: flex;
  gap: var(--spacing-md);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
}

.bot-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
}

/* === Buttons === */
.btn {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.btn:active {
  transform: scale(0.96);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
  flex: 1;
}

.btn-full {
  width: 100%;
}

/* === Stats === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  border: 1px solid var(--border);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--spacing-xs);
  color: var(--text);
}

.empty-text {
  font-size: 14px;
  margin-bottom: var(--spacing-lg);
}

/* === Bottom Navigation === */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 var(--spacing-sm);
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--spacing-sm);
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-sm);
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn .icon {
  font-size: 24px;
}

.nav-btn .label {
  font-size: 11px;
  font-weight: 500;
}

/* === List === */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-sm);
  border: 1px solid var(--border);
}

.list-item-left {
  flex: 1;
}

.list-item-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 2px;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.list-item-value {
  font-size: 15px;
  font-weight: 600;
}

/* === Badge === */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--secondary);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

/* === Responsive === */
@media (max-width: 375px) {
  .screen-title {
    font-size: 24px;
  }
  
  .card-value {
    font-size: 28px;
  }
}
