/*
 * Joomla 6 UI compatibility for the pivo template.
 *
 * The pivo look is built on the legacy LT Event Bootstrap 3 stylesheet, but
 * Joomla 6 core markup (front-end editing, com_config module/template forms,
 * calendar, fancy-select) is written for Bootstrap 5. Cassiopeia ships these
 * rules itself; a custom template has to provide them, otherwise hidden labels
 * and edit tooltips render as visible text and the forms fall apart.
 * Rules mirror Cassiopeia (media/templates/site/cassiopeia/scss/blocks/_form.scss).
 */

/* Screen-reader-only text (Bootstrap 5 utility used throughout core layouts). */
.visually-hidden,
.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Front-end editing: edit button + tooltip ─────────────────────────────── */
.sp-module,
.item-page,
.blog-item,
.items-leading > div,
.items-row > div {
  position: relative;
}

/* Only when editing is available: keep module content clear of the edit icon. */
.sp-module:has(> .jmodedit) {
  padding-right: 34px;
}

.btn.jmodedit,
.btn.jmodedit:visited {
  position: absolute;
  top: 0;
  right: 0;
  left: auto;
  z-index: 900;
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1.4;
  color: #3f79c8;
  background-color: rgba(255, 255, 255, .85);
  border: 1px solid #58595a;
  border-radius: 4px;
  text-transform: none;
}

.btn.jmodedit:hover,
.btn.jmodedit:focus {
  color: #fff;
  background-color: #3f79c8;
}

/* Tooltip stays hidden until the edit button is hovered or focused. */
[role="tooltip"]:not(.show) {
  display: none;
  right: 3em;
  z-index: 1070;
  max-width: 100%;
  padding: .5em;
  margin: .5em;
  font-size: 13px;
  line-height: 1.4;
  color: #000;
  text-align: start;
  background: #fff;
  border: 1px solid #6c757d;
  border-radius: 4px;
  box-shadow: 0 0 .5rem rgba(0, 0, 0, .8);
}

:focus + [role="tooltip"],
:hover + [role="tooltip"] {
  position: absolute;
  display: block;
}

/* ── Core forms (front-end module/template editing, com_config) ───────────── */
.com_config .control-group {
  margin-bottom: 18px;
}

.com_config .control-label label {
  margin-bottom: 4px;
  font-weight: 600;
}

.com_config .form-control,
.com_config .form-select {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-shadow: none;
}

.com_config .form-select {
  max-width: 320px;
}

.com_config .form-control:focus,
.com_config .form-select:focus {
  border-color: #3f79c8;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(63, 121, 200, .2);
}

/* Calendar: input + compact icon button on one line. */
.com_config .input-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  max-width: 360px;
}

.com_config .input-group > .form-control {
  flex: 1 1 auto;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.com_config .input-group > .btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Fancy-select (choices.js) remove button: Joomla renders it as
   .choices__button_joomla and styles it in Cassiopeia's vendor/choicesjs CSS. */
.choices__button_joomla {
  position: relative;
  padding: 0 10px;
  color: inherit;
  text-indent: -9999px;
  cursor: pointer;
  background: none;
  border: 0;
  box-shadow: none;
  opacity: .5;
  appearance: none;
}

.choices__button_joomla::before {
  position: absolute;
  inset: 0;
  display: block;
  text-align: center;
  text-indent: 0;
  content: "×";
}

.choices[data-type*="select-one"] .choices__button_joomla {
  position: absolute;
  top: 50%;
  inset-inline-end: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  margin-block-start: -10px;
  margin-inline-end: 50px;
  border-radius: 10em;
}

.choices__button_joomla:hover,
.choices__button_joomla:focus {
  opacity: 1;
  outline: none;
}

/* ── Bootstrap 5 collapse / accordion ─────────────────────────────────────
   Joomla 6 marks an open panel with .show; the legacy Bootstrap 3 in this
   template only knows .in, so .collapse.show stayed display:none and the
   module's "Možnosti" / "Pokročilé" panels were unreachable. */
.collapse.show,
.collapse.in {
  display: block;
  visibility: visible; /* BS3 .collapse also sets visibility:hidden */
}

.collapsing {
  visibility: visible;
}

.collapse:not(.show):not(.in) {
  display: none;
}

.collapsing {
  height: 0;
  overflow: hidden;
  transition: height .25s ease;
}

.accordion-item {
  margin-bottom: -1px;
  background: #fff;
  border: 1px solid #ddd;
}

.accordion-item:first-of-type {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.accordion-item:last-of-type {
  margin-bottom: 0;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 4px;
}

.accordion-header {
  margin: 0;
  font-size: 16px;
}

.accordion-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #333;
  text-align: left;
  text-transform: none;
  background-color: #f5f5f5;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.accordion-button::after {
  margin-left: auto;
  content: "▾";
  transition: transform .2s ease;
}

.accordion-button.collapsed::after {
  transform: rotate(-90deg);
}

.accordion-button:not(.collapsed) {
  color: #fff;
  background-color: #3f79c8;
}

.accordion-button:focus {
  outline: 0;
  box-shadow: inset 0 0 0 2px rgba(63, 121, 200, .5);
}

.accordion-body {
  padding: 16px;
}

.accordion-body .nav.flex-column {
  display: block;
  padding: 0;
  margin: 0;
  list-style: none;
}

.com_config .choices {
  max-width: 420px;
}

/* Open dropdown must sit above the fields below it. Base choices.css uses
   z-index 1 while legacy BS3 gives form inputs a higher one, so the date
   inputs painted through the list. Cassiopeia uses 1060 — same here. */
.choices.is-open {
  z-index: 1060;
}

.choices__list--dropdown,
.choices__list[aria-expanded] {
  z-index: 1060;
  background-color: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
  background-color: #eaf1fb;
}

/* Group headings (template name / "Aktivní pozice") read as headings. */
.choices__heading {
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 700;
  color: #3f79c8;
  text-transform: uppercase;
  letter-spacing: .03em;
  background: #f7f9fc;
  border-bottom: 1px solid #e3e8ef;
}

/* Form action buttons row. */
.com_config form .btn + .btn {
  margin-left: 6px;
}

/* ── Front-end module editing layout (html/com_config/modules) ────────────── */
.pivo-modedit {
  --modedit-accent: #3f79c8;
  --modedit-border: #e1e5eb;
  --modedit-muted: #6b7280;
  --modedit-surface: #f7f9fc;
  --modedit-label-width: 190px;

  max-width: 860px;
}

.pivo-modedit__head {
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--modedit-accent);
}

