/* =========================================================
   HTG TELEGRAM BOT — 24/7 Bot Hosting Platform
   Next-Gen Dual Theme Engine (Light & Dark)
   Responsive App Shell with Collapsible Sidebar & Mobile Drawer
   ========================================================= */

/* --- DARK THEME (Default) --- */
:root, [data-theme="dark"] {
  --theme-name: 'dark';

  /* Base Surfaces */
  --bg-main: #07090e;
  --bg-surface: #0c101b;
  --bg-sidebar: #090d17;
  --bg-card: rgba(14, 20, 32, 0.78);
  --bg-card-hover: rgba(20, 28, 46, 0.88);
  --bg-input: #0a0e18;
  --bg-input-focus: #0f1524;
  --bg-darker: #05070a;
  --bg-toolbar: #090e17;
  --bg-modal: #0d131f;
  --bg-terminal: #030508;
  --bg-editor: #05070c;
  
  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(0, 240, 255, 0.6);
  --border-accent: rgba(139, 92, 246, 0.4);

  /* Typography */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-contrast: #ffffff;
  --text-inverse: #030712;

  /* Brand Accents */
  --accent-cyan: #00f0ff;
  --accent-telegram: #229ed9;
  --accent-telegram-hover: #2cb5f6;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-indigo: #6366f1;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #00f0ff 0%, #229ed9 40%, #8b5cf6 100%);
  --gradient-telegram: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
  --gradient-discord: linear-gradient(135deg, #5865F2 0%, #4752C4 100%);
  --gradient-ai: linear-gradient(135deg, #8B5CF6 0%, #EC4899 100%);
  --gradient-primary: linear-gradient(135deg, #00d4ff, #0088ff);
  --gradient-primary-hover: linear-gradient(135deg, #38e1ff, #1a9aff);
  --gradient-purple: linear-gradient(135deg, #8b5cf6, #6366f1);
  --gradient-success: linear-gradient(135deg, #10b981, #059669);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
  --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);

  /* Glow & Shadows */
  --shadow-glow-cyan: 0 0 25px rgba(0, 240, 255, 0.2);
  --shadow-glow-telegram: 0 0 25px rgba(34, 158, 217, 0.3);
  --shadow-glow-purple: 0 0 25px rgba(139, 92, 246, 0.2);
  --shadow-card: 0 12px 32px -4px rgba(0, 0, 0, 0.55), 0 4px 12px -2px rgba(0, 0, 0, 0.3);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  --shadow-dropdown: 0 12px 28px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);

  /* Background Ambient FX */
  --ambient-grad-1: radial-gradient(circle at 15% 15%, rgba(34, 158, 217, 0.12) 0%, transparent 45%);
  --ambient-grad-2: radial-gradient(circle at 85% 85%, rgba(0, 240, 255, 0.09) 0%, transparent 45%);
  --ambient-grad-3: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 65%);

  /* Navigation & Sidebar */
  --navbar-bg: rgba(7, 9, 14, 0.88);
  --navbar-border: rgba(255, 255, 255, 0.07);
  --sidebar-border: rgba(255, 255, 255, 0.07);

  /* Toggle Switch */
  --toggle-bg: #141b2b;
  --toggle-thumb: #00f0ff;
  --toggle-thumb-text: #05070a;
  --toggle-border: rgba(0, 240, 255, 0.3);
}

/* --- LIGHT THEME --- */
[data-theme="light"] {
  --theme-name: 'light';

  /* Base Surfaces */
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(248, 250, 252, 0.98);
  --bg-input: #ffffff;
  --bg-input-focus: #ffffff;
  --bg-darker: #f1f5f9;
  --bg-toolbar: #f8fafc;
  --bg-modal: #ffffff;
  --bg-terminal: #0b101c;
  --bg-editor: #ffffff;

  /* Borders & Dividers */
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #0284c7;
  --border-accent: #7c3aed;

  /* Typography */
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --text-contrast: #0f172a;
  --text-inverse: #ffffff;

  /* Brand Accents */
  --accent-cyan: #0284c7;
  --accent-telegram: #0284c7;
  --accent-telegram-hover: #0369a1;
  --accent-purple: #7c3aed;
  --accent-blue: #2563eb;
  --accent-green: #059669;
  --accent-amber: #d97706;
  --accent-red: #dc2626;
  --accent-indigo: #4f46e5;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #7c3aed 100%);
  --gradient-telegram: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --gradient-discord: linear-gradient(135deg, #5865F2 0%, #4752C4 100%);
  --gradient-ai: linear-gradient(135deg, #7C3AED 0%, #DB2777 100%);
  --gradient-primary: linear-gradient(135deg, #0284c7, #2563eb);
  --gradient-primary-hover: linear-gradient(135deg, #0369a1, #1d4ed8);
  --gradient-purple: linear-gradient(135deg, #7c3aed, #4f46e5);
  --gradient-success: linear-gradient(135deg, #059669, #047857);
  --gradient-warning: linear-gradient(135deg, #d97706, #b45309);
  --gradient-danger: linear-gradient(135deg, #dc2626, #b91c1c);

  /* Glow & Shadows */
  --shadow-glow-cyan: 0 0 20px rgba(2, 132, 199, 0.15);
  --shadow-glow-telegram: 0 0 20px rgba(2, 132, 199, 0.15);
  --shadow-glow-purple: 0 0 20px rgba(124, 58, 237, 0.15);
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-modal: 0 20px 40px -8px rgba(15, 23, 42, 0.2), 0 0 0 1px #e2e8f0;
  --shadow-dropdown: 0 12px 30px rgba(15, 23, 42, 0.12), 0 0 0 1px #e2e8f0;

  /* Background Ambient FX */
  --ambient-grad-1: radial-gradient(circle at 15% 15%, rgba(2, 132, 199, 0.05) 0%, transparent 40%);
  --ambient-grad-2: radial-gradient(circle at 85% 85%, rgba(124, 58, 237, 0.05) 0%, transparent 40%);
  --ambient-grad-3: radial-gradient(circle at 50% 50%, rgba(5, 150, 105, 0.02) 0%, transparent 60%);

  /* Navigation & Sidebar */
  --navbar-bg: rgba(255, 255, 255, 0.9);
  --navbar-border: #e2e8f0;
  --sidebar-border: #e2e8f0;

  /* Toggle Switch */
  --toggle-bg: #e2e8f0;
  --toggle-thumb: #ffffff;
  --toggle-thumb-text: #f59e0b;
  --toggle-border: #cbd5e1;
}

/* --- CORE RESET & BASE --- */
:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --radius-full: 9999px;

  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --navbar-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-main);
  background-image: var(--ambient-grad-1), var(--ambient-grad-2), var(--ambient-grad-3);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* Typography Helpers */
h1, h2, h3, h4, h5, h6, .brand-title, .section-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-contrast);
}

.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.text-muted { color: var(--text-muted) !important; }
.text-dim { color: var(--text-dim) !important; }
.text-success { color: var(--accent-green) !important; }
.text-warning { color: var(--accent-amber) !important; }
.text-danger { color: var(--accent-red) !important; }
.text-primary { color: var(--accent-cyan) !important; }
.text-purple { color: var(--accent-purple) !important; }
.text-contrast { color: var(--text-contrast) !important; }

.font-bold { font-weight: 700; }
.font-sm { font-size: 0.875rem; }
.font-xs { font-size: 0.75rem; }
.font-lg { font-size: 1.25rem; }
.font-mono { font-family: var(--font-mono); }
.cursor-pointer { cursor: pointer; }
.flex-1 { flex: 1; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.35rem; }
.gap-2 { gap: 0.65rem; }
.gap-3 { gap: 0.95rem; }
.gap-4 { gap: 1.25rem; }
.w-100 { width: 100%; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.rounded { border-radius: var(--radius-md); }
.bg-darker { background: var(--bg-darker); }

/* --- APP LAYOUT STRUCTURE --- */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

.app-body-container {
  display: flex;
  flex: 1;
  position: relative;
  width: 100%;
}

/* --- GLOBAL TOP NAVBAR --- */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--navbar-height);
  padding: 0 1.5rem;
  background: var(--navbar-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--navbar-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Mobile Hamburger Menu Toggle Button */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-contrast);
  width: 38px;
  height: 38px;
  font-size: 1.15rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-medium);
  color: var(--accent-cyan);
}

/* Desktop Sidebar Toggle Button */
.sidebar-toggle-btn {
  display: flex;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-card);
  color: var(--accent-cyan);
  border-color: var(--border-medium);
}

/* Brand Logo */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  position: relative;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, rgba(34, 158, 217, 0.25), rgba(0, 240, 255, 0.15));
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  font-size: 1.25rem;
  box-shadow: var(--shadow-glow-telegram);
  transition: transform 0.2s ease;
}

.brand-telegram-icon {
  color: #229ED9;
  transform: rotate(-10deg);
}

.nav-brand:hover .brand-logo {
  transform: scale(1.06) rotate(3deg);
}

.pulse-indicator {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-green);
  animation: pulseGreen 2s infinite;
}

.pulse-indicator-mini {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  margin-right: 4px;
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  color: var(--text-contrast);
  line-height: 1.15;
}

.brand-accent {
  color: var(--accent-cyan);
}

.brand-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-telegram);
  font-family: var(--font-mono);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.theme-toggle-btn:hover {
  border-color: var(--border-medium);
  background: var(--bg-card);
}

.theme-toggle-track {
  width: 32px;
  height: 18px;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  border-radius: var(--radius-full);
  position: relative;
  display: flex;
  align-items: center;
  padding: 2px;
}

.theme-toggle-thumb {
  width: 14px;
  height: 14px;
  background: var(--toggle-thumb);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: var(--toggle-thumb-text);
  transition: transform 0.2s ease;
}

[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(12px);
}

.theme-toggle-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* User Profile Button & Dropdown */
.user-dropdown {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-profile-btn:hover {
  border-color: var(--border-medium);
  background: var(--bg-card);
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-telegram);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.username-label {
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: var(--bg-modal);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: 0.5rem;
  z-index: 1100;
  animation: fadeIn 0.15s ease;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-header {
  padding: 0.6rem 0.75rem;
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 0.4rem 0;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.dropdown-item:hover {
  background: var(--bg-card);
  color: var(--accent-cyan);
}

.dropdown-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* --- APP SIDEBAR NAVIGATION --- */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 900;
  height: calc(100vh - var(--navbar-height));
  position: sticky;
  top: var(--navbar-height);
}

/* Sidebar Collapsed State (Desktop) */
.app-sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.app-sidebar.collapsed .sidebar-group-title,
.app-sidebar.collapsed .nav-item-text,
.app-sidebar.collapsed .nav-item-badge,
.app-sidebar.collapsed .sidebar-plan-widget,
.app-sidebar.collapsed .status-text,
.app-sidebar.collapsed .sidebar-empty-bots {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 0.75rem;
}

.sidebar-header {
  display: none; /* Only visible in mobile drawer */
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  justify-content: space-between;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-logo-mini {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--gradient-telegram);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-contrast);
  font-size: 1.1rem;
}

.sidebar-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.sidebar-close-btn:hover {
  background: var(--bg-card);
  color: var(--text-contrast);
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sidebar-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0.35rem 0.65rem;
  font-family: var(--font-mono);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  width: 100%;
  text-align: left;
}

.sidebar-nav-item:hover {
  background: var(--bg-card);
  color: var(--text-contrast);
  border-color: var(--border-subtle);
}

.sidebar-nav-item.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.12), rgba(34, 158, 217, 0.18));
  border-color: rgba(0, 240, 255, 0.35);
  color: var(--accent-cyan);
}

