/* Page Layout */
.regex-page-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 15px 40px;
  background: #faf8f5;
  min-height: 100vh;
}

/* Ad Sections */
.dedicated-ad-section {
  margin: 32px 0;
  padding: 16px 0;
}

.ad-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ad-label::before,
.ad-label::after {
  content: '';
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #d1d5db, transparent);
}

.ad-label-text {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #9ca3af;
}

.bottom-ad-section {
  margin: 40px 0 20px 0;
  padding: 16px 0;
}

.top-ad-section {
  margin: 0 0 24px 0;
  min-height: 90px;
}

/* Main Container */
.regex-tool {
  max-width: 900px;
  width: 100%;
  padding: 0;
  background: #faf8f5;
}

body:has(.regex-tool) {
  background: #faf8f5 !important;
}

.regex-tool .main-content {
  background: #faf8f5;
}

.regex-tester-main {
  display: block;
}

/* Header */
.regex-tool .tool-header {
  text-align: center;
  margin-bottom: 20px;
  padding: 40px 30px;
  background: linear-gradient(135deg, #292524 0%, #44403c 100%);
  border-radius: 16px;
  color: #faf8f5;
  box-shadow: 0 4px 20px rgba(41, 37, 36, 0.2);
}

.regex-tool .tool-intro {
  text-align: center;
  color: #57534e;
  font-size: 0.95rem;
  line-height: 1.7;
  max-width: 700px;
  margin: 0 auto 24px;
  padding: 0 16px;
}

.regex-tool .tool-intro strong {
  color: #44403c;
}

.regex-tool .tool-title {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.regex-tool .tool-title i {
  font-size: 1.6rem;
  color: #a5f3fc;
}

.regex-tool .tool-subtitle {
  font-size: 1rem;
  margin: 0;
  opacity: 0.75;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 400;
  color: #d6d3d1;
}

/* Input Sections */
.regex-tool .input-section {
  margin-bottom: 20px;
}

.regex-tool .input-section label {
  display: block;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.pattern-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 8px;
  padding: 4px 8px;
  transition: border-color 0.2s ease;
}

.pattern-input-wrapper:focus-within {
  border-color: #a8a29e;
}

.pattern-delimiter {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 1.1rem;
  color: #78716c;
  padding: 0 4px;
  user-select: none;
}

.pattern-input-wrapper input {
  flex: 1;
  padding: 10px 8px;
  font-size: 1rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  border: none;
  outline: none;
  background: transparent;
  color: #292524;
}

.pattern-input-wrapper input::placeholder {
  color: #a8a29e;
  font-size: 0.9rem;
}

.flags-container {
  display: flex;
  gap: 4px;
  padding-left: 8px;
  border-left: 1px solid #e7e0d5;
  margin-left: 8px;
}

.flag-btn {
  width: 28px;
  height: 28px;
  border: 2px solid #e7e0d5;
  border-radius: 4px;
  background: #fffdf9;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: #a8a29e;
  cursor: pointer;
  transition: all 0.15s ease;
}

.flag-btn:hover {
  border-color: #78716c;
  color: #44403c;
}

.flag-btn.active {
  background: #292524;
  border-color: #292524;
  color: #fef3c7;
}

.pattern-error {
  margin-top: 8px;
  padding: 8px 12px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  display: none;
}

.pattern-error.visible {
  display: block;
}

.test-string-wrapper textarea,
.regex-tool textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  border: 2px solid #e7e0d5;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s ease;
  background: #fffdf9;
  resize: vertical;
  line-height: 1.6;
}

.regex-tool textarea:focus {
  border-color: #a8a29e;
}

.regex-tool textarea::placeholder {
  color: #a8a29e;
}

/* Results */
.results-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.result-card {
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 12px;
  padding: 20px;
}

.result-card h3 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #78716c;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-card h3 i {
  color: #78716c;
}

.match-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  background: #292524;
  color: #fef3c7;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 4px;
}

.match-count.has-matches {
  background: #166534;
}

.highlighted-result {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.8;
  color: #44403c;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  padding: 12px;
  background: #f5f0e8;
  border-radius: 8px;
}

