/* -------------------------------------------------------
 * Easy FAQs — shared custom-field styles
 * Loaded once by any of DimensionField, BorderField,
 * TypographyField via a static guard.
 * ------------------------------------------------------- */

/* ── design tokens ──────────────────────────────────────
   Override on a parent element to rebrand. */
:root {
  --jxf-bg:      var(--dmod-field-bg, transparent);
  --jxf-border:  var(--dmod-field-border, rgba(24,25,237,.12));
  --jxf-focus:   var(--dmod-field-focus,  rgba(24,25,237,.28));
  --jxf-radius:  var(--dmod-field-radius, 12px);
  --jxf-accent:  var(--exman-hero-accent, var(--jx-site-accent, #1819ed));
  --jxf-text:    var(--template-text-dark, #212529);
  --jxf-muted:   var(--template-bg-dark-60, #6c757d);
}

/* ── flat shell (no card chrome) ────────────────────────
   Replaces the old heavy bordered accordion. */
.jx-field-shell {
  padding: 0;
  background: var(--jxf-bg);
  border: 0;
  box-shadow: none;
  margin-bottom: .5rem;
}

/* ── section ────────────────────────────────────────────
   A logical group inside a field (Width, Radius, Shadow). */
.jx-field-section {
  margin-bottom: .85rem;
}

.jx-field-section:last-child {
  margin-bottom: 0;
}

/* small muted uppercase label — replaces h3/h4 gray bars */
.jx-field-section-label {
  display: block;
  margin-bottom: .45rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--jxf-muted);
}

/* ── TRBL grid ──────────────────────────────────────────
   4 value inputs + unit select + link btn, all in one row. */
.jx-field-trbl {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 5.5rem 2.5rem;
  align-items: end;
  gap: .4rem .5rem;
}

.jx-field-trbl-4 {
  grid-template-columns: repeat(4, 1fr);
}

.jx-field-trbl-item {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.jx-field-trbl-item small {
  font-size: .68rem;
  font-weight: 600;
  color: var(--jxf-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* brand-focused focus ring on every input/select inside a shell */
.jx-field-shell .form-control:focus,
.jx-field-shell .form-select:focus {
  border-color: var(--jxf-focus);
  box-shadow: 0 0 0 .18rem rgba(24,25,237,.18);
  outline: 0;
}

/* ── link / unlink toggle button ────────────────────────
   Sits next to the unit dropdown in the TRBL grid. */
.jx-field-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--jxf-border);
  background: transparent;
  color: var(--jxf-muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
  align-self: flex-start;
}

.jx-field-link-btn:hover,
.jx-field-link-btn.is-linked {
  background: rgba(24,25,237,.08);
  border-color: var(--jxf-accent);
  color: var(--jxf-accent);
}

.jx-field-link-btn:focus {
  outline: none;
  box-shadow: 0 0 0 .18rem rgba(24,25,237,.18);
}

/* ── visualization / preview box ────────────────────────
   A simple dashed box showing TRBL values. */
.jx-field-preview {
  position: relative;
  border: 1.5px dashed var(--jxf-border);
  border-radius: var(--jxf-radius);
  padding: 1.8rem 2.2rem;
  margin-top: .65rem;
  text-align: center;
  font-size: .75rem;
  color: var(--jxf-muted);
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24,25,237,.02);
}

.jx-field-preview-top,
.jx-field-preview-bottom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: .68rem;
  font-weight: 700;
  color: var(--jxf-accent);
  white-space: nowrap;
}

.jx-field-preview-top    { top: .28rem; }
.jx-field-preview-bottom { bottom: .28rem; }

.jx-field-preview-left,
.jx-field-preview-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: .68rem;
  font-weight: 700;
  color: var(--jxf-accent);
}

.jx-field-preview-left  { left: .35rem; }
.jx-field-preview-right { right: .35rem; }

/* ── linked-state dim for right / bottom / left inputs ── */
.jx-dim-linked .jx-dim-input[data-pos="right"],
.jx-dim-linked .jx-dim-input[data-pos="bottom"],
.jx-dim-linked .jx-dim-input[data-pos="left"] {
  opacity: .4;
  pointer-events: none;
  background: rgba(0,0,0,.04);
}

.jx-bw-linked .jx-bw-input[data-pos="right"],
.jx-bw-linked .jx-bw-input[data-pos="bottom"],
.jx-bw-linked .jx-bw-input[data-pos="left"] {
  opacity: .4;
  pointer-events: none;
  background: rgba(0,0,0,.04);
}

.jx-br-linked .jx-br-input[data-pos="right"],
.jx-br-linked .jx-br-input[data-pos="bottom"],
.jx-br-linked .jx-br-input[data-pos="left"] {
  opacity: .4;
  pointer-events: none;
  background: rgba(0,0,0,.04);
}

/* ── minicolors tweaks inside field shells ───────────── */
.jx-field-shell .minicolors-input {
  padding-left: 2.25rem !important;
}

.jx-field-shell .minicolors-theme-bootstrap .minicolors-swatch {
  top: 50%;
  left: .45rem;
  width: 1.25rem;
  height: 1.25rem;
  transform: translateY(-50%);
  border-radius: .2rem;
}

/* ── inline grid for box-shadow / border-color row ────── */
.jx-field-inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
  gap: .4rem .5rem;
  align-items: end;
}

/* ── typography field ────────────────────────────────── */
.jx-typography {
  width: 100%;
  max-width: 640px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.jx-typography .jx-typo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .85rem;
  margin: 0 0 .75rem;
}

.jx-typography .jx-typo-row:last-child {
  margin-bottom: 0;
}

.jx-typography .jx-typo-label {
  flex: 0 0 7.5rem;
  max-width: 100%;
  font-size: .875rem;
  font-weight: 500;
  color: var(--jxf-text);
}

.jx-typography .jx-typo-field {
  flex: 1 1 12rem;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: .5rem;
}

/* connected input + unit dropdown */
.jx-typography .jx-typo-combo {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 20rem;
}

.jx-typography .jx-typo-combo .form-control,
.jx-typography .jx-typo-combo .form-select {
  width: auto;
  max-width: none;
  min-width: 0;
  flex: 1 1 auto;
}

.jx-typography .jx-typo-combo .jx-typo-unit {
  flex: 0 0 4.75rem;
  width: 4.75rem;
  max-width: 4.75rem;
}

.jx-typography .jx-typo-combo .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.jx-typography .jx-typo-combo .jx-typo-unit {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.jx-typography .jx-typo-combo .jx-typo-suffix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 2.75rem;
  padding: 0 .75rem;
  margin-left: -1px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--jxf-muted);
  background: var(--gray-100, #f8f9fa);
  border: 1px solid var(--template-bg-dark-20, #cdcdcd);
  border-top-right-radius: .25rem;
  border-bottom-right-radius: .25rem;
}

.jx-typography .jx-typo-field > .form-control,
.jx-typography .jx-typo-field > .form-select,
.jx-typography .jx-typo-field > joomla-field-fancy-select {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

/* text-shadow sub-grid */
.jx-typography .jx-typo-shadow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: .5rem .75rem;
  width: 100%;
}

.jx-typography .jx-typo-shadow-item small {
  display: block;
  margin-top: .25rem;
  font-size: .75rem;
  color: var(--jxf-muted);
}

.jx-typography joomla-field-fancy-select {
  display: block;
  width: 100%;
}

.jx-typography .choices {
  margin-bottom: 0;
}

.jx-typography .minicolors-input {
  padding-left: 2.25rem !important;
}

.jx-typography .minicolors-theme-bootstrap .minicolors-swatch {
  top: 50%;
  left: .45rem;
  width: 1.25rem;
  height: 1.25rem;
  transform: translateY(-50%);
  border-radius: .2rem;
}

/* focus inside typography */
.jx-typography .form-control:focus,
.jx-typography .form-select:focus {
  border-color: var(--jxf-focus);
  box-shadow: 0 0 0 .18rem rgba(24,25,237,.18);
  outline: 0;
}

/* ── responsive ──────────────────────────────────────── */
@media (max-width: 575.98px) {
  .jx-field-trbl {
    grid-template-columns: repeat(2, 1fr);
  }

  .jx-typography .jx-typo-label {
    flex-basis: 100%;
  }
}