[data-theme="light"] .sidebar-nav-item.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.1), rgba(37, 99, 235, 0.12));
  border-color: rgba(2, 132, 199, 0.35);
  color: #0284c7;
}

.nav-item-icon {
  font-size: 1.05rem;
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-badge {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.sidebar-bots-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-bot-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
}

.sidebar-bot-link:hover {
  background: var(--bg-card);
  color: var(--text-contrast);
}

.sidebar-bot-link.active {
  background: var(--bg-card-hover);
  color: var(--accent-cyan);
}

/* Sidebar Subscription Widget */
.sidebar-plan-widget {
  background: linear-gradient(145deg, rgba(20, 28, 46, 0.75), rgba(12, 16, 27, 0.9));
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-top: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .sidebar-plan-widget {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.plan-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.plan-widget-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-contrast);
}

.plan-widget-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-contrast);
}

.plan-widget-expiry {
  font-size: 0.75rem;
  color: var(--accent-amber);
  margin-bottom: 0.65rem;
}

.plan-slots-bar-wrapper {
  margin-top: 0.4rem;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg-darker);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

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

.sidebar-system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.status-dot-pulse {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulseGreen 2s infinite;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* --- MAIN CONTENT CONTAINER --- */
.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  transition: all 0.25s ease;
}