.pivo-modedit__eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--modedit-accent);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.pivo-modedit__title {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
  text-transform: none;
}

.pivo-modedit__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  color: var(--modedit-muted);
}

.pivo-modedit__meta strong {
  color: #333;
}

.pivo-modedit code {
  padding: 1px 5px;
  font-size: 12px;
  color: #333;
  background: var(--modedit-surface);
  border: 1px solid var(--modedit-border);
  border-radius: 3px;
}

.pivo-modedit__section {
  min-width: 0;
  padding: 20px 20px 4px;
  margin: 0 0 20px;
  background: #fff;
  border: 1px solid var(--modedit-border);
  border-radius: 6px;
}

.pivo-modedit__section > legend,
.pivo-modedit__legend {
  float: left; /* lets legend sit inside the padded box like a heading */
  width: 100%;
  padding: 0;
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  color: #222;
  text-transform: none;
  border: 0;
}

.pivo-modedit__section > legend + * {
  clear: both;
}

.pivo-modedit__hint {
  clear: both;
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--modedit-muted);
}

.pivo-modedit__fieldhint {
  margin: -10px 0 18px;
  font-size: 12px;
  color: var(--modedit-muted);
}

.pivo-modedit .form-text,
.pivo-modedit small.text-muted {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--modedit-muted);
}

/* Label beside the control on wider screens, stacked on phones. */
@media (min-width: 768px) {
  .pivo-modedit .control-group {
    display: grid;
    grid-template-columns: var(--modedit-label-width) minmax(0, 1fr);
    gap: 0 16px;
    align-items: start;
  }

  .pivo-modedit .control-label {
    padding-top: 7px;
    text-align: right;
  }

  .pivo-modedit__fieldhint {
    margin-left: calc(var(--modedit-label-width) + 16px);
  }
}

.pivo-modedit .control-label label {
  font-weight: 600;
  color: #333;
}

.pivo-modedit .star {
  color: #c0392b;
}

/* Options accordion lives inside its own section. */
.pivo-modedit #options .accordion {
  margin-bottom: 16px;
}

.pivo-modedit #options .accordion-body .control-group:last-child {
  margin-bottom: 0;
}

/* Action bar stays in reach while scrolling long forms. The legacy wrapper's
   overflow-x:hidden makes it a scroll container, which disables sticky;
   clip crops the same way without that side effect. */
.body-innerwrapper:has(.pivo-modedit) {
  overflow-x: clip;
}

.pivo-modedit__actions {
  position: sticky;
  bottom: 0;
  z-index: 950;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  margin: 0 -16px;
  background: #fff;
  border-top: 1px solid var(--modedit-border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, .06);
}

.com_config .pivo-modedit__actions .btn + .btn {
  margin-left: 0;
}

.pivo-modedit__actions .btn {
  padding: 8px 18px;
  font-size: 14px;
  text-transform: none;
}

/* Legacy default.css sets .btn { border: none !important }, so outline via shadow. */
.pivo-modedit__actions .btn-default {
  color: var(--modedit-accent);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--modedit-accent);
}

.pivo-modedit__actions .btn-default:hover,
.pivo-modedit__actions .btn-default:focus {
  color: #fff;
  background: var(--modedit-accent);
}

.pivo-modedit__cancel {
  margin-left: auto;
  color: var(--modedit-muted);
}

.pivo-modedit__cancel:hover,
.pivo-modedit__cancel:focus {
  color: #c0392b;
}

.pivo-modedit__actions .btn:focus-visible {
  outline: 2px solid var(--modedit-accent);
  outline-offset: 2px;
}

/* ── Switcher (Skrýt/Zobrazit, Ano/Ne) ────────────────────────────────────
   The invisible radios must cover the whole toggle (core: 62×28 at 0,0).
   Legacy input rules (legacy.css width:206px, BS3 radio margin-top:4px,
   width:auto) shrank them to a 13px strip, so only the text was clickable. */
.switcher input[type="radio"] {
  top: 0;
  width: 62px;
  height: 28px;
  margin: 0;
  cursor: pointer;
}

.switcher label {
  font-weight: normal;
  cursor: pointer;
}

/* Core uses var(--focus), which this template doesn't define. */
.switcher input:focus-visible ~ .toggle-outside {
  border-color: #3f79c8;
  box-shadow: 0 0 0 3px rgba(63, 121, 200, .35);
}
