/* ═══════════════════════════════════════════════════════════════════
   regex-tool.css  -  Regex Tester  |  Scoped under #rxt-root
   Theme: Deep Midnight × Violet Accent - Premium SaaS
═══════════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────────────────────────────── */
#rxt-root {
  --rxt-bg:          #0d0f1a;
  --rxt-surface:     #13162a;
  --rxt-surface2:    #1a1e35;
  --rxt-surface3:    #212643;
  --rxt-border:      #2a2f52;
  --rxt-border2:     #353b64;

  --rxt-accent:      #7c6bff;
  --rxt-accent-soft: rgba(124, 107, 255, 0.15);
  --rxt-accent2:     #a78bfa;
  --rxt-glow:        rgba(124, 107, 255, 0.35);

  --rxt-match-bg:    rgba(251, 191, 36, 0.25);
  --rxt-match-bd:    rgba(251, 191, 36, 0.7);
  --rxt-match-text:  #fbbf24;

  --rxt-ok:          #34d399;
  --rxt-err:         #f87171;
  --rxt-warn:        #fbbf24;

  --rxt-text:        #e2e5f5;
  --rxt-muted:       #7880a8;
  --rxt-faint:       #3d4470;

  --rxt-radius:      14px;
  --rxt-radius-sm:   8px;
  --rxt-font:        'DM Sans', 'Outfit', system-ui, sans-serif;
  --rxt-mono:        'JetBrains Mono', 'Fira Code', monospace;

  --rxt-shadow:      0 4px 24px rgba(0,0,0,0.45);
  --rxt-shadow-sm:   0 2px 10px rgba(0,0,0,0.3);

  font-family: var(--rxt-font);
  background: var(--rxt-bg);
  color: var(--rxt-text);
  min-height: 100vh;
  box-sizing: border-box;
}

#rxt-root *, #rxt-root *::before, #rxt-root *::after {
  box-sizing: inherit;
}

/* ── Hero ──────────────────────────────────────────────────────── */
.rxt-hero {
  text-align: center;
  padding: 56px 24px 40px;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(124,107,255,0.18) 0%, transparent 70%),
    var(--rxt-bg);
  border-bottom: 1px solid var(--rxt-border);
  position: relative;
  overflow: hidden;
}

.rxt-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(124,107,255,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(167,139,250,0.05) 0%, transparent 40%);
  pointer-events: none;
}

.rxt-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--rxt-accent-soft);
  border: 1px solid rgba(124,107,255,0.3);
  color: var(--rxt-accent2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 20px;
}

.rxt-hero-badge svg {
  width: 14px; height: 14px;
}