.view-panel {
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.center-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
}

/* --- HERO SECTION (Landing) --- */
.hero-section {
  text-align: center;
  max-width: 900px;
  margin: 2rem auto 4rem;
  padding: 1rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.95rem;
  background: rgba(34, 158, 217, 0.12);
  border: 1px solid rgba(34, 158, 217, 0.35);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-telegram);
  margin-bottom: 1.5rem;
}

.badge-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.hero-title {
  font-size: 3.25rem;
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 760px;
  margin: 0 auto 2.5rem;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 1.15rem;
  flex-wrap: wrap;
  margin-bottom: 4rem;
}

/* Feature Highlights Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.35rem;
  text-align: left;
}

.feature-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.65rem;
  transition: all 0.25s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-medium);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card);
}

.feature-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1.15rem;
}

.telegram-icon { background: rgba(34, 158, 217, 0.18); color: #229ED9; }
.python-icon { background: rgba(0, 240, 255, 0.15); color: #00f0ff; }
.node-icon { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.sqlite-icon { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

.feature-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- ALERT BANNERS --- */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  gap: 1.25rem;
  box-shadow: var(--shadow-card);
}

.alert-danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(185, 28, 28, 0.22));
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.alert-danger h4 { color: #ffffff; margin-bottom: 0.25rem; font-size: 1rem; }
.alert-danger p { color: #fca5a5; font-size: 0.85rem; }

.alert-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.22));
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fef3c7;
}

