:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-card-hover: #22222f;
  --bg-input: #14141e;
  --border: #2a2a3a;
  --border-focus: #5865f2;
  --text-primary: #e4e4ea;
  --text-secondary: #8b8b9e;
  --text-muted: #5c5c72;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-glow: rgba(88, 101, 242, 0.15);
  --danger: #ed4245;
  --success: #3ba55c;
  --warning: #faa61a;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body[data-lang="ar"] {
  direction: rtl;
  font-family: var(--font-ar);
}

/* Force LTR for code */
pre,
code,
.code-block-content,
.form-input {
  direction: ltr !important;
  text-align: left !important;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Language Switcher — ALWAYS top-right ─── */
.lang-switch {
  position: fixed;
  top: 20px;
  right: 20px;
  left: auto;
  z-index: 100;
  display: flex;
  direction: ltr;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.lang-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  font-family: var(--font);
}

.lang-btn.active {
  background: var(--accent);
  color: white;
}

.lang-btn:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ─── Container ─── */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ─── Hero ─── */
.hero {
  text-align: center;
  padding: 100px 0 60px;
}

.hero-title {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 28px;
  line-height: 1.8;
}

.hero-badges {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  direction: ltr !important;
  unicode-bidi: isolate;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-dot.red {
  background: var(--danger);
}

.badge-dot.green {
  background: var(--success);
}

/* ─── Sections ─── */
section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .bar {
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

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

/* ─── Code Block ─── */
.code-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  direction: ltr;
}

.code-block-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  font-family: inherit;
}

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-btn.copied {
  border-color: var(--success);
  color: var(--success);
}

.code-block-content {
  padding: 16px;
  overflow-x: auto;
}

.code-block-content pre {
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-primary);
}

/* ─── Collapsible ─── */
.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.collapsible-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-card);
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: start;
}

.collapsible-toggle:hover {
  background: var(--bg-card-hover);
}

.collapsible-toggle .arrow {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.collapsible.open .collapsible-toggle .arrow {
  transform: rotate(90deg);
}

.collapsible-body {
  display: none;
  border-top: 1px solid var(--border);
}

.collapsible.open .collapsible-body {
  display: block;
}

.collapsible-body .code-block {
  border: none;
  border-radius: 0;
  margin: 0;
}

.collapsible-body .code-block-header {
  background: var(--bg-secondary);
}

/* ─── Card ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}

.card-quote {
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: 16px;
}

.card-quote .quote-author {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 14px;
}

.card-quote .quote-author a {
  color: inherit;
  text-decoration: none;
}

.card-quote .quote-author a:hover {
  text-decoration: underline;
}

.card-quote .quote-text {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.9;
}

/* ─── Steps ─── */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-inline-start: 36px;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Webhook Form ─── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  transition: var(--transition);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-status {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: none;
}

.form-status.success {
  display: block;
  background: rgba(59, 165, 92, 0.1);
  border: 1px solid rgba(59, 165, 92, 0.3);
  color: var(--success);
}

.form-status.error {
  display: block;
  background: rgba(237, 66, 69, 0.1);
  border: 1px solid rgba(237, 66, 69, 0.3);
  color: var(--danger);
}

.form-status.warning {
  display: block;
  background: rgba(250, 166, 26, 0.1);
  border: 1px solid rgba(250, 166, 26, 0.3);
  color: var(--warning);
}

/* ─── Mention Chips ─── */
.chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: text;
  align-items: center;
}

.chip-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.chip-container .chip-input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  outline: none;
  padding: 4px 0;
  direction: ltr !important;
  text-align: left !important;
}

.chip-container .chip-input::placeholder {
  color: var(--text-muted);
}

.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  animation: chipIn 0.2s ease;
  direction: ltr;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.mention-chip .chip-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.mention-chip .chip-role-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-glow);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.mention-chip .chip-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}

.mention-chip .chip-label small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.mention-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
  display: flex;
  align-items: center;
}

.mention-chip .chip-remove:hover {
  color: var(--danger);
}

/* ─── Toast ─── */
.site-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.site-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.site-toast.warning {
  border-color: rgba(250, 166, 26, 0.5);
  color: var(--warning);
}

.site-toast.error {
  border-color: rgba(237, 66, 69, 0.5);
  color: var(--danger);
}

/* ─── Timestamp Table ─── */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.info-table th,
.info-table td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: start;
}

.info-table th {
  background: var(--bg-card);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
}

.info-table td {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.info-table code {
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 12px;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  direction: ltr;
  unicode-bidi: embed;
}

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

/* ─── Footer ─── */
.footer {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent);
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .hero {
    padding: 80px 0 40px;
  }

  .hero-title {
    font-size: 1.8rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .container {
    padding: 0 16px;
  }

  .card {
    padding: 18px;
  }

  .lang-switch {
    top: 12px;
    right: 12px;
  }
}