.rxt-hero h1 {
  font-size: clamp(28px, 5vw, 46px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin: 0 0 14px;
  line-height: 1.1;
}

.rxt-hero h1 span {
  background: linear-gradient(135deg, var(--rxt-accent) 0%, var(--rxt-accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.rxt-hero p {
  color: var(--rxt-muted);
  font-size: 15px;
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── App Shell ─────────────────────────────────────────────────── */
.rxt-app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ── Top Bar (Pattern + Flags + Actions) ───────────────────────── */
.rxt-topbar {
  background: var(--rxt-surface);
  border: 1px solid var(--rxt-border);
  border-radius: var(--rxt-radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--rxt-shadow-sm);
}

.rxt-pattern-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.rxt-pattern-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--rxt-surface2);
  border: 1.5px solid var(--rxt-border2);
  border-radius: var(--rxt-radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

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

.rxt-pattern-wrap.is-error {
  border-color: var(--rxt-err);
  box-shadow: 0 0 0 3px rgba(248,113,113,0.2);
}

.rxt-slash {
  padding: 0 12px;
  color: var(--rxt-accent);
  font-family: var(--rxt-mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

#rxt-pattern {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--rxt-text);
  font-family: var(--rxt-mono);
  font-size: 15px;
  padding: 12px 4px;
  min-width: 0;
}

#rxt-pattern::placeholder { color: var(--rxt-faint); }

.rxt-flags-inline {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  border-left: 1px solid var(--rxt-border);
}

.rxt-flag-btn {
  background: none;
  border: none;
  color: var(--rxt-muted);
  font-family: var(--rxt-mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
  transition: all 0.15s;
  line-height: 1;
}

.rxt-flag-btn:hover { background: var(--rxt-surface3); color: var(--rxt-accent2); }
.rxt-flag-btn.is-active {
  background: var(--rxt-accent-soft);
  color: var(--rxt-accent);
  border: 1px solid rgba(124,107,255,0.3);
}

/* Error banner */
.rxt-error-banner {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--rxt-err);
  border-radius: var(--rxt-radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  font-family: var(--rxt-mono);
}

.rxt-error-banner.is-visible { display: flex; }
.rxt-error-banner svg { flex-shrink: 0; width: 15px; height: 15px; }

/* Action buttons row */
.rxt-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rxt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--rxt-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.18s;
  white-space: nowrap;
  font-family: var(--rxt-font);
}

.rxt-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.rxt-btn-primary {
  background: linear-gradient(135deg, var(--rxt-accent), #6b5ce7);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px var(--rxt-glow);
}
.rxt-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 18px var(--rxt-glow);
}

.rxt-btn-outline {
  background: var(--rxt-surface2);
  color: var(--rxt-muted);
  border-color: var(--rxt-border2);
}
.rxt-btn-outline:hover {
  border-color: var(--rxt-accent);
  color: var(--rxt-accent2);
  background: var(--rxt-surface3);
}

.rxt-btn-danger {
  background: rgba(248,113,113,0.1);
  color: var(--rxt-err);
  border-color: rgba(248,113,113,0.25);
}
.rxt-btn-danger:hover {
  background: rgba(248,113,113,0.2);
  border-color: var(--rxt-err);
}

.rxt-match-badge {
  margin-left: auto;
  background: var(--rxt-surface3);
  border: 1px solid var(--rxt-border2);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--rxt-muted);
  white-space: nowrap;
}

.rxt-match-badge.has-matches {
  background: rgba(52,211,153,0.12);
  border-color: rgba(52,211,153,0.3);
  color: var(--rxt-ok);
}

/* ── Two-column Split ──────────────────────────────────────────── */
.rxt-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Panel cards ───────────────────────────────────────────────── */
.rxt-panel {
  background: var(--rxt-surface);
  border: 1px solid var(--rxt-border);
  border-radius: var(--rxt-radius);
  overflow: hidden;
  box-shadow: var(--rxt-shadow-sm);
  display: flex;
  flex-direction: column;
}

.rxt-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rxt-border);
  background: var(--rxt-surface2);
  flex-shrink: 0;
}

.rxt-panel-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--rxt-muted);
}

.rxt-panel-label svg { width: 13px; height: 13px; color: var(--rxt-accent); }

.rxt-panel-meta {
  font-size: 11px;
  color: var(--rxt-faint);
  font-family: var(--rxt-mono);
}

/* ── Test string textarea ──────────────────────────────────────── */
#rxt-teststr {
  width: 100%;
  min-height: 260px;
  max-height: 400px;
  resize: vertical;
  background: transparent;
  border: none;
  outline: none;
  color: var(--rxt-text);
  font-family: var(--rxt-mono);
  font-size: 13.5px;
  line-height: 1.7;
  padding: 16px;
  flex: 1;
}

#rxt-teststr::placeholder { color: var(--rxt-faint); }

/* ── Highlight output (overlay method) ─────────────────────────── */
.rxt-output-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rxt-highlight-area {
  flex: 1;
  min-height: 260px;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  font-family: var(--rxt-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--rxt-text);
  white-space: pre-wrap;
  word-break: break-all;
}

.rxt-highlight-area:empty::before {
  content: 'Highlighted matches will appear here…';
  color: var(--rxt-faint);
  font-style: italic;
}

