/* ==========================================================================
   A2Z Converter — Format chooser (shared)
   A select-looking trigger (.select-btn) that opens a searchable,
   filterable format popup. Used by the home uploader and converter pages.
   ========================================================================== */

/* ---------- Trigger: looks like a select ---------- */
.select-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
  min-width: 96px; height: 38px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: #fff;
  font-size: 14px; font-weight: 700; letter-spacing: .02em; color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.select-btn i { font-size: 11px; color: var(--muted); transition: transform .2s var(--ease); }
.select-btn:hover { border-color: var(--text); }
.select-btn:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.select-btn[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.select-btn[aria-expanded="true"] i { transform: rotate(180deg); }
.select-btn:disabled { opacity: .5; cursor: not-allowed; }
.select-btn .is-placeholder { color: var(--muted); font-weight: 600; letter-spacing: 0; }

/* ---------- Modal ---------- */
.fmt-modal {
  position: fixed; inset: 0; z-index: 185;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(10, 10, 14, .5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.fmt-modal[hidden] { display: none; }
.fmt-modal-box {
  display: flex; flex-direction: column;
  width: 100%; max-width: 760px; max-height: min(720px, 90vh);
  background: #fff; border-radius: 24px; box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .2s var(--ease);
}

.fmt-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 24px 24px 16px;
}
.fmt-modal-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.fmt-modal-head p { margin-top: 4px; font-size: 14.5px; color: var(--muted); overflow-wrap: anywhere; }
.fmt-modal-head p strong { color: var(--text); font-weight: 600; }
.fmt-modal-close {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  color: var(--muted); font-size: 18px;
}
.fmt-modal-close:hover { background: var(--panel); color: var(--text); }

.fmt-modal-tools { padding: 0 24px 14px; border-bottom: 1px solid var(--border); }
.fmt-search {
  display: flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid transparent;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
.fmt-search:focus-within { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.fmt-search i { color: var(--muted-2); }
.fmt-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 15.5px; }

.fmt-cats {
  display: flex; gap: 8px; margin-top: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.fmt-cats::-webkit-scrollbar { display: none; }
.fmt-cat {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: #fff;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.fmt-cat:hover { color: var(--text); border-color: var(--border-strong); }
.fmt-cat span { font-size: 12px; font-weight: 600; color: var(--muted-2); }
.fmt-cat[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.fmt-cat[aria-pressed="true"] span { color: rgba(255, 255, 255, .8); }

.fmt-modal-body { flex: 1; overflow-y: auto; padding: 16px 24px 20px; background: var(--panel); }
.fmt-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .fmt-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 760px) { .fmt-grid { grid-template-columns: repeat(3, 1fr); } }

.fmt-card {
  position: relative; width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 14px; text-align: left;
  background: #fff; border: 1px solid var(--border);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.fmt-card:hover { border-color: color-mix(in srgb, var(--accent, var(--primary)) 45%, #fff); box-shadow: var(--shadow); transform: translateY(-1px); }
.fmt-card:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.fmt-card-ext {
  flex: none; display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 12px;
  color: var(--accent, var(--primary));
  background: color-mix(in srgb, var(--accent, var(--primary)) 12%, #fff);
  font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
}
.fmt-card-body { min-width: 0; display: grid; gap: 1px; }
.fmt-card-body strong { font-size: 15px; font-weight: 700; display: flex; align-items: baseline; gap: 6px; }
.fmt-card-body strong em { font-style: normal; font-size: 12.5px; font-weight: 500; color: var(--muted-2); }
.fmt-card-body small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.fmt-card-check {
  position: absolute; top: 8px; right: 8px;
  display: none; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 10px;
}
.fmt-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.fmt-card.is-selected .fmt-card-check { display: grid; }

.fmt-modal-empty { grid-column: 1 / -1; padding: 40px 16px; text-align: center; color: var(--muted); }
.fmt-modal-empty i { display: block; font-size: 24px; color: var(--muted-2); margin-bottom: 10px; }

.fmt-modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-top: 1px solid var(--border);
  font-size: 14px; color: var(--muted);
}
.fmt-modal-foot strong { color: var(--text); }

/* Phones: bottom sheet */
@media (max-width: 559px) {
  .fmt-modal { align-items: flex-end; padding: 0; }
  .fmt-modal-box { max-width: none; max-height: 88vh; border-radius: 24px 24px 0 0; animation: sheet .25s var(--ease); }
  .fmt-modal-head { padding: 20px 16px 12px; }
  .fmt-modal-head h2 { font-size: 19px; }
  .fmt-modal-tools, .fmt-modal-body, .fmt-modal-foot { padding-left: 16px; padding-right: 16px; }
}
@keyframes sheet { from { transform: translateY(100%); } }
