:root {
  --bg: #000000;
  --bg-secondary: #16181c;
  --bg-tertiary: #1d1f23;
  --bg-hover: #1e2025;
  --border: #2f3336;
  --text: #e7e9ea;
  --text-secondary: #71767b;
  --primary: #1d9bf0;
  --primary-hover: #1a8cd8;
  --success: #00ba7c;
  --danger: #f4212e;
  --warning: #ffd400;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.header-right { display: flex; align-items: center; gap: 12px; }

#user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

#user-name { font-weight: 600; color: var(--text); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-icon { background: transparent; color: var(--text-secondary); padding: 8px; border-radius: 50%; }
.btn-icon:hover { background: rgba(29,155,240,0.1); color: var(--primary); }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* Layout */
.main-layout {
  display: flex;
  min-height: calc(100vh - 57px);
}

/* Sidebar */
.sidebar {
  width: 280px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h3 { font-size: 18px; }

.bot-list { padding: 8px; }

.bot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.bot-item:hover { background: var(--bg-hover); }
.bot-item.active { background: var(--bg-secondary); }

.bot-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

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

.bot-item-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.bot-item-status.running { background: var(--success); }

.empty-state-small {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px 16px;
  font-size: 14px;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  max-width: 900px;
}

/* Welcome */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  gap: 16px;
}

.welcome-icon { margin-bottom: 8px; color: var(--text-secondary); }
.welcome-screen h2 { font-size: 28px; }
.welcome-screen p { color: var(--text-secondary); font-size: 16px; line-height: 1.6; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

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

/* Bot header */
.bot-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.bot-header-info h2 { font-size: 24px; }

.bot-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-secondary);
}

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

.bot-status.running .status-dot { background: var(--success); }
.bot-status.running .status-text { color: var(--success); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-config {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  opacity: 0.7;
}

.actions-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
}

/* AI Chat */
.ai-chat-section {
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.ai-chat-section h3 { margin-bottom: 4px; }

.section-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.chat-messages {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.chat-msg {
  margin-bottom: 16px;
}

.chat-msg:last-child { margin-bottom: 0; }

.chat-msg.user .chat-msg-content {
  background: var(--primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  display: inline-block;
  max-width: 80%;
  float: right;
}

.chat-msg.assistant .chat-msg-content {
  background: var(--bg-tertiary);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 16px;
  display: inline-block;
  max-width: 80%;
  line-height: 1.5;
  font-size: 14px;
}

.chat-msg::after { content: ''; display: table; clear: both; }

.chat-input-area {
  display: flex;
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 10px 20px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.chat-input-area input:focus { border-color: var(--primary); }

/* Forms */
.form-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.form-section h4 { margin-bottom: 4px; font-size: 17px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea,
.form-group select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
}

.form-group textarea { resize: vertical; }

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Logs */
.logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.logs-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 600px;
  overflow-y: auto;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.log-entry:last-child { border-bottom: none; }

.log-time {
  color: var(--text-secondary);
  white-space: nowrap;
  font-family: monospace;
  font-size: 12px;
  min-width: 55px;
}

.log-type {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  min-width: 70px;
  text-align: center;
}

.log-type.post { background: rgba(29,155,240,0.15); color: var(--primary); }
.log-type.reply { background: rgba(0,186,124,0.15); color: var(--success); }
.log-type.retweet { background: rgba(255,212,0,0.15); color: var(--warning); }
.log-type.like { background: rgba(244,33,46,0.15); color: var(--danger); }
.log-type.follow { background: rgba(120,86,255,0.15); color: #7856ff; }
.log-type.dm { background: rgba(29,155,240,0.15); color: var(--primary); }
.log-type.error { background: rgba(244,33,46,0.15); color: var(--danger); }

.log-text { flex: 1; color: var(--text); line-height: 1.4; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(91,112,131,0.4);
}

.modal-content {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 440px;
}

.modal-content h3 { margin-bottom: 16px; font-size: 20px; }
.modal-content p { color: var(--text-secondary); margin-bottom: 20px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 14px;
  z-index: 2000;
  animation: slideUp 0.3s ease;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h3,
  .bot-item-info,
  .bot-item-status { display: none; }
  .sidebar-header { justify-content: center; }
  .bot-item { justify-content: center; padding: 12px 8px; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .header { padding: 12px 16px; }
  .logo span { display: none; }
}

/* Info tooltip */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.info-icon:hover {
  background: var(--primary);
  color: #fff;
}

.info-icon:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  white-space: nowrap;
  max-width: 320px;
  white-space: normal;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  line-height: 1.4;
}

/* API help box */
.api-help-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.api-help-box strong {
  color: var(--text);
  display: block;
  margin-bottom: 8px;
}

.api-help-box ol {
  padding-left: 18px;
}

.api-help-box li {
  margin-bottom: 4px;
}

/* Plan info box */
.plan-info-box {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-top: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.plan-info-box.plan-free {
  background: rgba(255, 212, 0, 0.08);
  border: 1px solid rgba(255, 212, 0, 0.25);
}
.plan-info-box.plan-basic {
  background: rgba(29, 155, 240, 0.08);
  border: 1px solid rgba(29, 155, 240, 0.25);
}
.plan-info-box.plan-pro {
  background: rgba(0, 186, 124, 0.08);
  border: 1px solid rgba(0, 186, 124, 0.25);
}
.plan-info-box .plan-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.plan-free .plan-title { color: var(--warning); }
.plan-basic .plan-title { color: var(--primary); }
.plan-pro .plan-title { color: var(--success); }
.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
}
.plan-features li {
  margin-bottom: 3px;
  font-size: 13px;
}
.plan-features li.ok { color: var(--success); }
.plan-features li.ok::before { content: "✓ "; font-weight: 700; }
.plan-features li.no { color: var(--text-secondary); opacity: 0.6; text-decoration: line-through; }
.plan-features li.no::before { content: "✗ "; font-weight: 700; color: var(--danger); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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