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

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #06080f;
  --bg2: #0d1117;
  --bg3: #161b27;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-accent: rgba(16,185,129,0.4);

  --accent: #10b981;
  --accent2: #059669;
  --accent-glow: rgba(16,185,129,0.2);
  --accent-text: #6ee7b7;

  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;

  --red: #ef4444;
  --yellow: #f59e0b;
  --blue: #3b82f6;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(16,185,129,0.15);
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Auth Page ───────────────────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(16,185,129,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(59,130,246,0.07) 0%, transparent 50%),
              var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow), var(--shadow-glow);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}
.auth-logo svg { width: 40px; height: 40px; }
.auth-logo-text { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.auth-logo-text span { color: var(--accent); }

/* Tabs */
.auth-tabs {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--accent);
  color: #fff;
}

/* Form */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 8px; }
.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text3); }

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

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

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

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text2); cursor: pointer; transition: all 0.2s; }
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

/* Error message */
.error-msg { font-size: 13px; color: var(--red); margin-top: 12px; text-align: center; display: none; }
.error-msg.show { display: block; }

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

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-text { font-size: 17px; font-weight: 700; }
.sidebar-logo-text span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--border-accent); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 10px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-email { font-size: 11px; color: var(--text2); }

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 28px 32px;
  max-width: calc(100vw - 240px);
}

.page-header { margin-bottom: 28px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.page-subtitle { font-size: 14px; color: var(--text2); margin-top: 4px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text2); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-dash { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.status-connected { background: rgba(16,185,129,0.15); color: var(--accent); }
.status-connected .status-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse 2s infinite; }
.status-disconnected { background: rgba(239,68,68,0.1); color: var(--red); }
.status-disconnected .status-dot { background: var(--red); }
.status-qr { background: rgba(245,158,11,0.1); color: var(--yellow); }
.status-qr .status-dot { background: var(--yellow); animation: pulse 1s infinite; }
.status-connecting { background: rgba(59,130,246,0.1); color: var(--blue); }
.status-connecting .status-dot { background: var(--blue); animation: pulse 0.8s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* QR Code */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
}
.qr-wrapper {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 0 40px rgba(16,185,129,0.2);
  animation: qr-appear 0.4s ease;
}
@keyframes qr-appear { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.qr-wrapper img { display: block; width: 200px; height: 200px; }
.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text3);
  font-size: 14px;
  text-align: center;
}
.qr-placeholder svg { opacity: 0.3; }

/* API Key */
.apikey-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.apikey-text {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--accent-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats */
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.stat-label { font-size: 13px; color: var(--text2); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -1px; }
.stat-value.green { color: var(--accent); }
.stat-value.red { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }

/* API Docs */
.code-block {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #7dd3fc;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.7;
  margin-top: 12px;
}
.code-block .kw { color: #c084fc; }
.code-block .str { color: #86efac; }
.code-block .key { color: #93c5fd; }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-color: rgba(16,185,129,0.3); }
.toast-error { border-color: rgba(239,68,68,0.3); }

/* Loading spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Divider */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Phone display */
.phone-display { font-size: 18px; font-weight: 600; color: var(--accent); margin-top: 12px; }

/* Section header */
.section { margin-bottom: 24px; }

/* ─── Mobile Navigation ─── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.burger-btn {
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s;
}
.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
  .grid-2, .grid-3, .grid-dash { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .dash-layout { flex-direction: column; }
  .mobile-header { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 16px; max-width: 100vw; }
}
