/* ========================================
   CODE PREVIEW SHORTCODE STYLES
   ======================================== */

.code-preview-section {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin: 2rem auto !important;
  padding: 0 !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  background: var(--card);
  box-shadow: var(--shadow);
}

.code-preview-section summary {
  padding: 1rem 1.5rem !important;
  background: linear-gradient(135deg, var(--primary-soft) 0%, rgba(59, 130, 246, 0.04) 100%);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  user-select: none;
  outline: none;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease, color 0.2s ease;
  border-radius: calc(var(--radius-base) - 1px) calc(var(--radius-base) - 1px) 0 0;
}

.code-preview-section summary:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12) 0%, rgba(59, 130, 246, 0.08) 100%) !important;
  color: var(--primary-dark);
}

html[data-theme="dark"] .code-preview-section summary {
  color: var(--primary-light);
}

html[data-theme="dark"] .code-preview-section summary:hover {
  color: var(--primary);
}

.code-preview-section > div {
  padding: 1.5rem !important;
  background: rgba(15, 23, 42, 0.02);
  border-top: 1px solid var(--border);
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

html[data-theme="dark"] .code-preview-section > div {
  background: rgba(255, 255, 255, 0.02);
}

.code-preview-section pre {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 400px;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 1rem !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: var(--radius-sm) !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
  font-size: 12px !important;
  line-height: 1.6 !important;
  font-family: var(--font-mono) !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
}

html[data-theme="dark"] .code-preview-section pre {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.code-preview-section code {
  display: block;
  width: 100% !important;
  box-sizing: border-box !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  white-space: pre-wrap !important;
  word-break: break-word !important;
  color: inherit !important;
}

.code-preview-section details {
  margin-top: 1rem !important;
  padding-top: 1rem !important;
  border-top: 1px solid var(--border) !important;
}

.code-preview-section details summary {
  padding: 0.5rem 0 !important;
  background: none !important;
  border: none !important;
  color: var(--primary);
  font-weight: 500;
  user-select: none;
  border-radius: 0 !important;
  display: block;
  cursor: pointer;
  transition: color 0.2s ease;
}

.code-preview-section details summary:hover {
  color: var(--primary-dark);
  background: none !important;
}

html[data-theme="dark"] .code-preview-section details summary:hover {
  color: var(--primary-light);
}

.code-preview-section details pre {
  margin-top: 1rem !important;
  max-height: 600px !important;
}

@media (max-width: 768px) {
  .code-preview-section {
    margin: 1.5rem 0 !important;
  }

  .code-preview-section summary {
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem;
  }

  .code-preview-section > div {
    padding: 1rem !important;
  }

  .code-preview-section pre {
    font-size: 11px !important;
    padding: 0.75rem !important;
    max-height: 300px !important;
  }

  .code-preview-section details pre {
    max-height: 400px !important;
  }
}
