
/* ========== Regex Tester Tool Page ========== */
.tool-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.tool-header {
  text-align: center;
  margin-bottom: 24px;
}

.tool-header h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-heading);
  margin-bottom: 8px;
}

.tool-header .tool-desc {
  font-size: 16px;
  color: var(--color-muted);
  max-width: 750px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Regex Input Row */
.regex-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
  background: #1e1e2e;
  border-radius: 12px;
  border: 1px solid #45475a;
}

.regex-label {
  color: #f38ba8;
  font-weight: 700;
  font-size: 16px;
  font-family: 'Consolas', monospace;
  user-select: none;
}

.regex-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 16px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 15px;
  background: #313244;
  color: #cdd6f4;
  border: 1px solid #585b70;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.regex-input:focus {
  border-color: #89b4fa;
}

.regex-input::placeholder {
  color: #6c7086;
}

.regex-delimiter {
  color: #a6adc8;
  font-weight: 600;
  font-size: 16px;
  font-family: 'Consolas', monospace;
  user-select: none;
}

/* Flags */
.flags-group {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  background: #313244;
  border-radius: 6px;
}

.flag-btn {
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Consolas', monospace;
  background: transparent;
  color: #6c7086;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.flag-btn:hover {
  color: #a6adc8;
  background: rgba(255,255,255,0.05);
}

.flag-btn.active {
  color: #f5c2e7;
  background: rgba(245,194,231,0.15);
  border-color: #f5c2e7;
}

/* Toolbar */
.tool-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--color-bg-card);
  border-radius: 12px;
  border: 1px solid var(--color-border);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.tool-btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.tool-btn-secondary {
  background: #10b981;
  color: #fff;
}

.tool-btn-secondary:hover {
  background: #059669;
}

.tool-btn-outline {
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.tool-btn-outline:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-primary);
}

.tool-btn-danger {
  background: #ef4444;
  color: #fff;
}

.tool-btn-danger:hover {
  background: #dc2626;
}

.tool-btn-purple {
  background: #8b5cf6;
  color: #fff;
}

.tool-btn-purple:hover {
  background: #7c3aed;
  transform: translateY(-1px);
}

/* Mode tabs */
.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f3f4f6;
  border-radius: 8px;
  margin-bottom: 16px;
}

.mode-tab {
  flex: 1;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: #6b7280;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.mode-tab:hover {
  color: #374151;
  background: rgba(0,0,0,0.03);
}

.mode-tab.active {
  background: #fff;
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Replace input row */
.replace-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 8px;
}

.replace-label {
  font-size: 14px;
  font-weight: 600;
  color: #92400e;
  white-space: nowrap;
}

.replace-input {
  flex: 1;
  padding: 8px 12px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  outline: none;
  background: #fff;
}

.replace-input:focus {
  border-color: #f59e0b;
}

/* Main editor area */
.tool-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.editor-panel {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

.editor-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
}

.editor-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-heading);
}

.editor-panel-header .panel-actions {
  display: flex;
  gap: 8px;
}

.panel-btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
}

.panel-btn:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-primary);
}

.editor-panel textarea {
  width: 100%;
  height: 300px;
  padding: 16px;
  border: none;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
}

.editor-panel textarea:focus {
  outline: none;
}

.editor-panel textarea::placeholder {
  color: #6c7086;
}