.alert-warning h4 { color: #ffffff; margin-bottom: 0.25rem; font-size: 1rem; }
.alert-warning p { color: #fde68a; font-size: 0.85rem; }

.alert-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
}

/* --- DASHBOARD STATS GRID --- */
.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

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

.stat-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 0.85rem;
}

.telegram-icon-bg { background: rgba(34, 158, 217, 0.18); color: #229ED9; }
.active-icon-bg { background: rgba(16, 185, 129, 0.18); color: #10b981; }
.ram-icon-bg { background: rgba(0, 240, 255, 0.15); color: #00f0ff; }
.plan-icon-bg { background: rgba(245, 158, 11, 0.18); color: #f59e0b; }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: clamp(1.2rem, 1.7vw, 1.55rem);
  font-weight: 800;
  color: var(--text-contrast);
  font-family: var(--font-display);
  line-height: 1.2;
  word-break: normal;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.35;
}

.stat-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-darker);
  border-radius: var(--radius-full);
  margin-top: 0.85rem;
  overflow: hidden;
}

.stat-progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* --- SECTION HEADERS --- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.35rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.55rem;
  margin-bottom: 0.25rem;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* --- DASHBOARD FILTER & SEARCH TOOLBAR --- */
.bots-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.bots-search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
}

.bots-search-box .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.85rem;
  pointer-events: none;
}

.bots-search-input {
  padding-left: 2.3rem !important;
  padding-right: 2rem !important;
  border-radius: var(--radius-full) !important;
  height: 38px;
}

.search-clear-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
}

.search-clear-btn:hover {
  color: var(--text-contrast);
}

.bots-filter-pills, .template-filter-pills {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

/* Filter Pills (Interactive, Accessible, High Contrast) */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  white-space: nowrap;
}

.filter-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-contrast);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.filter-pill.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.16), rgba(34, 158, 217, 0.22));
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 2px 10px rgba(0, 240, 255, 0.18);
}

[data-theme="light"] .filter-pill.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.12), rgba(37, 99, 235, 0.16));
  border-color: #0284c7;
  color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
}

/* --- BOTS GRID & BOT CARDS --- */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.35rem;
}

.bot-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.45rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.bot-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
  background: var(--bg-card-hover);
}

.bot-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.15rem;
  gap: 0.75rem;
}