/* Match highlight span */
.rxt-match {
  background: var(--rxt-match-bg);
  border-bottom: 2px solid var(--rxt-match-bd);
  color: var(--rxt-match-text);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  padding: 0 1px;
  transition: background 0.15s;
}

.rxt-match:hover {
  background: rgba(251,191,36,0.4);
}

/* Tooltip on hover */
.rxt-match[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1e35;
  color: var(--rxt-accent2);
  border: 1px solid var(--rxt-border2);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  font-family: var(--rxt-mono);
}

.rxt-match[data-tip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--rxt-border2);
  z-index: 101;
  pointer-events: none;
}

/* Capture group colors */
.rxt-group-1 { background: rgba(96,165,250,0.2); border-bottom-color: rgba(96,165,250,0.7); color: #60a5fa; }
.rxt-group-2 { background: rgba(167,139,250,0.2); border-bottom-color: rgba(167,139,250,0.7); color: #a78bfa; }
.rxt-group-3 { background: rgba(52,211,153,0.2);  border-bottom-color: rgba(52,211,153,0.7);  color: #34d399; }

/* ── Match Details Panel ───────────────────────────────────────── */
.rxt-details {
  margin-top: 16px;
  background: var(--rxt-surface);
  border: 1px solid var(--rxt-border);
  border-radius: var(--rxt-radius);
  overflow: hidden;
  box-shadow: var(--rxt-shadow-sm);
}

.rxt-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rxt-border);
  background: var(--rxt-surface2);
}

.rxt-details-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--rxt-muted);
}

.rxt-details-title svg { width: 13px; height: 13px; color: var(--rxt-accent); }

.rxt-details-body {
  padding: 4px 0;
  max-height: 220px;
  overflow-y: auto;
}

.rxt-match-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--rxt-border);
  font-size: 13px;
  transition: background 0.15s;
}

.rxt-match-item:last-child { border-bottom: none; }
.rxt-match-item:hover { background: var(--rxt-surface2); }

.rxt-match-num {
  font-family: var(--rxt-mono);
  font-size: 11px;
  color: var(--rxt-faint);
  font-weight: 600;
  padding-top: 1px;
}

.rxt-match-val {
  font-family: var(--rxt-mono);
  font-size: 13px;
  color: var(--rxt-match-text);
  word-break: break-all;
  line-height: 1.5;
}

.rxt-match-pos {
  font-family: var(--rxt-mono);
  font-size: 11px;
  color: var(--rxt-faint);
  white-space: nowrap;
  padding-top: 2px;
}

.rxt-groups-row {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rxt-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--rxt-surface3);
  border: 1px solid var(--rxt-border2);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-family: var(--rxt-mono);
  color: var(--rxt-accent2);
}

.rxt-group-chip .rxt-chip-lbl {
  color: var(--rxt-faint);
  font-size: 10px;
}

.rxt-no-matches {
  padding: 24px;
  text-align: center;
  color: var(--rxt-faint);
  font-size: 13px;
}

/* ── Library Panel ─────────────────────────────────────────────── */
.rxt-library {
  margin-top: 16px;
  background: var(--rxt-surface);
  border: 1px solid var(--rxt-border);
  border-radius: var(--rxt-radius);
  overflow: hidden;
  box-shadow: var(--rxt-shadow-sm);
}

.rxt-library-head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rxt-border);
  background: var(--rxt-surface2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--rxt-muted);
}

.rxt-library-head svg { width: 13px; height: 13px; color: var(--rxt-accent); }

.rxt-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--rxt-border);
}

.rxt-lib-item {
  background: var(--rxt-surface);
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.rxt-lib-item:hover { background: var(--rxt-surface2); }

.rxt-lib-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--rxt-text);
  margin-bottom: 3px;
}

.rxt-lib-pattern {
  font-family: var(--rxt-mono);
  font-size: 11px;
  color: var(--rxt-accent);
  word-break: break-all;
  line-height: 1.5;
}

