/* =========================
   Mindset Digital · Schema Markup Generator
   ========================= */

/* Layout */
.mdt-schema-gen {
  background: var(--md-background);
  color: var(--md-foreground);
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 2rem;
}
@supports (height: 1dvh) { .mdt-schema-gen { min-height: 100dvh; } }
.mdt-schema-gen .md-card {
  width: min(780px, 94vw);
  background: var(--md-surface, #fff);
  color: var(--md-foreground);
}

/* Header */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .65rem;
  border: 1px solid var(--md-border, rgba(0,0,0,.12));
  border-radius: 999px;
  background: transparent;
  color: var(--md-foreground);
  cursor: pointer;
  line-height: 1;
}
.theme-toggle:hover { background: rgba(0,0,0,.04); }
[data-theme="dark"] .theme-toggle:hover { background: rgba(255,255,255,.06); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
#iconMoon { display: none; }
[data-theme="dark"] #iconSun { display: none; }
[data-theme="dark"] #iconMoon { display: block; }
@media (max-width: 480px) { .theme-toggle__label { display: none; } }

/* Form rows */
.form-row {
  display: grid;
  gap: .3rem;
  margin-bottom: .85rem;
}
.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--md-foreground);
}

/* Select dropdown */
select#schema-type {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--md-border);
  border-radius: 8px;
  background: var(--md-surface);
  color: var(--md-foreground);
  font-size: 1rem;
  font-family: var(--md-font-body);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.25rem;
}
[data-theme="dark"] select#schema-type {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Schema form (dynamic fields) */
.schema-form {
  margin-block: 1rem;
}
.schema-form .form-group {
  display: grid;
  gap: .3rem;
  margin-bottom: .85rem;
}
.schema-form .form-group label {
  font-weight: 600;
  font-size: .92rem;
  color: var(--md-foreground);
}
.schema-form .form-group input[type="text"],
.schema-form .form-group input[type="number"],
.schema-form .form-group input[type="date"],
.schema-form .form-group input[type="url"],
.schema-form .form-group textarea,
.schema-form .form-group select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--md-border);
  border-radius: 8px;
  background: var(--md-surface);
  color: var(--md-foreground);
  font-size: .95rem;
  font-family: var(--md-font-body);
  box-sizing: border-box;
}
.schema-form .form-group textarea {
  resize: vertical;
  min-height: 3rem;
}
.schema-form .form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  padding-right: 2rem;
  cursor: pointer;
}
[data-theme="dark"] .schema-form .form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23aaa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Two-column grid for some fields */
.schema-form .form-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}
@media (max-width: 560px) {
  .schema-form .form-row-grid {
    grid-template-columns: 1fr;
  }
}

/* Section divider inside forms */
.schema-form .form-section {
  font-weight: 700;
  font-size: .88rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: color-mix(in srgb, var(--md-foreground) 60%, transparent);
  margin-top: 1rem;
  margin-bottom: .5rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--md-border);
}

/* FAQ items (repeatable) */
.faq-item,
.step-item,
.breadcrumb-item {
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius);
  padding: .85rem;
  margin-bottom: .75rem;
  position: relative;
  background: color-mix(in srgb, var(--md-surface) 95%, var(--md-background));
}
[data-theme="dark"] .faq-item,
[data-theme="dark"] .step-item,
[data-theme="dark"] .breadcrumb-item {
  background: color-mix(in srgb, var(--md-surface) 80%, var(--md-background));
}

.faq-item .item-header,
.step-item .item-header,
.breadcrumb-item .item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}
.faq-item .item-header strong,
.step-item .item-header strong,
.breadcrumb-item .item-header strong {
  font-size: .88rem;
  color: var(--md-foreground);
}

/* Remove button (inside repeatable items) */
.btn-remove {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .55rem;
  border: 1px solid var(--md-color-danger);
  border-radius: var(--md-radius-pill);
  background: transparent;
  color: var(--md-color-danger);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-remove:hover {
  background: var(--md-color-danger);
  color: #fff;
}

/* Add button (for repeatable sections) */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .85rem;
  border: 1px dashed var(--md-border-strong);
  border-radius: var(--md-radius-pill);
  background: transparent;
  color: var(--md-color-primary);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  margin-bottom: .75rem;
}
.btn-add:hover {
  background: color-mix(in srgb, var(--md-color-primary) 8%, transparent);
  border-color: var(--md-color-primary);
}

/* Actions */
.actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  align-items: center;
  position: relative;
}
.md-btn {
  background: var(--md-color-primary, #1063ff);
  color: var(--md-color-primary-contrast, #fff);
}
.md-btn--secondary {
  background: var(--md-color-secondary, #f0b138);
  color: var(--md-color-secondary-contrast, #090a08);
}

/* Help */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--md-border);
  border-radius: 50%;
  background: var(--md-surface);
  color: var(--md-foreground);
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.help-popover {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: .5rem;
  z-index: 1000;
  width: min(520px, 86vw);
  background: var(--md-surface);
  color: var(--md-foreground);
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  padding: .85rem 1rem;
  display: none;
}
.help-popover.is-open { display: block; }
.help-popover ul { padding-left: 1.2rem; margin: .5rem 0; }
.help-popover li { margin-bottom: .4rem; }
.help-popover a {
  color: var(--md-color-primary);
  text-decoration: none;
  font-weight: 600;
}
.help-popover a:hover {
  text-decoration: underline;
}

/* JSON output section */
.json-output-section {
  margin-top: 1.25rem;
}
.json-output-heading {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: var(--md-foreground);
  font-family: var(--md-font-body);
}
.json-output-wrap {
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius);
  background: #f8f9fb;
  max-height: 480px;
  overflow: auto;
  position: relative;
}
[data-theme="dark"] .json-output-wrap {
  background: #0d1017;
}
.json-output-wrap pre {
  margin: 0;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.json-output-wrap code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .88rem;
  color: var(--md-foreground);
}

/* Syntax highlighting for JSON */
.json-key { color: #1063ff; }
.json-string { color: #0b7a3e; }
.json-number { color: #c05a15; }
.json-boolean { color: #7c3aed; }
.json-null { color: #7c3aed; }
.json-bracket { color: var(--md-foreground); opacity: .7; }
.json-punctuation { color: var(--md-foreground); opacity: .5; }

[data-theme="dark"] .json-key { color: #6da1ff; }
[data-theme="dark"] .json-string { color: #4ade80; }
[data-theme="dark"] .json-number { color: #fb923c; }
[data-theme="dark"] .json-boolean { color: #a78bfa; }
[data-theme="dark"] .json-null { color: #a78bfa; }

/* Status */
.status-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95rem;
  color: var(--md-foreground);
  display: inline-block;
  padding: .3rem .5rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--md-surface) 85%, transparent);
  min-height: 1.4em;
}
.status-line::after {
  content: "\2588";
  margin-left: .3rem;
  opacity: .7;
  animation: blink 1s steps(2, end) infinite;
}
@keyframes blink { 0%,50% { opacity: 0; } 50.01%,100% { opacity: 1; } }

/* Accessibility */
.skip-link {
  position: absolute;
  left: .5rem;
  top: -1000px;
  background: var(--md-foreground);
  color: var(--md-background);
  padding: .5rem .75rem;
  border-radius: 6px;
  text-decoration: none;
}
.skip-link:focus { top: .5rem; z-index: 10; }
textarea:focus-visible,
input:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--md-focus, #0a57ff);
  outline-offset: 2px;
}
:root { color-scheme: light dark; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