.bot-type-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.bot-type-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Bot Category Specific Styling */
.telegram-bg { background: var(--gradient-telegram); color: #ffffff; }
.discord-bg { background: var(--gradient-discord); color: #ffffff; }
.ai-bg { background: var(--gradient-ai); color: #ffffff; }
.custom-bg { background: linear-gradient(135deg, #10B981 0%, #059669 100%); color: #ffffff; }
.python-bg { background: linear-gradient(135deg, #00d4ff 0%, #0088ff 100%); color: #ffffff; }
.node-bg { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #ffffff; }

.bot-name {
  font-size: 1.15rem;
  color: var(--text-contrast);
  margin-bottom: 0.2rem;
  word-break: break-word;
}

.bot-runtime-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.bot-card-body {
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.bot-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.bot-card-actions {
  display: flex;
  gap: 0.65rem;
}

/* --- EMPTY STATES --- */
.empty-state-card {
  background: var(--bg-card);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 4rem 2rem;
  text-align: center;
  max-width: 540px;
  margin: 3rem auto;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(34, 158, 217, 0.12);
  color: #229ED9;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.empty-state-card h3 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}

.empty-state-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- BOT STUDIO VIEW --- */
.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 1.35rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.studio-title-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.studio-bot-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--gradient-telegram);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.studio-bot-name {
  font-size: 1.4rem;
  color: var(--text-contrast);
}

.studio-bot-sub {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 0.2rem;
}

.studio-action-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* Studio Tabs Bar (Touch Friendly & Responsive) */
.studio-tabs-bar {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.35rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.15rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-card);
}

.studio-tab-content {
  display: none;
}

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

/* Console & Terminal */
.console-wrapper {
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.console-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-subtle);
}

.console-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.775rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.console-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.console-dot.connected {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.console-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.terminal-screen {
  padding: 1rem 1.25rem;
  height: 480px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  line-height: 1.5;
  color: #d1d5db;
}

.terminal-line {
  margin-bottom: 0.2rem;
  word-break: break-all;
  white-space: pre-wrap;
}

.terminal-line.system { color: var(--accent-cyan); }
.terminal-line.stderr { color: #f87171; }
.terminal-line.stdout { color: #e5e7eb; }

/* Files & Editor */
.file-studio-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  min-height: 520px;
}

.file-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.file-sidebar-header {
  padding: 0.75rem 1rem;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-contrast);
}

.file-tree-container {
  padding: 0.65rem;
  overflow-y: auto;
  flex: 1;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.file-item:hover {
  background: var(--bg-darker);
  color: var(--text-contrast);
}

.file-item.active {
  background: rgba(0, 240, 255, 0.12);
  color: var(--accent-cyan);
  font-weight: 600;
}

.editor-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  padding: 0.65rem 1rem;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.active-file-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-contrast);
  font-family: var(--font-mono);
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
}

.editor-area {
  flex: 1;
  display: flex;
}

#codeEditorInput {
  width: 100%;
  height: 480px;
  background: var(--bg-editor);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 1.15rem;
  border: none;
  outline: none;
  resize: vertical;
}

/* --- Workspace Hub (Editor Empty State) --- */
.editor-empty-state {
  padding: 2.25rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 480px;
  background: radial-gradient(circle at 50% 10%, rgba(0, 240, 255, 0.04), transparent 60%);
}

.workspace-hub-hero {
  max-width: 540px;
  margin: 0 auto 1.5rem;
}

.hub-icon-glow {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(139, 92, 246, 0.25));
  border: 1px solid rgba(0, 240, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--accent-cyan);
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.2);
}

.quick-file-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  width: 100%;
  max-width: 680px;
  margin-bottom: 1.75rem;
}

@media (max-width: 768px) {
  .quick-file-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.quick-file-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-main);
}

.quick-file-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.quick-file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.quick-file-text {
  display: flex;
  flex-direction: column;
}

.quick-file-text strong {
  font-size: 0.825rem;
  color: var(--text-contrast);
}

.quick-file-text span {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.editor-drop-zone {
  width: 100%;
  max-width: 680px;
  padding: 1.85rem 1.5rem;
  border: 2px dashed rgba(0, 240, 255, 0.35);
  border-radius: var(--radius-lg);
  background: rgba(0, 240, 255, 0.02);
  transition: all 0.2s ease;
}

.editor-drop-zone.drag-over {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.1);
  transform: scale(1.01);
}

/* File Tree Custom Item Actions */
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.file-item-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.file-item:hover .file-item-actions {
  opacity: 1;
}

.file-item-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.15s ease;
}

.file-item-delete-btn:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.15);
}