/* ── SEO Section ───────────────────────────────────────────────── */
.rxt-seo {
  margin-top: 56px;
  padding: 0 4px 48px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.rxt-seo h2 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px;
  padding-top: 36px;
  border-top: 1px solid var(--rxt-border);
}

.rxt-seo h2:first-child { border-top: none; padding-top: 0; }

.rxt-seo p {
  color: var(--rxt-muted);
  font-size: 14px;
  line-height: 1.8;
  margin: 0 0 14px;
}

.rxt-seo code {
  font-family: var(--rxt-mono);
  font-size: 12.5px;
  background: var(--rxt-surface2);
  border: 1px solid var(--rxt-border);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--rxt-accent2);
}

.rxt-seo table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 14px;
}

.rxt-seo th, .rxt-seo td {
  padding: 9px 14px;
  text-align: left;
  border: 1px solid var(--rxt-border);
}

.rxt-seo th {
  background: var(--rxt-surface2);
  color: var(--rxt-text);
  font-weight: 600;
}

.rxt-seo td {
  color: var(--rxt-muted);
  background: var(--rxt-surface);
}

.rxt-seo td:first-child { font-family: var(--rxt-mono); color: var(--rxt-accent2); }

.rxt-faq-item {
  border: 1px solid var(--rxt-border);
  border-radius: var(--rxt-radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.rxt-faq-q {
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--rxt-text);
  background: var(--rxt-surface2);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.rxt-faq-q:hover { background: var(--rxt-surface3); }

.rxt-faq-chevron {
  transition: transform 0.2s;
  color: var(--rxt-muted);
  flex-shrink: 0;
}

.rxt-faq-item.is-open .rxt-faq-chevron { transform: rotate(180deg); }

.rxt-faq-a {
  display: none;
  padding: 13px 16px;
  color: var(--rxt-muted);
  font-size: 13.5px;
  line-height: 1.75;
  background: var(--rxt-surface);
  border-top: 1px solid var(--rxt-border);
}

.rxt-faq-item.is-open .rxt-faq-a { display: block; }

/* ── Toast ─────────────────────────────────────────────────────── */
.rxt-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--rxt-surface3);
  border: 1px solid var(--rxt-border2);
  border-radius: 100px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rxt-text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}

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

/* ── Scrollbars ────────────────────────────────────────────────── */
#rxt-root ::-webkit-scrollbar { width: 5px; height: 5px; }
#rxt-root ::-webkit-scrollbar-track { background: transparent; }
#rxt-root ::-webkit-scrollbar-thumb { background: var(--rxt-border2); border-radius: 99px; }
#rxt-root ::-webkit-scrollbar-thumb:hover { background: var(--rxt-faint); }

/* ── Animations ────────────────────────────────────────────────── */
@keyframes rxt-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rxt-topbar,
.rxt-split,
.rxt-details,
.rxt-library {
  animation: rxt-fade-in 0.35s ease both;
}

.rxt-split  { animation-delay: 0.05s; }
.rxt-details{ animation-delay: 0.1s; }
.rxt-library{ animation-delay: 0.15s; }

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .rxt-hero { padding: 40px 20px 28px; }

  .rxt-split { grid-template-columns: 1fr; }

  .rxt-pattern-row { flex-wrap: wrap; }
  .rxt-pattern-wrap { width: 100%; }

  .rxt-actions-row { flex-wrap: wrap; }
  .rxt-actions-row .rxt-btn { flex: 1 1 auto; justify-content: center; }
  .rxt-match-badge { width: 100%; text-align: center; margin-left: 0; }

  .rxt-library-grid { grid-template-columns: 1fr 1fr; }

  .rxt-match-item { grid-template-columns: 36px 1fr; }
  .rxt-match-pos { display: none; }
}

@media (max-width: 480px) {
  .rxt-library-grid { grid-template-columns: 1fr; }
  .rxt-flags-inline { gap: 0; }
}
