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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e17;
  color: #e0e6f0;
  min-height: 100vh;
}

/* ── Header / Nav ── */
.header {
  background: linear-gradient(135deg, #0d1320 0%, #111927 100%);
  border-bottom: 1px solid #1e2a3a;
  padding: 14px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header h1 { font-size: 20px; color: #fff; font-weight: 600; }
.header h1 span { color: #25D366; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-user { font-size: 13px; color: #25D366; font-weight: 500; }

.nav { display: flex; gap: 4px; }
.nav a {
  font-size: 13px; color: #7a8ba3; text-decoration: none;
  padding: 6px 14px; border-radius: 6px; transition: all 0.2s;
}
.nav a:hover { color: #c0cce0; background: #1e2a3a; }
.nav a.active { color: #25D366; background: rgba(37,211,102,0.1); }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

/* ── Cards ── */
.card {
  background: #111927; border: 1px solid #1e2a3a;
  border-radius: 12px; padding: 24px; margin-bottom: 24px;
}
.card h2 {
  font-size: 18px; color: #fff; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ── Auth Page ── */
.auth-page {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  background: #111927; border: 1px solid #1e2a3a;
  border-radius: 16px; padding: 40px; width: 100%; max-width: 420px;
}
.auth-card h1 { font-size: 24px; color: #fff; margin-bottom: 8px; text-align: center; }
.auth-card h1 span { color: #25D366; }
.auth-card .subtitle { text-align: center; color: #5a6a80; font-size: 14px; margin-bottom: 28px; }
.auth-tabs { display: flex; margin-bottom: 24px; border-bottom: 1px solid #1e2a3a; }
.auth-tab {
  flex: 1; padding: 12px; text-align: center; font-size: 14px; font-weight: 600;
  color: #5a6a80; cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.auth-tab:hover { color: #c0cce0; }
.auth-tab.active { color: #25D366; border-bottom-color: #25D366; }
.auth-error {
  background: rgba(255,71,87,0.1); border: 1px solid rgba(255,71,87,0.3);
  color: #ff6b7a; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px; display: none;
}
.auth-error.show { display: block; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: #7a8ba3; margin-bottom: 6px; font-weight: 500; }
.form-group input, .input {
  width: 100%; padding: 12px 16px; border-radius: 8px;
  border: 1px solid #2a3a50; background: #0a0e17; color: #fff;
  font-size: 15px; outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .input:focus { border-color: #25D366; }
.form-group input::placeholder, .input::placeholder { color: #4a5a70; }

.create-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.create-form input { flex: 1; min-width: 200px; }

/* ── Buttons ── */
.btn {
  padding: 12px 24px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: #25D366; color: #000; }
.btn-primary:hover { background: #1fba59; }
.btn-danger { background: #ff4757; color: #fff; padding: 8px 14px; font-size: 13px; }
.btn-danger:hover { background: #e0303f; }
.btn-secondary { background: #1e2a3a; color: #c0cce0; padding: 8px 14px; font-size: 13px; }
.btn-secondary:hover { background: #2a3a50; }
.btn-logout {
  background: none; border: 1px solid #2a3a50; color: #7a8ba3;
  padding: 8px 16px; font-size: 13px; cursor: pointer;
  border-radius: 8px; transition: all 0.2s;
}
.btn-logout:hover { border-color: #ff4757; color: #ff4757; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm {
  padding: 6px 12px; font-size: 12px; border: none; border-radius: 6px;
  cursor: pointer; font-weight: 600; transition: all 0.2s;
}
.btn-sm.save { background: #25D366; color: #000; }
.btn-sm.save:hover { background: #1fba59; }
.btn-sm.toggle { background: #1e2a3a; color: #c0cce0; }
.btn-sm.toggle:hover { background: #2a3a50; }

/* ── Sessions ── */
.sessions-list { margin-top: 8px; }
.session-item {
  background: #0d1320; border: 1px solid #1e2a3a; border-radius: 10px;
  padding: 18px 20px; margin-bottom: 12px; display: flex;
  align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; transition: border-color 0.2s;
}
.session-item:hover { border-color: #25D366; }
.session-info { flex: 1; min-width: 200px; }
.session-name { font-size: 16px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.session-id { font-size: 12px; color: #5a6a80; font-family: monospace; }
.session-status { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-connected .status-dot { background: #25D366; }
.status-connected { color: #25D366; }
.status-waiting .status-dot { background: #ffd600; }
.status-waiting { color: #ffd600; }
.status-starting .status-dot { background: #5a6a80; }
.status-starting { color: #5a6a80; }
.session-phone { font-size: 14px; color: #8a9ab0; min-width: 120px; }
.session-actions { display: flex; gap: 8px; align-items: center; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 1000;
  justify-content: center; align-items: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #111927; border: 1px solid #1e2a3a; border-radius: 16px;
  width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; position: relative;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid #1e2a3a;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 18px; color: #fff; }
.modal-close { background: none; border: none; color: #5a6a80; font-size: 24px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 24px; }

/* ── QR ── */
.qr-container { text-align: center; padding: 20px 0; }
.qr-container img { border: 6px solid #fff; border-radius: 12px; max-width: 280px; }
.qr-instructions { margin-top: 16px; color: #7a8ba3; font-size: 14px; line-height: 1.6; }
.qr-loading { padding: 60px 0; color: #ffd600; font-size: 16px; }
.qr-connected { padding: 40px 0; color: #25D366; }
.qr-connected .checkmark { font-size: 48px; margin-bottom: 12px; }

/* ── API Key ── */
.api-key-box {
  background: #0a0e17; border: 1px solid #2a3a50; border-radius: 8px;
  padding: 14px 16px; margin: 16px 0; display: flex; align-items: center; gap: 10px;
}
.api-key-value { flex: 1; font-family: monospace; font-size: 13px; color: #25D366; word-break: break-all; }
.copy-btn {
  background: #1e2a3a; border: none; color: #c0cce0; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.copy-btn:hover { background: #2a3a50; }
.copy-btn.copied { background: #25D366; color: #000; }

/* ── Code ── */
.code-block {
  background: #0a0e17; border: 1px solid #1e2a3a; border-radius: 8px;
  padding: 14px 16px; margin: 10px 0; font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px; color: #c0cce0; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all; position: relative;
}
.code-block .copy-btn { position: absolute; top: 8px; right: 8px; }
.code-block .key { color: #7dd3fc; }
.code-block .str { color: #a5d6a7; }
.code-block .method { color: #f9a825; }

/* ── Instructions ── */
.instructions h3 { font-size: 15px; color: #fff; margin: 20px 0 10px; }
.instructions h3:first-child { margin-top: 0; }
.instructions p { font-size: 13px; color: #7a8ba3; margin-bottom: 8px; line-height: 1.5; }
.instructions .step { display: flex; gap: 10px; margin-bottom: 12px; }
.instructions .step-num {
  background: #25D366; color: #000; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.instructions .step-text { font-size: 14px; color: #c0cce0; line-height: 1.5; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid #1e2a3a; }
.tab {
  padding: 10px 20px; font-size: 14px; color: #5a6a80; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: #c0cce0; }
.tab.active { color: #25D366; border-bottom-color: #25D366; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Admin rows ── */
.user-item {
  background: #0d1320; border: 1px solid #1e2a3a; border-radius: 10px;
  padding: 16px 20px; margin-bottom: 10px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.user-info { flex: 1; min-width: 140px; }
.user-name { font-size: 15px; font-weight: 600; color: #fff; }
.user-meta { font-size: 12px; color: #5a6a80; margin-top: 2px; }
.user-role-badge { font-size: 11px; padding: 2px 10px; border-radius: 10px; font-weight: 600; }
.user-role-badge.admin { background: #25D366; color: #000; }
.user-role-badge.user { background: #1e2a3a; color: #7a8ba3; }
.user-actions { display: flex; gap: 6px; align-items: center; }
.user-inactive { opacity: 0.5; }

/* ── Message rows ── */
.msg-item {
  background: #0d1320; border: 1px solid #1e2a3a; border-radius: 8px;
  padding: 12px 16px; margin-bottom: 8px;
}
.msg-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.msg-type {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.msg-type.text { background: #1e2a3a; color: #7dd3fc; }
.msg-type.media { background: #2a1e3a; color: #ce93d8; }
.msg-type.location { background: #1e3a2a; color: #a5d6a7; }
.msg-type.template { background: #3a2a1e; color: #ffcc80; }
.msg-status { font-size: 12px; font-weight: 600; margin-left: auto; }
.msg-status.sent { color: #25D366; }
.msg-status.failed { color: #ff4757; }
.msg-status.queued { color: #ffd600; }
.msg-preview { font-size: 12px; color: #8a9ab0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
.msg-meta { display: flex; gap: 16px; font-size: 11px; color: #5a6a80; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 30px; right: 30px;
  background: #25D366; color: #000; padding: 12px 20px;
  border-radius: 8px; font-size: 14px; font-weight: 600;
  z-index: 2000; transform: translateY(100px); opacity: 0; transition: all 0.3s;
}
.toast.error { background: #ff4757; color: #fff; }
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Empty ── */
.empty-state { text-align: center; padding: 50px 20px; color: #4a5a70; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; margin-bottom: 8px; }

.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .header h1 { font-size: 18px; }
  .nav a { padding: 4px 10px; font-size: 12px; }
  .container { padding: 16px 12px; }
  .card { padding: 16px; }
  .session-item { flex-direction: column; align-items: flex-start; }
  .session-actions { width: 100%; justify-content: flex-end; }
  .create-form { flex-direction: column; }
  .create-form input { width: 100%; }
  .btn { width: 100%; justify-content: center; }
  .auth-card { padding: 24px; }
  .user-item { flex-direction: column; align-items: flex-start; }
}
