/* JSON Formatter Consistent Styling */
.json-section {
  margin: 30px 0;
}

.json-section h2 {
  margin-bottom: 20px;
  font-size: 24px;
  color: #2c3e50;
}

/* Unified button styling - same as other tools */
.json-button, .json-button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 2px solid;
  border-radius: 4px;
  font-weight: bold;
  font-size: 16px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-sizing: border-box;
  min-height: 44px;
  gap: 8px;
  width: 100%; /* Take full width of grid cell */
  min-width: 0; /* Allow flexing */
}

/* Primary button style (Format button) */
.json-button {
  background-color: #1376B3;
  color: #ffffff;
  border: 2px solid #d1d5db;
}

.json-button:hover {
  background-color: #005583;
  border-color: #1f2937;
}

/* Secondary button style (Copy, Download, Clear buttons) */
.json-button-secondary {
  background-color: #ffffff;
  color: #333333;
  border: 2px solid #d1d5db;
}

.json-button-secondary:hover {
  background-color: #f9fafb;
  border-color: #9ca3af;
}

/* Copy icon styling */
.copy-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Button container layout - responsive grid */
.json-buttons-container {
  display: grid;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
  max-width: 800px;
  margin: 0 auto;
  
  /* Default: All 4 buttons in one row for wide screens */
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 1fr;
}

/* Format options styling */
.format-options {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: end;
  margin: 30px 0;
  flex-wrap: wrap;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.option-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 140px;
  flex: 1;
  max-width: 200px;
}

.option-group .json-form-label {
  margin-bottom: 8px;
  text-align: center;
}

/* Form elements styling */
.json-form-group {
  margin-bottom: 20px;
}

.json-form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #374151;
}

.json-form-select {
  padding: 12px;
  border: 2px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background-color: #ffffff;
  color: #374151;
  transition: border-color 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.json-form-select:focus {
  outline: none;
  border-color: #1376B3;
}

/* Input and output sections */
.input-section, .output-section {
  margin: 30px 0;
}

.input-group, .output-group {
  max-width: 800px;
  margin: 0 auto;
}

/* JSON Editor Container */
.json-editor-container {
  position: relative;
  display: flex;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.json-editor-container:focus-within {
  border-color: #1376B3;
}

/* Textarea Wrapper for Error Background */
.textarea-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}

/* Error Background Highlight */
.error-highlight-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  color: transparent;
  box-sizing: border-box;
}

.error-highlight-background .error-char {
  background-color: #ef4444;
  color: transparent;
  border-radius: 2px;
}

/* Line Numbers Styling */
.line-numbers {
  padding: 16px 8px;
  background-color: #f8f9fa;
  border-right: 1px solid #e5e7eb;
  color: #6b7280;
  font-family: Consolas, 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  text-align: right;
  user-select: none;
  white-space: pre;
  min-width: 40px;
  box-sizing: border-box;
}

/* Textarea styling */
.json-textarea {
  width: 100%;
  min-height: 200px;
  font-family: Consolas, 'Courier New', monospace;
  padding: 16px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  color: #2c3e50;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
  tab-size: 4;
  -moz-tab-size: 4;
}

/* Error highlighting using box-shadow for underline effect */
.json-textarea.has-error {
  /* Red border to indicate error state */
  border-color: #ef4444 !important;
}

/* Error indication in the container */
.json-editor-container.has-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}


/* Output container specific styling */
.output-section .json-editor-container {
  background: #f8f9fa;
  border-color: #e9ecef;
}

.output-section .json-editor-container:focus-within {
  background: #ffffff;
  border-color: #1376B3;
}

.output-section .json-editor-container .line-numbers {
  background-color: #f1f3f4;
}

/* Validation status styling */
.validation-status {
  margin: 20px auto;
  max-width: 800px;
  padding: 12px 16px;
  border-radius: 6px;
  font-weight: 500;
  text-align: center;
  min-height: 20px;
}

.validation-status.valid {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.validation-status.invalid {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.validation-status.empty {
  background-color: #f9fafb;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

/* Hint styling */
.json-hint {
  font-size: 12px;
  color: #6b7280;
  font-weight: normal;
  text-align: center;
  margin-top: 8px;
}

/* Responsive design */
@media (max-width: 768px) and (min-width: 349px) {
  /* Medium screens: 2x2 grid layout */
  .json-buttons-container {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    max-width: 400px;
  }
}

@media (max-width: 348px) {
  /* Small screens: single column layout */
  .json-buttons-container {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 1fr);
    max-width: 300px;
  }
}

@media (max-width: 480px) {
  .format-options {
    flex-direction: column;
    gap: 15px;
    align-items: center;
  }
  
  .option-group {
    width: 100%;
    max-width: 300px;
  }
  
  .json-textarea {
    min-height: 150px;
    font-size: 13px;
  }
  
  .line-numbers {
    padding: 16px 6px;
    font-size: 13px;
    min-width: 35px;
  }
}

@media (max-width: 450px) {
  .format-options {
    gap: 8px;
    width: 100%;
  }
  
  .option-group {
    flex: 1;
    min-width: 0;
    max-width: none;
  }
}

/* Syntax highlighting for JSON output (optional enhancement) */
.json-textarea.highlighted {
  background: #fafafa;
}

/* Focus states for better accessibility */
.json-editor-container:focus-within,
.json-form-select:focus,
.json-button:focus,
.json-button-secondary:focus {
  box-shadow: 0 0 0 3px rgba(19, 118, 179, 0.1);
}

/* Better visual hierarchy */
.input-section .json-form-label::after {
  content: " *";
  color: #dc2626;
  font-weight: normal;
}

.output-section .json-form-label {
  color: #6b7280;
}

/* Animation for validation status changes */
.validation-status {
  transition: all 0.3s ease;
}

/* Tab size for code examples and any pre elements */
pre, code, .minecraft-command-block pre, .minecraft-command-block code {
  tab-size: 4;
  -moz-tab-size: 4;
}

.validation-status:empty {
  padding: 0;
  min-height: 0;
  border: none;
  margin: 0;
}