/**
 * Category Tab Navigation — Shared styles
 * Used on: quick-order, category, subcategory pages
 */

/* ---- Container ---- */
.qo-category-nav {
  margin-top: var(--space-xs, 4px);
  margin-bottom: 0;
  min-height: 44px; /* Reserve vertical space to avoid CLS when tabs initialize */
}

.filter-main-content > .qo-category-nav {
  margin-bottom: 0;
}

/* Morph Track: fixed-height row */
.qo-morph-track {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
}

/* Scroll hint when tabs overflow (pattern from service-modal pay tabs) */
.qo-morph-track.is-scroll-fade::before,
.qo-morph-track.is-scroll-fade::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.qo-morph-track.is-scroll-fade.is-scroll-fade-start::before,
.qo-morph-track.is-scroll-fade.is-scroll-fade-end::after {
  opacity: 1;
}

.qo-morph-track.is-scroll-fade::before {
  inset-inline-start: 0;
  background: linear-gradient(to right, var(--bg, #0a0818), transparent);
}

.qo-morph-track.is-scroll-fade::after {
  inset-inline-end: 0;
  background: linear-gradient(to left, var(--bg, #0a0818), transparent);
}

html[dir="rtl"] .qo-morph-track.is-scroll-fade::before {
  background: linear-gradient(to left, var(--bg, #0a0818), transparent);
}

html[dir="rtl"] .qo-morph-track.is-scroll-fade::after {
  background: linear-gradient(to right, var(--bg, #0a0818), transparent);
}

/* Morph Slide: scrollable row of tabs */
.qo-morph-slide {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 0.25rem;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.25rem 0;
  padding-inline: 6px;
  scroll-padding-inline: 6px;
  height: 100%;
  scroll-behavior: smooth;
  box-sizing: border-box;
}

.qo-morph-slide::-webkit-scrollbar {
  display: none;
}

/* ---- Slide Animations ---- */
@keyframes qo-morph-exit-fwd {
  from { transform: translateX(0) scale(1); opacity: 1; filter: blur(0); }
  to   { transform: translateX(-16%) scale(0.96); opacity: 0; filter: blur(6px); }
}
@keyframes qo-morph-exit-bwd {
  from { transform: translateX(0) scale(1); opacity: 1; filter: blur(0); }
  to   { transform: translateX(16%) scale(0.96); opacity: 0; filter: blur(6px); }
}
@keyframes qo-tab-appear {
  from { opacity: 0; transform: translateY(6px) scale(0.92); filter: blur(3px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.qo-morph-slide.qo-anim-exit-left {
  animation: qo-morph-exit-fwd 0.18s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

.qo-morph-slide.qo-anim-exit-right {
  animation: qo-morph-exit-bwd 0.18s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

.qo-morph-slide.qo-anim-enter > * {
  opacity: 0;
  animation: qo-tab-appear 0.28s cubic-bezier(0, 0, 0.2, 1) forwards;
  animation-delay: calc(var(--i, 0) * 0.04s);
}

/* ---- Tab Button ---- */
.qo-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 16px);
  color: var(--muted, var(--quick-text-secondary, rgba(255, 255, 255, 0.55)));
  font-size: var(--text-base, 14px);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  min-height: 2.25rem;
  flex-shrink: 0;
  position: relative;
}

.qo-tab-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--brand, var(--quick-accent, #5b43ea));
  border-radius: 2px;
  transform: translateX(-50%);
  transition: width 0.2s ease;
}

.qo-tab-btn:hover {
  color: var(--ink, var(--quick-text, #ffffff));
  background: rgba(255, 255, 255, 0.03);
}

.qo-tab-btn:hover::after {
  width: 60%;
}

.qo-tab-btn:active {
  transform: scale(0.98);
}

.qo-tab-btn.active {
  color: var(--ink, var(--quick-text, #ffffff));
  font-weight: 600;
  background: rgba(91, 67, 234, 0.06);
}

.qo-tab-btn.active::after {
  width: 80%;
}

/* Tab icon */
.qo-tab-btn i {
  font-size: 1rem;
  color: var(--brand, var(--quick-accent, #5b43ea));
  opacity: 0.8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.qo-tab-btn:hover i,
.qo-tab-btn.active i {
  opacity: 1;
}

.qo-tab-btn .has-category-accent.qo-tab-icon-fallback i,
.qo-tab-btn .has-category-accent .category-icon-css-fallback {
  color: var(--category-color, var(--category-accent, var(--brand, var(--quick-accent, #5b43ea))));
  opacity: 0.9;
}

.qo-tab-btn:hover .has-category-accent.qo-tab-icon-fallback i,
.qo-tab-btn.active .has-category-accent.qo-tab-icon-fallback i {
  opacity: 1;
}

/* Tab icon via IconRenderer (category-icon-wrap structure) */
.qo-tab-btn .category-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Same “accent plate” as admin category list (color from item.color) */
.qo-tab-btn .category-icon-wrap.has-category-accent {
  width: 1.25rem;
  height: 1.25rem;
  padding: 2px;
  box-sizing: border-box;
  border-radius: var(--radius-xs, 10px);
  background: color-mix(
    in srgb,
    var(--category-accent, var(--category-color, #5b43ea)) 22%,
    rgba(0, 0, 0, 0.2)
  );
  box-shadow: inset 0 0 0 1px
    color-mix(
      in srgb,
      var(--category-accent, var(--category-color, #5b43ea)) 45%,
      transparent
    );
}

.qo-tab-btn .category-icon-tinted {
  position: absolute;
  inset: 0;
  background: var(--category-color, var(--brand, var(--quick-accent, #5b43ea)));
  -webkit-mask-image: var(--icon-url);
  mask-image: var(--icon-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.qo-tab-btn:hover .category-icon-tinted,
.qo-tab-btn.active .category-icon-tinted {
  opacity: 1;
}

.qo-tab-btn .category-icon-css-fallback {
  font-size: 0.875rem;
  color: var(--category-color, var(--brand, var(--quick-accent, #5b43ea)));
  opacity: 0.8;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qo-tab-btn .category-icon-css-fallback[style*="inline"] {
  display: inline-flex;
}

/* Tab count */
.qo-tab-count {
  font-size: 0.75rem;
  color: var(--muted, var(--quick-text-secondary, rgba(255, 255, 255, 0.55)));
  opacity: 0.8;
  font-weight: 400;
  transition: color 0.2s, opacity 0.2s;
}

.qo-tab-btn.active .qo-tab-count {
  color: var(--brand, var(--quick-accent, #5b43ea));
  opacity: 0.9;
}

/* ---- Back Button ---- */
.qo-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 16px);
  color: var(--muted, var(--quick-text-secondary, rgba(255, 255, 255, 0.55)));
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  min-height: 2rem;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

.qo-back-btn:hover {
  color: var(--ink, var(--quick-text, #ffffff));
  background: rgba(255, 255, 255, 0.03);
}

.qo-back-btn:active {
  transform: scale(0.98);
}

.qo-back-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.8;
  color: var(--brand, var(--quick-accent, #5b43ea));
  transition: transform 0.2s, opacity 0.2s;
}

.qo-back-btn:hover svg {
  opacity: 1;
  transform: translateX(-2px);
}

.qo-back-label {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- View Switch ---- */
.qo-view-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-left: 0.5rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-xs, 10px);
  color: var(--muted, var(--quick-text-secondary, rgba(255, 255, 255, 0.55)));
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
  padding: 0;
  opacity: 0.85;
}

.qo-view-switch:hover {
  color: var(--brand, var(--quick-accent, #5b43ea));
  background: rgba(255, 255, 255, 0.04);
  opacity: 1;
}

.qo-view-switch:active {
  transform: scale(0.94);
}

.qo-view-icon {
  width: 16px;
  height: 16px;
  transition: opacity 0.2s ease;
}

.qo-view-switch .qo-view-icon {
  stroke: currentColor;
}

/* ---- RTL Support ---- */
[dir="rtl"] .qo-back-btn {
  margin-right: 0;
  margin-left: 0.125rem;
}

[dir="rtl"] .qo-back-btn:hover svg {
  transform: translateX(2px);
}

[dir="rtl"] .qo-morph-slide.qo-anim-exit-left {
  animation-name: qo-morph-exit-bwd;
}
[dir="rtl"] .qo-morph-slide.qo-anim-exit-right {
  animation-name: qo-morph-exit-fwd;
}

[dir="rtl"] .qo-view-switch {
  margin-left: 0;
  margin-right: 0.5rem;
}
