/* ═══════════════════════════════════════════════════════
   MLP Telegram Forwarder – Dark Purple SaaS Theme
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-body:        #08080e;
  --bg-sidebar:     #0b0b14;
  --bg-card:        #111119;
  --bg-card-hover:  #16161f;
  --bg-input:       #0c0c15;
  --bg-overlay:     rgba(0,0,0,.55);

  --border:         #1c1c30;
  --border-light:   #24243d;
  --border-focus:   #7c3aed;

  --text-primary:   #e4e4ed;
  --text-secondary: #8888a0;
  --text-muted:     #55566a;

  --accent:         #8b5cf6;
  --accent-hover:   #a78bfa;
  --accent-dim:     rgba(139,92,246,.12);
  --accent-glow:    rgba(139,92,246,.35);

  --success:        #22c55e;
  --success-dim:    rgba(34,197,94,.12);
  --error:          #ef4444;
  --error-dim:      rgba(239,68,68,.12);
  --warning:        #f59e0b;
  --warning-dim:    rgba(245,158,11,.12);
  --info:           #3b82f6;
  --info-dim:       rgba(59,130,246,.12);

  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --sidebar-w:      260px;
  --transition:     .2s ease;
}

/* ── Reset ───────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent);
  color: #fff;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ══════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════ */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(139,92,246,.08) 0%, transparent 60%),
    var(--bg-body);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 48px 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  animation: fadeUp .5s ease;
}

.auth-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 24px var(--accent-glow));
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-sub {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: .95rem;
}

.auth-card .input {
  margin-bottom: 12px;
}

.auth-error {
  color: var(--error);
  font-size: .85rem;
  margin-top: 14px;
  min-height: 1.2em;
}

/* ══════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ══════════════════════════════════════════════════════ */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.sidebar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: .7;
}
.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 12px 10px 20px;
  border-top: 1px solid var(--border);
}

/* ── Mobile Header ───────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 90;
}

.mobile-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.hamburger {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 4px;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

/* ── Main Content ────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  min-height: 100vh;
  max-width: 1100px;
}

/* ══════════════════════════════════════════════════════
   PAGES
   ══════════════════════════════════════════════════════ */
.page { display: none; animation: fadeUp .35s ease; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.purple { background: var(--accent-dim); color: var(--accent); }
.stat-icon.red    { background: var(--error-dim);   color: var(--error); }
.stat-icon.green  { background: var(--success-dim); color: var(--success); }
.stat-icon.blue   { background: var(--info-dim);    color: var(--info); }

.stat-info {
  display: flex;
  flex-direction: column;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  transition: all var(--transition);
}
.card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
}

.card-header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.card-header .text-muted {
  display: block;
  font-size: .8rem;
  margin-top: 3px;
}

.card-body {
  padding: 20px 24px;
}

/* ══════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════ */
.input, .select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .92rem;
  transition: all var(--transition);
  outline: none;
}

.input::placeholder { color: var(--text-muted); }

.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 16px var(--accent-glow);
}

.input-sm { max-width: 140px; }

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238888a0' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  max-width: 220px;
}

.label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.flex-1 { flex: 1; min-width: 0; }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ══════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  box-shadow: 0 2px 12px rgba(139,92,246,.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  box-shadow: 0 4px 20px rgba(139,92,246,.4);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239,68,68,.2);
}
.btn-danger:hover {
  box-shadow: 0 4px 20px rgba(239,68,68,.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--accent-dim);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ══════════════════════════════════════════════════════
   TOGGLE SWITCH
   ══════════════════════════════════════════════════════ */
.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 999px;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* ══════════════════════════════════════════════════════
   SETTINGS ROWS
   ══════════════════════════════════════════════════════ */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.setting-info { flex: 1; }
.setting-label {
  font-weight: 500;
  font-size: .95rem;
}
.setting-desc {
  display: block;
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ══════════════════════════════════════════════════════
   STATUS BADGE
   ══════════════════════════════════════════════════════ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.status-badge::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-badge.online {
  background: var(--success-dim);
  color: var(--success);
}
.status-badge.online::before {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

.status-badge.offline {
  background: var(--error-dim);
  color: var(--error);
}
.status-badge.offline::before {
  background: var(--error);
}

/* ══════════════════════════════════════════════════════
   TARGETS LIST
   ══════════════════════════════════════════════════════ */
.targets-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.target-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.target-item:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.target-item .target-info {
  display: flex;
  flex-direction: column;
}
.target-item .target-name {
  font-weight: 500;
  font-size: .92rem;
}
.target-item .target-id {
  font-size: .78rem;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
}

.target-remove {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--error-dim);
  color: var(--error);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.target-remove:hover {
  background: var(--error);
  color: #fff;
  transform: scale(1.05);
}

/* ══════════════════════════════════════════════════════
   LOGS
   ══════════════════════════════════════════════════════ */
.logs-body {
  max-height: 500px;
  overflow-y: auto;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  animation: fadeUp .25s ease;
}
.log-entry:last-child { border-bottom: none; }

.log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.log-dot.success  { background: var(--success); }
.log-dot.error    { background: var(--error); }
.log-dot.info     { background: var(--info); }
.log-dot.filtered { background: var(--warning); }

.log-text { flex: 1; color: var(--text-secondary); }

.log-time {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: 'Courier New', monospace;
}

/* bot info */
.bot-info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: .9rem;
}
.bot-info-grid .info-label {
  color: var(--text-muted);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════ */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.mt-sm { margin-top: 8px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  animation: slideIn .3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-width: 380px;
}

.toast.success {
  background: #0d3320;
  border: 1px solid #166534;
  color: var(--success);
}
.toast.error {
  background: #3b1111;
  border: 1px solid #7f1d1d;
  color: var(--error);
}
.toast.info {
  background: #0c1a3d;
  border: 1px solid #1e3a5f;
  color: var(--info);
}

/* ══════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.5);
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 72px 16px 24px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .form-row {
    flex-direction: column;
  }

  .setting-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

@media (max-width: 440px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
}

/* backdrop for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }
