/* ============================================================
   Quick Sale — Open Ticket panel (mini Salon Center)
   ------------------------------------------------------------
   Markup: _QuickSale.cshtml #qs-open-ticket-panel · JS: quickSaleOpenTicket.js
   Header / tabs / search / cards are the Salon Center v2 sc2-* components
   (salonCenter2/*.css); this file only fits them into the Quick Sale drawer
   and adds the "current ticket" state.
   ============================================================ */

/* While open, the panel replaces the catalogue inside .main-list-services. */
.qs-pos-container.qs-open-ticket-mode .main-list-services > :not(.qs-open-ticket) {
  display: none !important;
}

/* Phones: updateContainerVisibility swaps in the desktop container for this mode
   (same as Combine). The panel brings its own Back, so drop the desktop header
   (tabs / Opened By / actions overflowed to 109px) and the cart — it is
   position:fixed on phones and covered the left half of the list. */
@media (max-width: 767.98px) {
  .qs-pos-container.qs-open-ticket-mode > .header-top-bar,
  .qs-pos-container.qs-open-ticket-mode > .main-content > .cart-sidebar {
    display: none !important;
  }

  .qs-pos-container.qs-open-ticket-mode > .main-content {
    padding: 0;
  }

  .qs-pos-container.qs-open-ticket-mode > .main-content > .main-list-services {
    padding: 0;
    margin: 0;
    width: 100%;
  }

  /* Back + Refresh on row 1, the 3 filters as equal columns on row 2 — in one row
     "Wait List" was scrolled off-screen with no hint it existed. */
  .qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__header {
    flex: 0 0 auto;
    flex-wrap: wrap;
    height: auto;
    row-gap: 6px;
    padding: 6px 12px 8px;
  }

  .qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__header .sc2-frame__actions {
    margin-left: auto;
  }

  .qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__header .sc2-ticket-tabs {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    gap: 4px;
    overflow: visible;
  }

  .qs-open-ticket[data-sc2-layout="mobile"] .sc2-ticket-tab {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding-left: 4px;
    padding-right: 4px;
  }

  .qs-open-ticket[data-sc2-layout="mobile"] .sc2-ticket-tab__text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__search {
    margin-top: 8px;
  }

  .qs-pos-container.qs-open-ticket-mode .qs-open-ticket {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

.qs-pos-container .qs-open-ticket {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: none;
  background: var(--bs-surface-bg, #fff);
}

.qs-open-ticket .qs-open-ticket__header {
  gap: 4px;
  padding-left: 6px;
}

/* Title + short tab label only in the phone layout (row 1 is otherwise empty). */
.qs-open-ticket__title,
.qs-open-ticket__label-short {
  display: none;
}

.qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__title {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--sc2-header-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__label-full {
  display: none;
}

.qs-open-ticket[data-sc2-layout="mobile"] .qs-open-ticket__label-short {
  display: inline;
}

.qs-open-ticket .qs-open-ticket__back {
  flex: 0 0 auto;
  color: var(--sc2-header-fg);
}

.qs-open-ticket .sc2-ticket-tabs {
  gap: 2px;
}

/* Desktop: tabs sit in the flex middle between Back and Refresh — center them
   in that slot so they are not flush left. */
.qs-open-ticket[data-sc2-layout="desktop"] .sc2-ticket-tabs {
  justify-content: center;
}

.qs-open-ticket .qs-open-ticket__search {
  flex: 0 0 auto;
  margin: 10px 12px 0;
  border-color: var(--sc2-frame-border);
}

.qs-open-ticket .qs-open-ticket__search:focus-within {
  border-color: var(--sc2-primary);
}

/* type=search: drop the native clear/decoration so it matches the sc2 bar */
.qs-open-ticket .qs-open-ticket__search input::-webkit-search-decoration {
  -webkit-appearance: none;
}

.qs-open-ticket .sc2-frame__body {
  background: var(--sc2-bg-page);
}

/* Drawer is narrower than the Salon Center column — slightly smaller min track. */
.qs-open-ticket .sc2-ticket-list {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.qs-open-ticket[data-sc2-layout="mobile"] .sc2-ticket-list {
  grid-template-columns: minmax(0, 1fr);
}

/* Cards open the ticket on click — not draggable here. */
.qs-open-ticket .sc2-ticket {
  cursor: pointer;
}

/* ---------- current ticket (V2 .opened-tix) ---------- */
.qs-open-ticket .sc2-ticket.is-current {
  border-color: var(--sc2-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sc2-primary) 25%, transparent);
}

.qs-open-ticket__current-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--sc2-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.qs-open-ticket .sc2-ticket.is-opening {
  opacity: 0.6;
  pointer-events: none;
}

/* ---------- header button states ---------- */
.qs-open-ticket [data-qs-ot-action="refresh"].is-spinning i {
  animation: qs-open-ticket-spin 0.8s linear infinite;
}

@keyframes qs-open-ticket-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .qs-open-ticket [data-qs-ot-action="refresh"].is-spinning i {
    animation: none;
  }
}

.btn-list-actions [data-purpose="ticket-action"].is-active,
.header-actions-mobile [data-purpose="ticket-action"].is-active {
  background-color: var(--bs-main) !important;
  color: #fff !important;
  border-color: var(--bs-main) !important;
}
