@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0a0d14;
  --bg-2: #0f1320;
  --bg-card: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.08);
  --primary: #25d366;
  --primary-dark: #128c7e;
  --primary-glow: rgba(37,211,102,0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #475569;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

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

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

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(37,211,102,0.12) 0%, transparent 70%), var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow), 0 0 80px rgba(37,211,102,0.06);
  animation: fadeUp 0.5s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  justify-content: center;
}

.login-logo .icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 0 24px var(--primary-glow);
}

.login-logo h1 { font-size: 24px; font-weight: 700; }
.login-logo span { color: var(--primary); }

.login-subtitle { text-align: center; color: var(--text-2); margin-bottom: 32px; font-size: 14px; }

/* ── FORMS ── */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }

.form-control {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  background: rgba(37,211,102,0.05);
  box-shadow: 0 0 0 3px rgba(37,211,102,0.1);
}

select.form-control option {
  background-color: var(--bg-2);
  color: var(--text);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 15px;
  box-shadow: 0 4px 20px rgba(37,211,102,0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(37,211,102,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 8px; }

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

.sidebar {
  width: 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex; flex-direction: column;
  position: fixed; height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.sidebar-logo .icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.sidebar-logo h2 { font-size: 16px; font-weight: 700; }
.sidebar-logo span { color: var(--primary); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 4px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}

.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); }
.nav-item .nav-icon { font-size: 18px; width: 20px; text-align: center; }

.sidebar-bottom { margin-top: auto; }

.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: calc(100vw - 240px);
}

/* ── HEADER ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px;
}

.page-title { font-size: 22px; font-weight: 700; }
.page-title span { color: var(--text-2); font-weight: 400; font-size: 14px; margin-left: 10px; }

/* ── CARDS ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}

.card:hover { border-color: rgba(255,255,255,0.12); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: all 0.2s;
}

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

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.stat-icon.green { background: rgba(37,211,102,0.12); }
.stat-icon.yellow { background: rgba(245,158,11,0.12); }
.stat-icon.red { background: rgba(239,68,68,0.12); }
.stat-icon.blue { background: rgba(59,130,246,0.12); }

.stat-label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; }

/* ── INSTANCES GRID ── */
.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.instance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
  animation: fadeUp 0.3s ease;
}

.instance-card:hover { border-color: rgba(255,255,255,0.15); transform: translateY(-2px); }

.instance-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}

.instance-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.instance-name { font-size: 15px; font-weight: 600; }
.instance-number { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.status-open { background: rgba(37,211,102,0.12); color: var(--primary); }
.status-close { background: rgba(239,68,68,0.12); color: var(--danger); }
.status-connecting { background: rgba(245,158,11,0.12); color: var(--warning); }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

.instance-actions {
  display: flex; gap: 8px; margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── QR CODE MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 90%; max-width: 440px;
  animation: scaleIn 0.25s ease;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-title { font-size: 18px; font-weight: 700; }

.qr-container {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 24px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  min-height: 250px;
  justify-content: center;
}

.qr-container img { max-width: 220px; border-radius: 10px; }
.qr-hint { font-size: 13px; color: var(--text-2); text-align: center; }

/* ── STEPS ── */
.steps { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.step {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.step-text { font-size: 13px; color: var(--text-2); padding-top: 4px; }
.step-text strong { color: var(--text); }

/* ── DOCS ── */
.docs-layout { display: flex; gap: 32px; }

.docs-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 32px;
  align-self: flex-start;
}

.docs-nav-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 8px; margin-top: 20px;
}
.docs-nav-title:first-child { margin-top: 0; }

.docs-nav-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s;
  margin-bottom: 2px;
}
.docs-nav-item:hover { background: var(--bg-card); color: var(--text); }
.docs-nav-item.active { background: var(--primary-glow); color: var(--primary); }

.docs-content { flex: 1; min-width: 0; }

.docs-section { margin-bottom: 48px; }
.docs-section-title {
  font-size: 20px; font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.endpoint-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.endpoint-header {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.endpoint-header:hover { background: rgba(255,255,255,0.02); }

.method-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  font-family: 'Courier New', monospace;
  flex-shrink: 0;
}

.method-get { background: rgba(34,197,94,0.15); color: #4ade80; }
.method-post { background: rgba(59,130,246,0.15); color: #60a5fa; }
.method-delete { background: rgba(239,68,68,0.15); color: #f87171; }
.method-put { background: rgba(234,179,8,0.15); color: #facc15; }

.endpoint-path {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.endpoint-desc { font-size: 13px; color: var(--text-2); margin-left: auto; }

.endpoint-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
  display: none;
}

.endpoint-body.open { display: block; padding-top: 16px; }

.endpoint-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-3);
  margin-bottom: 8px; margin-top: 16px;
}
.endpoint-section-label:first-child { margin-top: 0; }

pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #e2e8f0;
}

.json-key { color: #93c5fd; }
.json-str { color: #86efac; }
.json-num { color: #fca5a5; }
.json-bool { color: #fdba74; }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(37,211,102,0.1); border: 1px solid rgba(37,211,102,0.3); color: #86efac; }

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ── ANIMATIONS ── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 20px; max-width: 100%; }
  .docs-layout { flex-direction: column; }
  .docs-sidebar { width: 100%; position: static; }
}