.file-item-size {
  font-size: 0.675rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.python-bg { background: rgba(0, 240, 255, 0.15); color: #00f0ff; }
.node-bg { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.sqlite-bg { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.env-bg { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.json-bg { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.custom-bg { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }

/* Visual SQLite Studio */
.sqlite-studio-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  min-height: 520px;
}

.sqlite-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.sqlite-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-contrast);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sqlite-main-pane {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.sqlite-query-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.query-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  font-weight: 700;
}

#sqlQueryInput {
  width: 100%;
  background: var(--bg-terminal);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #a7f3d0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.75rem;
  outline: none;
}

.sqlite-results-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  flex: 1;
}

.results-header {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

/* Settings Card */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 760px;
}

/* --- BUTTONS & CONTROLS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  text-decoration: none;
  min-height: 38px;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--gradient-telegram);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(34, 158, 217, 0.3);
}
.btn-primary:hover {
  background: var(--gradient-primary-hover);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.35);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-medium);
  color: var(--text-contrast);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.btn-dark {
  background: var(--bg-darker);
  border-color: var(--border-subtle);
  color: var(--text-main);
}
.btn-dark:hover {
  background: var(--bg-card);
  border-color: var(--border-medium);
}

.btn-success { background: var(--gradient-success); color: #fff; }
.btn-warning { background: var(--gradient-warning); color: #fff; }
.btn-danger { background: var(--gradient-danger); color: #fff; }

.btn-lg { padding: 0.85rem 1.85rem; font-size: 1rem; border-radius: var(--radius-lg); min-height: 48px; }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.8rem; border-radius: var(--radius-sm); min-height: 32px; }
.btn-xs { padding: 0.3rem 0.6rem; font-size: 0.75rem; border-radius: var(--radius-xs); min-height: 26px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.badge-primary { background: rgba(0, 240, 255, 0.15); color: #00f0ff; border: 1px solid rgba(0, 240, 255, 0.3); }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-dark { background: var(--bg-darker); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.badge-xs { padding: 0.15rem 0.4rem; font-size: 0.65rem; }

/* --- MODALS --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-modal);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideInUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-lg { max-width: 780px; }
.modal-card.modal-xl { max-width: 1040px; width: 95%; }

/* --- ADMIN BOT FORENSIC INSPECTION MODAL --- */
.admin-inspect-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.inspect-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.inspect-meta-item .meta-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.inspect-meta-item .meta-value {
  font-size: 0.875rem;
  color: var(--text-contrast);
  word-break: break-word;
}

.admin-inspect-actions-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.admin-forensic-viewer-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  min-height: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-forensic-sidebar {
  background: var(--bg-darker);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.forensic-sidebar-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-toolbar);
}

.admin-forensic-files-list {
  flex: 1;
  overflow-y: auto;
  max-height: 380px;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-forensic-code-pane {
  display: flex;
  flex-direction: column;
  background: var(--bg-darker);
  min-height: 380px;
}

.forensic-code-header {
  padding: 0.85rem 1.15rem;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.forensic-code-body {
  flex: 1;
  overflow: auto;
  max-height: 380px;
  padding: 1rem 1.25rem;
  background: #080b11;
}

.forensic-code-body pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.min-w-180 { min-width: 180px; }
.min-w-220 { min-width: 220px; }
.min-w-240 { min-width: 240px; }

.modal-header {
  padding: 1.25rem 1.65rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover { color: var(--text-contrast); }

.modal-body {
  padding: 1.65rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-darker);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.auth-tab-btn {
  padding: 0.65rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-card);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group.col { flex: 1; }
.form-group.col-1 { flex: 1; }
.form-group.col-2 { flex: 2; }

.form-label, label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-contrast);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--border-focus);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15);
}

/* Template Selector Cards (Enhanced with Click State & Indicators) */
.template-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 0.6rem;
}

.template-card {
  position: relative;
  display: block;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--bg-card);
  user-select: none;
}

.template-card input[type="radio"] { display: none; }

.template-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card);
}

