/* BotMonitor v2 — Global Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500;600&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg:        #080c14;
  --card:      #0e1420;
  --card2:     #141c2e;
  --border:    #1e2d47;
  --text:      #e8edf5;
  --muted:     #5a6a85;
  --accent:    #00d4ff;
  --green:     #00e5a0;
  --red:       #ff4566;
  --yellow:    #ffca28;
  --purple:    #7c5cfc;
  --sidebar-w: 240px;
  --radius:    10px;
  --transition: 0.18s ease;
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: 'DM Mono', monospace;
  font-weight: 600;
}

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

/* ── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Layout ────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-text {
  font-family: 'DM Mono', monospace;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.sidebar-logo .logo-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 4px 16px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 12px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--card2);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(0, 212, 255, 0.07);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-footer .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bg);
  flex-shrink: 0;
}

.sidebar-footer .logout-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition);
}

.sidebar-footer .logout-btn:hover {
  background: var(--card2);
  color: var(--red);
  border-color: var(--red);
}

/* ── Main content ──────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: 'DM Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  padding: 24px 28px;
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

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

.card-title {
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.card-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Stat cards ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: var(--accent); }

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.stat-value {
  font-family: 'DM Mono', monospace;
  font-size: 2rem;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1;
}

.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.accent { color: var(--accent); }
.stat-value.purple { color: var(--purple); }

.stat-icon {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  opacity: 0.08;
}

/* ── Table ─────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(30, 45, 71, 0.5);
  transition: background var(--transition);
  cursor: pointer;
}

tbody tr:hover { background: var(--card2); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 11px 14px;
  color: var(--text);
  white-space: nowrap;
}

/* ── Status badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-running   { background: rgba(0, 212, 255, 0.12); color: var(--accent); }
.badge-running::before { background: var(--accent); animation: pulse 1.5s infinite; }
.badge-completed { background: rgba(0, 229, 160, 0.12); color: var(--green); }
.badge-completed::before { background: var(--green); }
.badge-failed    { background: rgba(255, 69, 102, 0.12); color: var(--red); }
.badge-failed::before { background: var(--red); }
.badge-online    { background: rgba(0, 229, 160, 0.12); color: var(--green); }
.badge-online::before { background: var(--green); animation: pulse 1.5s infinite; }
.badge-offline   { background: rgba(90, 106, 133, 0.12); color: var(--muted); }
.badge-offline::before { background: var(--muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: #00b8e0; transform: translateY(-1px); }

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

.btn-danger {
  background: rgba(255, 69, 102, 0.12);
  color: var(--red);
  border: 1px solid rgba(255, 69, 102, 0.2);
}
.btn-danger:hover { background: rgba(255, 69, 102, 0.25); }

.btn-green {
  background: rgba(0, 229, 160, 0.12);
  color: var(--green);
  border: 1px solid rgba(0, 229, 160, 0.2);
}
.btn-green:hover { background: rgba(0, 229, 160, 0.25); }

.btn-sm { padding: 5px 10px; font-size: 0.77rem; }
.btn-icon { padding: 7px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--muted); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6a85' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  transform: translateY(12px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-family: 'DM Mono', monospace;
  font-size: 1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

/* ── Side Panel (dim overlay) ──────────────────────────────────── */
.side-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.65);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.side-panel-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ── Side Panel (drawer) ───────────────────────────────────────── */
.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 520px;
  max-width: 100%;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-panel.open { transform: translateX(0); }

.side-panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--card2);
}

.side-panel-title {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

/* ── Panel content ─────────────────────────────────────────────── */
.panel-process-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}

.panel-meta {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px 14px;
  font-size: 0.83rem;
  margin: 16px 0;
}

.panel-meta-label { color: var(--muted); }

.panel-meta-value {
  color: var(--text);
  font-weight: 500;
  word-break: break-all;
}

.panel-error-box {
  background: rgba(255, 69, 102, 0.12);
  border: 1px solid rgba(255, 69, 102, 0.35);
  border-left: 3px solid var(--red);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: 0.81rem;
  color: #ffb3c0;
  line-height: 1.65;
}

.panel-error-label {
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}

.panel-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.panel-logs-header {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

/* ── Logs ──────────────────────────────────────────────────────── */
.log-container {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  max-height: 400px;
  overflow-y: auto;
}

.log-entry {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  line-height: 1.6;
  border-bottom: 1px solid rgba(30, 45, 71, 0.4);
}

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

.log-time {
  color: var(--muted);
  flex-shrink: 0;
  min-width: 110px;
}

.log-msg { word-break: break-word; }

.log-INFO  { color: var(--text); }
.log-WARN  { color: var(--yellow); }
.log-ERROR { color: #ff8fa3; }
.log-DEBUG { color: var(--muted); }

/* ── Toast notifications ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  min-width: 280px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.2s ease forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--accent); }
.toast.toast-warning { border-left: 3px solid var(--yellow); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-msg  { flex: 1; color: var(--text); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Loading spinner ───────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }

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

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  gap: 12px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
.empty-title { font-size: 0.95rem; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 0.82rem; }

/* ── Login page ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-main {
  font-family: 'DM Mono', monospace;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent);
}

.login-logo .logo-ver {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Chart containers ──────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 220px;
}

/* ── Divider ───────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ── Grid helpers ──────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Auto-refresh indicator ────────────────────────────────────── */
.refresh-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.refresh-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

/* ── Bottom nav (mobile) ───────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 8px 0;
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  font-size: 0.68rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition);
}

.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .bnav-icon { font-size: 1.2rem; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .bottom-nav { display: block; }
  .content { padding: 16px; padding-bottom: 80px; }
  .topbar { padding: 12px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel { width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 28px 22px; }
}
