/**
 * SQL Formatter Tool Styles
 * Matches the explainer theme: clean, professional, developer-focused
 */

/* Page Layout */
.sql-page-wrapper {
  max-width: 1200px;
  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;
}

/* ==========================================================================
   Layout & Container
   ========================================================================== */

.sql-tool {
  max-width: 1200px;
  width: 100%;
  padding: 0;
  background: #faf8f5;
}

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

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

/* ==========================================================================
   Header
   ========================================================================== */

.sql-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);
}

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

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

.sql-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;
}

.sql-tool .tool-title i {
  font-size: 1.6rem;
  color: #fef3c7;
}

.sql-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;
}

/* ==========================================================================
   Main Controls
   ========================================================================== */

.sql-formatter-main .main-controls {
  margin-bottom: 20px;
}

.sql-formatter-main .action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.sql-formatter-main .action-buttons-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.sql-formatter-main .action-buttons-right {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.sql-tool .btn-primary,
.sql-tool .btn-secondary {
  padding: 10px 20px;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

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

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

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

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

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

.btn-format {
  background: #292524 !important;
  color: #fef3c7 !important;
}

.btn-minify {
  background: #44403c !important;
  color: #faf8f5 !important;
}

/* ==========================================================================
   Options Row
   ========================================================================== */

.options-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
  padding: 12px 18px;
  background: #f5f0e8;
  border: 2px solid #e7e0d5;
  border-radius: 10px;
  flex-wrap: wrap;
}

.option-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  color: #44403c;
  font-weight: 600;
}

.option-group select {
  padding: 6px 12px;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  border: 2px solid #e7e0d5;
  border-radius: 6px;
  background: #fffdf9;
  color: #292524;
  cursor: pointer;
}

.option-group select:focus {
  outline: none;
  border-color: #a8a29e;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d6cfc4;
  transition: 0.3s;
  border-radius: 22px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #292524;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ==========================================================================
   Result Section
   ========================================================================== */

.sql-formatter-main .result-section {
  margin-bottom: 16px;
}

.sql-formatter-main .result-section.hidden {
  display: none;
}

.sql-formatter-main .result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 10px;
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
}

.sql-formatter-main .result-card.success {
  background: #f0fdf4;
  border: 2px solid #bbf7d0;
  color: #166534;
}

.sql-formatter-main .result-card.error {
  background: #fef2f2;
  border: 2px solid #fecaca;
  color: #991b1b;
}

.sql-formatter-main .result-icon i {
  font-size: 1.1rem;
}

/* ==========================================================================
   Editor Panels
   ========================================================================== */

.editor-panels {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  min-height: 400px;
}

.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

body.resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #292524;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.panel-header label {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #faf8f5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.output-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-count {
  font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.75rem;
  color: #a8a29e;
  font-weight: 500;
}

/* Editor container with line numbers */
.editor-container {
  display: flex;
  flex: 1;
  border: 2px solid #e7e0d5;
  border-top: none;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  overflow: hidden;
  background: #fffdf9;
}

.line-numbers {
  width: 40px;
  min-width: 40px;
  padding: 12px 4px 12px 0;
  text-align: right;
  background: #f5f0e8;
  border-right: 1px solid #e7e0d5;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #a8a29e;
  user-select: none;
  overflow: hidden;
}

.output-line-numbers {
  width: 40px;
  min-width: 40px;
  padding: 12px 4px 12px 0 !important;
  text-align: right;
  background: #1e1e1e !important;
  border-right: 1px solid #333;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  color: #858585;
  user-select: none;
  overflow: hidden;
}

.line-numbers span,
.output-line-numbers span {
  display: block;
  padding: 0 6px;
}

/* Output panel dark header border */
.output-panel .panel-header {
  border-bottom: 1px solid #333;
}

.editor-container textarea {
  flex: 1;
  padding: 12px 16px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #1c1917;
  border: none;
  outline: none;
  resize: none;
  background: #fffdf9;
  overflow-y: auto;
  tab-size: 2;
  white-space: pre;
}

.editor-container textarea::placeholder {
  color: #a8a29e;
}

/* Output container */
.output-container {
  display: flex;
  flex: 1;
  border: 2px solid #333;
  border-top: none;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  overflow: hidden;
  background: #1e1e1e;
  min-height: 0;
}