/* Output / match result area */
.match-output {
  height: 300px;
  padding: 16px;
  overflow: auto;
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.match-output .match-highlight {
  background: rgba(250, 179, 135, 0.4);
  border-radius: 3px;
  border-bottom: 2px solid #fab387;
  cursor: pointer;
  transition: background 0.15s;
}

.match-output .match-highlight:hover {
  background: rgba(250, 179, 135, 0.6);
}

.match-output .match-highlight.group-1 {
  background: rgba(137, 180, 250, 0.35);
  border-bottom-color: #89b4fa;
}

.match-output .match-highlight.group-2 {
  background: rgba(166, 227, 161, 0.35);
  border-bottom-color: #a6e3a1;
}

.match-output .match-highlight.group-3 {
  background: rgba(243, 139, 168, 0.35);
  border-bottom-color: #f38ba8;
}

/* Replace result */
.replace-result {
  height: 300px;
  padding: 16px;
  overflow: auto;
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Stats bar */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 16px;
  background: #1e1e2e;
  border-top: 1px solid #45475a;
  font-size: 13px;
  color: #a6adc8;
  font-family: 'Consolas', monospace;
}

.stats-bar .stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stats-bar .stat-value {
  color: #f5c2e7;
  font-weight: 700;
}

/* Match details panel */
.details-panel {
  margin-bottom: 20px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

.details-panel-header {
  padding: 12px 16px;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-heading);
}

.details-content {
  padding: 12px 16px;
  max-height: 300px;
  overflow: auto;
}

.match-group-card {
  margin-bottom: 8px;
  padding: 10px 14px;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.match-group-card:last-child {
  margin-bottom: 0;
}

.match-group-card .match-num {
  font-weight: 700;
  color: var(--color-primary);
  margin-right: 8px;
}

.match-group-card .match-text {
  color: #059669;
}

.match-group-card .match-pos {
  color: #6b7280;
  font-size: 12px;
  margin-left: 8px;
}

.match-group-card .sub-group {
  padding: 4px 0 4px 24px;
  font-size: 13px;
  color: #6b7280;
}

.match-group-card .sub-group .group-label {
  color: #9333ea;
  font-weight: 600;
}

.match-group-card .sub-group .group-text {
  color: #374151;
}

.details-empty {
  padding: 24px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

/* Regex explanation panel */
.explain-panel {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  display: none;
}

.explain-panel.visible {
  display: block;
}

.explain-panel .explain-title {
  font-size: 14px;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 10px;
}

.explain-item {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-size: 14px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  line-height: 1.8;
}

.explain-item .exp-token {
  color: #9333ea;
  font-weight: 600;
  min-width: 60px;
}

.explain-item .exp-arrow {
  color: #6b7280;
}

.explain-item .exp-meaning {
  color: #374151;
  font-family: system-ui, -apple-system, sans-serif;
}

/* Common patterns area */
.patterns-section {
  margin-bottom: 20px;
  padding: 20px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.patterns-section h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 16px;
}

.pattern-category {
  margin-bottom: 14px;
}

.pattern-category:last-child {
  margin-bottom: 0;
}

.pattern-cat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.pattern-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pattern-tag {
  padding: 5px 12px;
  font-size: 12px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.pattern-tag:hover {
  border-color: var(--color-primary);
  background: #eff6ff;
  color: var(--color-primary);
}

.pattern-tag .pattern-desc {
  font-family: system-ui, -apple-system, sans-serif;
  color: #6b7280;
  margin-left: 4px;
  font-size: 11px;
}

/* Syntax reference */
.syntax-ref {
  margin-bottom: 20px;
  padding: 20px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.syntax-ref h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 16px;
}

.syntax-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.syntax-table th {
  text-align: left;
  padding: 8px 12px;
  background: #f3f4f6;
  font-weight: 600;
  color: var(--color-heading);
  border-bottom: 2px solid var(--color-border);
}

.syntax-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--color-text);
  line-height: 1.5;
}

.syntax-table code {
  font-family: 'Consolas', monospace;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #9333ea;
}

.syntax-table tr:hover td {
  background: #fafafa;
}

/* Error display */
.error-box {
  padding: 16px 20px;
  margin: 16px 0;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
}

.error-box .error-icon {
  font-size: 20px;
  margin-right: 8px;
}

/* Success indicator */
.success-box {
  padding: 12px 16px;
  margin: 16px 0;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #16a34a;
  font-weight: 600;
}

/* Info section */
.tool-info {
  margin-top: 32px;
  padding: 24px;
  background: var(--color-bg-card);
  border-radius: 12px;
  border: 1px solid var(--color-border);
}

.tool-info h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 16px;
}

.tool-info h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-heading);
  margin: 20px 0 12px;
}

.tool-info p {
  font-size: 15px;
  color: var(--color-text);
  line-height: 1.8;
  margin-bottom: 12px;
}

.tool-info ul {
  margin: 0 0 16px 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text);
}

.tool-info li {
  margin-bottom: 6px;
}

/* Responsive */
@media (max-width: 900px) {
  .tool-editor {
    grid-template-columns: 1fr;
  }

  .editor-panel textarea,
  .match-output,
  .replace-result {
    height: 250px;
  }

  .regex-row {
    flex-direction: column;
    align-items: stretch;
  }

  .regex-input {
    min-width: auto;
  }

  .pattern-tag {
    font-size: 11px;
    padding: 4px 10px;
  }
}

@media (max-width: 600px) {
  .tool-container {
    padding: 16px;
  }

  .tool-header h1 {
    font-size: 24px;
  }

  .tool-toolbar {
    padding: 12px;
    gap: 8px;
  }

  .tool-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .editor-panel textarea,
  .match-output,
  .replace-result {
    height: 200px;
  }

  .syntax-table {
    font-size: 12px;
  }

  .syntax-table th,
  .syntax-table td {
    padding: 6px 8px;
  }
}