.highlighted-result .placeholder {
  color: #a8a29e;
  font-style: italic;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.highlighted-result .match {
  background: #fef3c7;
  border-radius: 2px;
  padding: 1px 2px;
  border-bottom: 2px solid #f59e0b;
}

.highlighted-result .match-alt {
  background: #a5f3fc;
  border-radius: 2px;
  padding: 1px 2px;
  border-bottom: 2px solid #0891b2;
}

.capture-groups {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
}

.capture-groups .placeholder {
  color: #a8a29e;
  font-style: italic;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.capture-group-item {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f5f0e8;
}

.capture-group-item:last-child {
  border-bottom: none;
}

.group-label {
  font-weight: 600;
  color: #78716c;
  min-width: 60px;
}

.group-value {
  color: #292524;
  background: #f5f0e8;
  padding: 2px 8px;
  border-radius: 4px;
  flex: 1;
  word-break: break-all;
}

.match-separator {
  padding: 12px 0 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #a8a29e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-top: 1px dashed #e7e0d5;
  margin-top: 8px;
}

/* Pattern Explanation */
.explanation-section {
  margin-bottom: 24px;
}

.explanation-section h3 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #44403c;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.explanation-section h3 i {
  color: #78716c;
}

.pattern-explanation {
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 0.9rem;
}

.pattern-explanation .placeholder {
  color: #a8a29e;
  font-style: italic;
}

.explanation-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f5f0e8;
  align-items: flex-start;
}

.explanation-item:last-child {
  border-bottom: none;
}

.explanation-token {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  background: #292524;
  color: #fef3c7;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  min-width: 80px;
  text-align: center;
  flex-shrink: 0;
}

.explanation-desc {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: #44403c;
  line-height: 1.5;
}

/* Share Section */
.share-section {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
  padding-top: 8px;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  padding: 10px 18px;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #292524;
  color: #faf8f5;
  box-shadow: 0 2px 8px rgba(41, 37, 36, 0.2);
}

.btn-primary:hover {
  background: #44403c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(41, 37, 36, 0.25);
}

.btn-secondary {
  background: #fffdf9;
  color: #44403c;
  border: 2px solid #e7e0d5;
}

.btn-secondary:hover {
  background: #f5f0e8;
  border-color: #d6cfc4;
}

.btn-secondary.copied {
  background: #166534;
  color: white;
  border-color: #166534;
}

/* Quick Reference */
.reference-section {
  margin-bottom: 32px;
}

.reference-section h3 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #44403c;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reference-section h3 i {
  color: #78716c;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.reference-card {
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 10px;
  padding: 16px 20px;
}

.reference-card h4 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: #78716c;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e7e0d5;
}

.reference-card table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
  background: transparent;
}

.reference-card tr {
  border: none;
  background: transparent;
}

.reference-card td {
  padding: 5px 0;
  color: #44403c;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  border: none;
  background: transparent;
}

.reference-card td:first-child {
  width: 70px;
}

.reference-card td:last-child {
  color: #78716c;
  font-size: 0.8rem;
}

.reference-card code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  background: #292524;
  color: #fef3c7;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Examples Table */
.examples-table-section {
  margin-bottom: 32px;
}

.examples-table-section h3 i.fa-lightbulb {
  color: #b45309;
}

.examples-intro {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  color: #78716c;
  margin: 0 0 16px 0;
  line-height: 1.5;
}

.regex-examples-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 12px;
  overflow: hidden;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.regex-examples-table thead tr {
  background: #292524 !important;
}

.regex-examples-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #faf8f5 !important;
  background: #292524 !important;
  border: none !important;
}

.regex-examples-table tbody tr {
  border-bottom: 1px solid #e7e0d5;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fffdf9;
}

.regex-examples-table tbody tr:nth-child(even) {
  background: #faf8f5;
}

.regex-examples-table tbody tr:last-child {
  border-bottom: none;
}

.regex-examples-table tbody tr:hover {
  background: #f5f0e8 !important;
}

.regex-examples-table tbody tr:active {
  background: #e7e0d5 !important;
}

.regex-examples-table td {
  padding: 10px 16px;
  font-size: 0.9rem;
  color: #44403c;
  vertical-align: middle;
  border: none !important;
  background: transparent !important;
}

.regex-examples-table td:first-child {
  max-width: 200px;
}

.regex-examples-table td:first-child code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  background: #292524 !important;
  color: #fef3c7 !important;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  display: inline-block;
  border: none !important;
  font-weight: 500;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.regex-examples-table td:nth-child(2) {
  font-weight: 500;
  color: #292524;
}