pre.sql-output,
#sql-output {
  flex: 1;
  padding: 12px 16px !important;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  color: #d4d4d4 !important;
  background: #1e1e1e !important;
  margin: 0 !important;
  overflow-y: auto !important;
  white-space: pre !important;
  word-wrap: normal !important;
  border: none !important;
  border-radius: 0 !important;
  min-height: 0;
}

.output-placeholder {
  color: #6A6A6A;
  font-style: italic;
}

/* Panel Resizer */
.panel-resizer {
  flex: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s ease;
  z-index: 2;
}

.panel-resizer:hover,
.panel-resizer.dragging {
  background: #e7e0d5;
}

.resizer-handle {
  width: 3px;
  height: 40px;
  background: #d6cfc4;
  border-radius: 2px;
  transition: background 0.2s ease;
}

.panel-resizer:hover .resizer-handle,
.panel-resizer.dragging .resizer-handle {
  background: #78716c;
}

/* ==========================================================================
   SQL Syntax Highlighting — VS Code Dark+ Theme
   ========================================================================== */

.sql-keyword {
  color: #569CD6;
  font-weight: 600;
}

.sql-string {
  color: #CE9178;
}

.sql-number {
  color: #B5CEA8;
}

.sql-comment {
  color: #6A9955;
  font-style: italic;
}

.sql-identifier {
  color: #4EC9B0;
}

.sql-operator {
  color: #D4D4D4;
}

.sql-paren {
  color: #FFD700;
  font-weight: 600;
}

.sql-punctuation {
  color: #D4D4D4;
}

.sql-word {
  color: #FAF8F5;
}

/* ==========================================================================
   Reference Section
   ========================================================================== */

.sql-tool .reference-section {
  margin-bottom: 32px;
}

.sql-tool .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;
}

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

.sql-tool .reference-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.sql-tool .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;
}

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

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

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

.sql-tool .reference-card td:first-child {
  font-weight: 600;
  color: #292524;
}

.sql-tool .reference-card td:last-child {
  text-align: right;
  color: #78716c;
  font-size: 0.8rem;
}

.sql-tool .reference-card code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  background: #f5f0e8;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
  color: #44403c;
  font-weight: 600;
  border: 1px solid #e7e0d5;
}

/* ==========================================================================
   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;
}

.sql-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;
}

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

.sql-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;
}

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

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

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

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

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

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

.sql-examples-table td:first-child {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  color: #292524;
  font-weight: 500;
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

/* ==========================================================================
   Syntax Guide
   ========================================================================== */

.sql-tool .syntax-guide-section {
  margin-bottom: 32px;
}

.sql-tool .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;
}

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

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

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

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

.sql-tool .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;
}

.sql-tool .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;
}

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

.sql-tool .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;
}

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

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

.sql-tool .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;
}

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

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

.sql-tool .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;
}

.sql-tool .syntax-diagram {
  background: #292524;
  color: #a8a29e;
  padding: 20px;
  border-radius: 8px;
  margin: 16px 0;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
}

.sql-tool .syntax-diagram code {
  background: transparent;
  padding: 0;
  color: inherit;
  display: block;
}

/* ==========================================================================
   FAQ Section
   ========================================================================== */

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

.sql-tool .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;
}

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

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

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

.sql-tool .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;
}

.sql-tool .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;
}

.sql-tool .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 Design
   ========================================================================== */

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

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

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

  .editor-panels {
    flex-direction: column;
    gap: 16px;
  }

  .panel-resizer {
    display: none;
  }

  .panel {
    flex: none !important;
  }

  .sql-formatter-main .action-buttons {
    flex-wrap: wrap;
  }

  .sql-formatter-main .action-buttons-right {
    margin-left: 0;
    width: 100%;
  }

  .options-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

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

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

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

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

  .sql-examples-table td:first-child {
    max-width: 200px;
    font-size: 0.75rem;
  }

  .sql-tool .faq-section {
    padding: 20px;
  }

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

@media (max-width: 480px) {
  .sql-tool .tool-title {
    font-size: 1.3rem;
  }

  .sql-tool .btn-primary,
  .sql-tool .btn-secondary {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .sql-examples-table td:first-child {
    max-width: 150px;
    font-size: 0.7rem;
  }

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