.template-card.active, .template-card:has(input:checked) {
  border-color: var(--accent-cyan);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.1), rgba(34, 158, 217, 0.12));
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.2);
}

[data-theme="light"] .template-card.active, [data-theme="light"] .template-card:has(input:checked) {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.08), rgba(37, 99, 235, 0.1));
  border-color: #0284c7;
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.18);
}

.template-card.active .select-indicator {
  display: inline-flex !important;
}

.template-content {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.template-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.template-info {
  flex: 1;
}

.template-info h4 {
  font-size: 0.925rem;
  margin-bottom: 0.25rem;
  color: var(--text-contrast);
}

.template-info p {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.template-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

.data-table th {
  background: var(--bg-toolbar);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}

.toast {
  padding: 0.95rem 1.35rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-modal);
  animation: slideInUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}

.toast-success { background: #064e3b; color: #a7f3d0; border: 1px solid #059669; }
.toast-error { background: #7f1d1d; color: #fecaca; border: 1px solid #dc2626; }
.toast-info { background: #1e1b4b; color: #c7d2fe; border: 1px solid #4f46e5; }

/* Spinners & Keyframes */
.spinner-glow {
  width: 52px;
  height: 52px;
  border: 3px solid rgba(0, 240, 255, 0.12);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.9s infinite linear;
  box-shadow: var(--shadow-glow-cyan);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   RESPONSIVE MEDIA QUERIES (Mobile & Tablet Excellence)
   ========================================================= */

/* Tablets & Small Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile & Small Screens (<= 992px) */
@media (max-width: 992px) {
  .mobile-menu-btn {
    display: flex;
  }
  .sidebar-toggle-btn {
    display: none;
  }
  .nav-hide-mobile {
    display: none !important;
  }

  /* Transform Sidebar into Off-Canvas Slide Drawer */
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 1300;
    transform: translateX(-100%);
    box-shadow: var(--shadow-modal);
  }

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

  .sidebar-header {
    display: flex;
  }

  .main-content {
    padding: 1.5rem 1rem;
    max-width: 100%;
  }

  .hero-title {
    font-size: 2.25rem;
  }

  .file-studio-layout, .sqlite-studio-layout {
    grid-template-columns: 1fr;
  }

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

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

  .studio-action-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .theme-toggle-label {
    display: none;
  }
}

/* Mobile Phones (<= 640px) */
@media (max-width: 640px) {
  .navbar {
    padding: 0 1rem;
  }

  .brand-title {
    font-size: 1rem;
  }

  .brand-tag {
    display: none;
  }

  .dashboard-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

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

  .bots-search-box {
    max-width: 100%;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .hero-title {
    font-size: 1.85rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .hero-buttons {
    flex-direction: column;
  }

  .btn-lg {
    width: 100%;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    max-width: 100%;
  }
}

/* ==========================================================================
   Deploy Mode Switcher & File Upload Styles
   ========================================================================== */
.deploy-mode-selector {
  display: flex;
  background: var(--bg-darker);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.deploy-mode-pills {
  display: flex;
  width: 100%;
  gap: 0.5rem;
}

.deploy-mode-btn {
  flex: 1;
  padding: 0.65rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.deploy-mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.deploy-mode-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

/* File Drop Zone */
.file-drop-zone {
  border: 2px dashed var(--border-subtle);
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-lg);
  padding: 2.2rem 1.5rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  transform: translateY(-2px);
}

.drop-zone-content i {
  font-size: 2.5rem;
  opacity: 0.9;
}

/* Selected Files List */
.selected-files-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--border-subtle);
}

.selected-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.selected-file-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* File Type Selector Grid */
.file-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.2rem;
}

.file-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  padding: 0.75rem 0.5rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.file-type-card input[type="radio"] {
  display: none;
}

.file-type-card:hover {
  border-color: var(--primary-light);
  background: rgba(59, 130, 246, 0.06);
  transform: translateY(-2px);
}

.file-type-card.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.14);
  box-shadow: 0 0 0 1px var(--primary);
}

.file-type-meta strong {
  display: block;
  font-size: 0.78rem;
  color: var(--text-main);
  line-height: 1.2;
}

.file-type-meta span {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.btn-hover-danger:hover {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}

.file-preview-banner {
  border: 1px solid var(--border-subtle);
}

