/* RegexVision Pro — Ultra-Compact Single Screen Dashboard */

:root {
  --bg: #f8faf6;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  
  --tok-anchor: #2563eb;
  --tok-charset: #15803d;
  --tok-quant: #ea580c;
  --tok-lookahead: #9333ea;
  --tok-wildcard: #0d9488;
  --tok-literal: #475569;
}

html.dark {
  --bg: #0a0e1a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  
  --tok-anchor: #93c5fd;
  --tok-charset: #86efac;
  --tok-quant: #fdba74;
  --tok-lookahead: #d8b4fe;
  --tok-wildcard: #5eead4;
  --tok-literal: #cbd5e1;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -999px;
  background: var(--accent);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Fixed Sidebar */
.sidebar-fixed {
  width: 16rem;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-item:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--text);
}

.sidebar-item.active {
  background: rgba(37, 99, 235, 0.15);
  color: var(--accent);
}

/* Compact Scroll */
.compact-scroll::-webkit-scrollbar {
  width: 6px;
}

.compact-scroll::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.compact-card {
  padding: 0.75rem;
}

/* Inputs */
.input-field {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  transition: all 0.15s;
  font-family: inherit;
  resize: vertical;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* Reset Button */
.reset-btn {
  padding: 0.375rem;
  background: transparent;
  border: 1px solid #fecaca;
  border-radius: 0.375rem;
  color: var(--danger);
  cursor: pointer;
  transition: all 0.15s;
}

.reset-btn:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

html.dark .reset-btn:hover {
  background: #450a0a;
}

/* Compact Chips */
.chip-groups.chip-compact {
  pointer-events: all;
}

.chip-groups.chip-groups-disabled {
  pointer-events: none;
  opacity: 0.4;
}

.chip-row-compact {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chip-cat-sm {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 3rem;
  padding-top: 0.375rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card-bg);
}

.chip-sm {
  padding: 0.1875rem 0.5rem;
  font-size: 0.6875rem;
}

.chip-allow {
  color: #0369a1;
  border-color: #bae6fd;
  background: #f0f9ff;
}

html.dark .chip-allow {
  color: #7dd3fc;
  border-color: #0c4a6e;
  background: #082f49;
}

.chip-allow[aria-pressed="true"] {
  color: white;
  background: #0284c7;
  border-color: #0284c7;
}

.chip-forbid {
  color: #be123c;
  border-color: #fecdd3;
  background: #fff1f2;
}

html.dark .chip-forbid {
  color: #fb7185;
  border-color: #881337;
  background: #4c0519;
}

.chip-forbid[aria-pressed="true"] {
  color: white;
  background: #e11d48;
  border-color: #e11d48;
}

.chip-must {
  color: #7c3aed;
  border-color: #ddd6fe;
  background: #faf5ff;
}

html.dark .chip-must {
  color: #c4b5fd;
  border-color: #5b21b6;
  background: #2e1065;
}

.chip-must[aria-pressed="true"] {
  color: white;
  background: #7c3aed;
  border-color: #7c3aed;
}

.chip-anchor[aria-pressed="true"] {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

/* Number Inputs */
.input-group-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.input-group-sm span {
  color: var(--text-muted);
  font-weight: 500;
}

.input-number-sm {
  width: 4rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--card-bg);
  color: var(--text);
  text-align: center;
}

.input-number-sm:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.input-number-sm::placeholder {
  color: var(--text-muted);
  font-size: 0.6875rem;
}

/* Code blocks */
.code-block-sm {
  padding: 0.75rem;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow-x: auto;
  word-break: break-all;
  white-space: pre-wrap;
}

html.dark .code-block-sm {
  background: #0f1729;
}

/* Alerts */
.alert-error {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
}

html.dark .alert-error {
  color: #fca5a5;
  background: #450a0a;
  border-color: #7f1d1d;
}

/* Railroad */
.rail-mount-sm {
  min-height: 80px;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow-x: auto;
}

html.dark .rail-mount-sm {
  background: #0f1729;
}

.rail-mount-sm svg .railroad-text {
  fill: var(--text);
}

.rail-mount-sm svg path {
  stroke: var(--text);
}

/* Token flow */
.token-flow-sm {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.tok-group {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
  border-radius: 0.375rem;
}

.tok-group.anchor {
  color: var(--tok-anchor);
  background: rgba(37, 99, 235, 0.1);
  border-color: currentColor;
}

.tok-group.charset {
  color: var(--tok-charset);
  background: rgba(21, 128, 61, 0.1);
  border-color: currentColor;
}

.tok-group.quantifier {
  color: var(--tok-quant);
  background: rgba(234, 88, 12, 0.1);
  border-color: currentColor;
}

.tok-group.lookahead {
  color: var(--tok-lookahead);
  background: rgba(147, 51, 234, 0.1);
  border-color: currentColor;
}

.tok-group.wildcard {
  color: var(--tok-wildcard);
  background: rgba(13, 148, 136, 0.1);
  border-color: currentColor;
}

.tok-group.literal {
  color: var(--tok-literal);
  background: rgba(71, 85, 105, 0.1);
  border-color: currentColor;
}

/* Step cards */
.step-cards-sm {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.step-group {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: white;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

.step-text {
  flex: 1;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text);
}

/* Template grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.template-grid-compact {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.template-card {
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.template-grid-compact .template-card {
  padding: 0.5rem 0.625rem;
}

.template-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.template-name {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.375rem;
}

.template-grid-compact .template-name {
  font-size: 0.8125rem;
  margin-bottom: 0.125rem;
}

.template-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.template-grid-compact .template-desc {
  display: none;
}

.template-pattern {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.6875rem;
  padding: 0.375rem 0.5rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow-x: auto;
  white-space: nowrap;
}

.template-grid-compact .template-pattern {
  font-size: 0.625rem;
  padding: 0.25rem 0.375rem;
}

html.dark .template-pattern {
  background: #0f1729;
}

/* Syntax tabs */
.syntax-tab {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.syntax-tab:hover {
  color: var(--text);
}

.syntax-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Prose */
.prose-sm {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.prose-sm p {
  margin: 0 0 0.5rem 0;
}

.prose-sm p:last-child {
  margin-bottom: 0;
}

/* Test result */
.test-result {
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
}

.test-result.ok {
  color: #15803d;
  background: #f0fdf4;
}

html.dark .test-result.ok {
  color: #86efac;
  background: #052e16;
}

.test-result.fail {
  color: #991b1b;
  background: #fef2f2;
}

html.dark .test-result.fail {
  color: #fca5a5;
  background: #450a0a;
}

/* Responsive */
@media (max-width: 1280px) {
  #section-builder {
    grid-template-columns: 1fr;
  }
  
  .sidebar-fixed {
    width: 14rem;
  }
}