.regex-examples-table td:last-child {
  color: #a8a29e;
  font-size: 0.75rem;
  width: 90px;
  text-align: right;
}

/* Syntax Guide */
.syntax-guide-section {
  margin-bottom: 32px;
}

.syntax-guide-section > h3 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #44403c;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.syntax-guide-section > h3 i.fa-graduation-cap {
  color: #7c3aed;
}

.syntax-guide-content {
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 12px;
  overflow: hidden;
}

.guide-article {
  padding: 24px 28px;
  border-bottom: 1px solid #e7e0d5;
}

.guide-article:last-child {
  border-bottom: none;
}

.guide-article h2 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #292524;
  margin: 0 0 12px 0;
}

.guide-article h3 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #44403c;
  margin: 16px 0 8px 0;
}

.guide-article h3:first-of-type {
  margin-top: 0;
}

.guide-article p {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  color: #57534e;
  margin: 0 0 12px 0;
  line-height: 1.7;
}

.guide-article p:last-child {
  margin-bottom: 0;
}

.guide-article ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.guide-article ul li {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  color: #57534e;
  line-height: 1.7;
  padding: 8px 0 8px 20px;
  position: relative;
  border-bottom: 1px solid #f5f0e8;
}

.guide-article ul li:last-child {
  border-bottom: none;
}

.guide-article ul li::before {
  content: "•";
  color: #7c3aed;
  font-weight: bold;
  position: absolute;
  left: 0;
}

.guide-article code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  background: #292524;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #fef3c7;
}

/* FAQ */
.faq-section {
  margin-bottom: 40px;
  padding: 30px;
  background: #f5f0e8;
  border-radius: 16px;
  border: 2px solid #e7e0d5;
}

.faq-section h2 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #44403c;
  margin: 0 0 24px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.faq-section h2 i {
  color: #78716c;
}

.faq-item {
  background: #fffdf9;
  border: 2px solid #e7e0d5;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
}

.faq-item:last-child {
  margin-bottom: 0;
}

.faq-item h3 {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #292524;
  margin: 0 0 10px 0;
}

.faq-item p {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  color: #78716c;
  margin: 0;
  line-height: 1.6;
}

.faq-item code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  background: #292524;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #fef3c7;
}

/* Responsive */

@media (max-width: 768px) {
  .regex-page-wrapper {
    padding: 15px 12px 30px;
  }

  .dedicated-ad-section,
  .bottom-ad-section {
    margin: 24px 0;
    padding: 12px 0;
  }

  .regex-tool .tool-header {
    padding: 30px 20px;
    border-radius: 12px;
  }

  .regex-tool .tool-title {
    font-size: 1.5rem;
  }

  .pattern-input-wrapper {
    flex-wrap: wrap;
    padding: 8px;
  }

  .pattern-input-wrapper input {
    width: 100%;
    order: 1;
  }

  .pattern-delimiter:first-child {
    order: 0;
  }

  .pattern-delimiter:nth-child(3) {
    display: none;
  }

  .flags-container {
    order: 2;
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px solid #e7e0d5;
    justify-content: center;
  }

  .results-section {
    grid-template-columns: 1fr;
  }

  .reference-grid {
    grid-template-columns: 1fr;
  }

  .share-section {
    flex-direction: column;
  }

  .share-section .btn-secondary {
    justify-content: center;
  }

  .regex-examples-table td:last-child,
  .regex-examples-table th:last-child {
    display: none;
  }

  .regex-examples-table td {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .regex-examples-table th {
    padding: 10px 12px;
    font-size: 0.7rem;
  }

  .regex-examples-table td:first-child code {
    font-size: 0.7rem;
    padding: 5px 8px;
    max-width: 140px;
  }

  .faq-section {
    padding: 20px;
  }

  .guide-article {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .regex-tool .tool-title {
    font-size: 1.3rem;
    flex-direction: column;
    gap: 8px;
  }

  .flag-btn {
    width: 32px;
    height: 32px;
  }

  .regex-examples-table td:first-child code {
    font-size: 0.65rem;
    padding: 4px 6px;
    max-width: 110px;
  }

  .regex-examples-table td:nth-child(2) {
    font-size: 0.8rem;
  }

  .explanation-item {
    flex-direction: column;
    gap: 6px;
  }

  .explanation-token {
    min-width: auto;
    align-self: flex-start;
  }
}
