/* =======================================================
   REGEX TESTER & EXPLAINER STYLESHEET
   ======================================================= */

.regex-tool {
  margin: 1.5rem 0 3rem;
}

.regex-main-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

@media (max-width: 1024px) {
  .regex-main-layout {
    flex-direction: column;
    align-items: stretch;
  }
}

.regex-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0; /* Prevents overflow */
}

.regex-sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .regex-sidebar {
    width: 100%;
  }
}

/* Workspace Cards */
.workspace-card {
  background: rgba(10, 15, 30, 0.65);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.workspace-card h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  color: var(--accent, #00f0ff);
  margin-top: 0;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.section-desc {
  font-size: 0.88rem;
  color: var(--text-secondary, #cccccc);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* Preset Select */
.preset-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.preset-row label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary, #ffffff);
}

.preset-row select {
  flex: 1;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.4);
  color: #ffffff;
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.preset-row select:focus {
  border-color: var(--accent, #00f0ff);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.25);
}

/* Pattern Container */
.regex-input-container {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
  transition: border-color 0.2s ease;
}

.regex-input-container:focus-within {
  border-color: var(--accent, #00f0ff);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.5), 0 0 8px rgba(0, 240, 255, 0.2);
}

.regex-slash {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.4rem;
  color: var(--accent, #00f0ff);
  font-weight: bold;
  user-select: none;
}

#val-regex-pattern {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.05rem;
  padding: 0.25rem 0.5rem;
}

.flags-display, .flags-indicator {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.05rem;
  color: #9d4edd;
  font-weight: bold;
  user-select: none;
  letter-spacing: 1px;
}

/* Flags Selector Checkboxes */
.flags-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 1rem;
}

.flag-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary, #cccccc);
  cursor: pointer;
  user-select: none;
}

.flag-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Error status block */
.error-console {
  background: rgba(0, 255, 102, 0.05);
  border: 1px solid rgba(0, 255, 102, 0.2);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: monospace;
  font-size: 0.85rem;
  color: #00ff66;
  line-height: 1.4;
  word-break: break-all;
}

.error-console.error {
  background: rgba(255, 50, 50, 0.06);
  border-color: rgba(255, 50, 50, 0.25);
  color: #ff3333;
}

/* Editor Stage: Overlay highlights */
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header-row h3 {
  margin: 0;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-secondary, #999);
  font-family: monospace;
}

.editor-stage {
  position: relative;
  height: 200px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
  box-sizing: border-box;
}

.editor-stage textarea, .editor-stage .highlight-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 12px 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  border: none;
  outline: none;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: transparent;
}

.editor-stage textarea {
  color: transparent;
  caret-color: #ffffff; /* Keep blinking caret visible */
  z-index: 2;
  resize: none;
}

.editor-stage .highlight-overlay {
  color: #b0c4de;
  z-index: 1;
  overflow-y: auto;
  pointer-events: none; /* Let click events slide through to textarea */
}

/* Mark styling inside overlays */
.editor-stage .highlight-overlay mark {
  background: rgba(0, 240, 255, 0.25);
  border-bottom: 2px solid rgba(0, 240, 255, 0.8);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.editor-stage .highlight-overlay mark:nth-child(even) {
  background: rgba(157, 78, 221, 0.25);
  border-bottom-color: rgba(157, 78, 221, 0.8);
}

/* Explainer List */
.explanation-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
}

.explainer-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid rgba(255, 255, 255, 0.15);
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-secondary, #cccccc);
}

.explainer-item.group {
  border-left-color: #9d4edd;
}

.explainer-item.class {
  border-left-color: #00f0ff;
}

.explainer-item.quantifier {
  border-left-color: #00ff66;
}

.explainer-item.anchor {
  border-left-color: #ffaa00;
}

.explainer-token {
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  align-self: flex-start;
  white-space: nowrap;
}

.explainer-desc {
  flex: 1;
}

.explainer-desc strong {
  color: #ffffff;
}

/* Matches Panel details */
.results-card {
  display: flex;
  flex-direction: column;
  height: 250px;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.count-badge {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: 'Orbitron', sans-serif;
  color: var(--accent, #00f0ff);
  background: rgba(0, 240, 255, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.matches-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.match-item {
  padding: 0.6rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
}

.match-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-weight: bold;
  color: var(--accent, #00f0ff);
  font-family: monospace;
}

.match-item-value {
  font-family: 'Courier New', Courier, monospace;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  color: #ffffff;
  word-break: break-all;
  border: 1px solid rgba(255,255,255,0.02);
}

.groups-list {
  margin-top: 0.4rem;
  padding-left: 0.5rem;
  border-left: 1px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.group-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary, #999);
}

.group-row span:last-child {
  font-family: monospace;
  color: #9d4edd;
}

/* Cheat sheet list styles */
.cheatsheet-card {
  display: flex;
  flex-direction: column;
  height: 310px;
}

.cheatsheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.cheatsheet-header h3 {
  margin: 0;
}

.cheatsheet-header select {
  padding: 0.3rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  color: #ffffff;
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
}

.cheatsheet-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cheatsheet-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cheatsheet-item:hover {
  background: rgba(0, 240, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.3);
}

.cheatsheet-item-code {
  font-family: monospace;
  font-weight: bold;
  color: var(--accent, #00f0ff);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.cheatsheet-item-lbl {
  color: var(--text-secondary, #cccccc);
}

.cheatsheet-tip {
  font-size: 0.72rem;
  color: var(--text-secondary, #999);
  margin: 0.5rem 0 0 0;
  text-align: center;
}

/* Scrollbar overrides for lists */
.explanation-list::-webkit-scrollbar,
.matches-list::-webkit-scrollbar,
.cheatsheet-list::-webkit-scrollbar,
.editor-stage .highlight-overlay::-webkit-scrollbar {
  width: 4px;
}

.explanation-list::-webkit-scrollbar-track,
.matches-list::-webkit-scrollbar-track,
.cheatsheet-list::-webkit-scrollbar-track,
.editor-stage .highlight-overlay::-webkit-scrollbar-track {
  background: transparent;
}

.explanation-list::-webkit-scrollbar-thumb,
.matches-list::-webkit-scrollbar-thumb,
.cheatsheet-list::-webkit-scrollbar-thumb,
.editor-stage .highlight-overlay::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.explanation-list::-webkit-scrollbar-thumb:hover,
.matches-list::-webkit-scrollbar-thumb:hover,
.cheatsheet-list::-webkit-scrollbar-thumb:hover,
.editor-stage .highlight-overlay::-webkit-scrollbar-thumb:hover {
  background: var(--accent, #00f0ff);
}
