/* ================================================================
   Tracker V2 — Grouped card view styles
   Card-level master rows + condition sub-rows
   ================================================================ */

/* ── Card block ───────────────────────────────────────────────── */
.v2-card-block {
  border-bottom: 1px solid #f0f2f5;
}
.v2-card-block:last-child { border-bottom: none; }

/* ── Master card row ──────────────────────────────────────────── */
.cmr {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cmr:active { background: #f6f8fb; }

/* Expand toggle — inline before card image */
.cmr-expand-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 6px 4px 0;
  font-size: 18px;
  color: #b0bac8;
  cursor: pointer;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.cmr-expand-btn:active { color: #5b8dee; }

.cmr-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* Image wrapper — relative so + badge can overlay */
.cmr-img-wrap {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 52px;
}
.cmr-img-wrap img {
  width: 38px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.cmr-img-ph {
  width: 38px;
  height: 52px;
  border-radius: 4px;
  background: #eef0f4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bcc2cc;
  font-size: 16px;
}

/* [+] badge overlaid at top-right of card image */
.cmr-add-btn {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5b8dee;
  color: #fff;
  border: 2px solid #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.cmr-add-btn:active { background: #3a6fd8; }

.cmr-info { min-width: 0; }

.cmr-name {
  font-size: 15px;
  font-weight: 700;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.cmr-sub {
  font-size: 12px;
  color: #96a0b0;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmr-right {
  flex-shrink: 0;
  margin-left: 8px;
  text-align: right;
}

.cmr-total {
  font-size: 14px;
  font-weight: 600;
  color: #1a1d23;
  white-space: nowrap;
  display: block;
}

/* ── Condition sub-rows ───────────────────────────────────────── */
.v2-sub-rows { background: #f8f9fb; }

.csr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 8px 60px;
  border-top: 1px solid #eef0f4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.csr:active { background: #f0f2f6; }

.csr-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.csr-qty {
  font-size: 12px;
  color: #6b7685;
  font-weight: 600;
}

.csr-unit-price {
  font-size: 11px;
  color: #aab1c0;
}

.csr-right {
  font-size: 13px;
  font-weight: 500;
  color: #4a5568;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Expand all toggle ────────────────────────────────────────── */
.v2-expand-all-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 6px 14px 4px;
}
.v2-expand-all-btn {
  background: none;
  border: 1px solid #dde1e9;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  color: #6b7685;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.v2-expand-all-btn:active { background: #f0f2f6; }

/* ── Unit management modal ────────────────────────────────────── */
.umd-qty-ctrl {
  display: flex;
  align-items: center;
  gap: 12px;
}
.umd-qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid #dde1e9;
  background: #fff;
  font-size: 18px;
  line-height: 1;
  color: #3d4756;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.umd-qty-btn:active { background: #f0f2f6; }
.umd-qty-count {
  font-size: 18px;
  font-weight: 700;
  color: #1a1d23;
  min-width: 24px;
  text-align: center;
}

.umd-unit-list {
  padding: 8px 0;
}

.umd-unit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid #f0f2f5;
  gap: 8px;
}
.umd-unit-item:last-child { border-bottom: none; }

.umd-unit-left { flex: 1; min-width: 0; }

.umd-unit-tag {
  font-size: 13px;
  color: #3d4756;
  font-family: monospace;
  cursor: pointer;
  border-bottom: 1px dashed #b8c0cc;
  display: inline-block;
  word-break: break-all;
}
.umd-unit-tag:active { color: #5b8dee; }

.umd-tag-input {
  font-size: 13px;
  font-family: monospace;
  border: 1.5px solid #5b8dee;
  border-radius: 6px;
  padding: 3px 8px;
  width: 100%;
  outline: none;
  color: #1a1d23;
}

.umd-unit-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.umd-unit-del {
  background: none;
  border: none;
  color: #c0c8d2;
  font-size: 18px;
  padding: 2px 4px;
  cursor: pointer;
  line-height: 1;
  border-radius: 4px;
}
.umd-unit-del:active { color: #e74c3c; background: #fdf0ef; }

.umd-guest-note {
  font-size: 12px;
  color: #96a0b0;
  padding: 8px 0;
  text-align: center;
}

/* Footer with gradient */
.umd-footer {
  position: relative;
  flex-shrink: 0;
}
.umd-gradient {
  position: absolute;
  top: -32px;
  left: 0;
  right: 0;
  height: 32px;
  background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.95) 100%);
  pointer-events: none;
}
.umd-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 11px 0;
  background: none;
  border: 1.5px solid #f0c4c4;
  border-radius: 12px;
  color: #c0392b;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin: 4px 0 16px;
}
.umd-remove-btn:active { background: #fdf0ef; }

/* Modal flex layout for scroll */
#modal-unit-mgmt .modal-content {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
#modal-unit-mgmt .modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Series group overrides for v2 */
.series-group .series-subtotal {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
}
.series-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Game filter pills ───────────────────────────────────────── */
.v2-game-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 10px 0;
  margin-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.v2-game-filter::-webkit-scrollbar { display: none; }

.v2-game-pill {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1.5px solid #dde1e9;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #6b7685;
  cursor: pointer;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.v2-game-pill.active {
  background: #5b8dee;
  border-color: #5b8dee;
  color: #fff;
}
.v2-game-pill:active { opacity: 0.8; }

/* ── Series group meta (name + count grouped together) ─────────── */
.series-group-meta {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.series-group-name {
  font-size: 12px;
  color: #96a0b0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.series-group-dot {
  font-size: 12px;
  color: #96a0b0;
  flex-shrink: 0;
}

/* ── Bulk add icon button (search bar) ───────────────────────── */
.hm-bulk-icon-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e8eef8;
  border: none;
  color: #5b8dee;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.hm-bulk-icon-btn:active { background: #d4e0f5; }

/* ── Controls bar: game filter + price mode + expand all ──────── */
.v2-controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  position: relative;
}
.v2-controls-bar .price-mode-switcher { margin: 0; flex-shrink: 0; }
.v2-controls-bar .v2-expand-all-btn   { flex-shrink: 0; }

/* ── Game filter wrap (flex:1, clips pill overflow) ────────────── */
.v2-gf-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
}
.v2-gf-wrap .v2-game-filter {
  padding-right: 28px;
  padding-bottom: 0;
  margin-bottom: 0;
}

/* ── Right-side gradient fade + arrow button ───────────────────── */
.v2-gf-gradient {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 48px;
  background: linear-gradient(to right, rgba(255,255,255,0) 0%, #fff 55%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 2px;
  pointer-events: none;
}
.v2-gf-arrow-btn {
  pointer-events: auto;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid #dde1e9;
  background: #fff;
  color: #6b7685;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s;
}
.v2-gf-arrow-btn.open { transform: rotate(180deg); }
.v2-gf-arrow-btn:active { background: #f0f2f6; }

/* ── Full game list dropdown ───────────────────────────────────── */
.v2-gf-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e0e6f0;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 10px 12px;
  z-index: 200;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── (legacy) Actions bar: price mode + expand all on same row ─── */
.v2-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px 0;
}
.v2-actions-bar .price-mode-switcher { margin: 0; }

/* ── Guest info icon + tooltip ────────────────────────────────── */
.guest-info-btn {
  background: none;
  border: none;
  padding: 0 0 0 4px;
  font-size: 14px;
  color: #c8d0da;
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.guest-info-btn.active { color: #5b8dee; }
.guest-info-btn:active { color: #3a6fd8; }

.guest-info-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #e0e6f0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 10px 14px;
  font-size: 12px;
  color: #4a5568;
  width: 220px;
  z-index: 100;
  line-height: 1.5;
}
.guest-info-tooltip a {
  color: #5b8dee;
  font-weight: 600;
  text-decoration: none;
  display: block;
  margin-top: 6px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .v2-card-block { border-color: #2a2d36; }
  .cmr-name { color: #e8ecf0; }
  .cmr-sub { color: #606878; }
  .cmr-total { color: #d0d8e4; }
  .cmr-add-btn { background: #4a7de0; border-color: #1c1f28; }
  .cmr-expand-btn { color: #4a5468; }
  .cmr-img-ph { background: #2a2d36; color: #606878; }
  .cmr:active { background: #22252e; }
  .v2-sub-rows { background: #1c1f28; }
  .csr { border-color: #2a2d36; }
  .csr:active { background: #22252e; }
  .csr-qty { color: #8090a4; }
  .csr-unit-price { color: #606878; }
  .csr-right { color: #8090a4; }
  .v2-expand-all-btn { border-color: #2a2d36; color: #8090a4; }
  .umd-unit-tag { color: #b0bac8; border-color: #4a5468; }
  .umd-unit-item { border-color: #2a2d36; }
  .umd-qty-btn { border-color: #2a2d36; background: #22252e; color: #b0bac8; }
  .umd-qty-count { color: #e8ecf0; }
  .umd-gradient { background: linear-gradient(to bottom, rgba(30,33,42,0) 0%, rgba(30,33,42,0.95) 100%); }
  .umd-remove-btn { border-color: #4a2525; color: #e57373; }
  .umd-remove-btn:active { background: #2d1f1f; }
  .series-group .series-subtotal { color: #8090a4; }
  .v2-game-pill { background: #1e2235; border-color: #2a2d3e; color: #7a8aa0; }
  .v2-game-pill.active { background: #3a5fc0; border-color: #3a5fc0; color: #e8ecf8; }
  .series-group-name { color: #4a5570; }
  .hm-bulk-icon-btn { background: #252840; color: #4a7de0; }
  .hm-bulk-icon-btn:active { background: #2d3460; }
  .guest-info-btn { color: #4a5468; }
  .guest-info-btn.active { color: #4a7de0; }
  .guest-info-tooltip { background: #22252e; border-color: #2a2d36; color: #b0bac8; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
  .guest-info-tooltip a { color: #4a7de0; }
  .v2-gf-gradient { background: linear-gradient(to right, rgba(30,33,42,0) 0%, #1a1d28 55%); }
  .v2-gf-arrow-btn { border-color: #2a2d36; background: #1a1d28; color: #8090a4; }
  .v2-gf-arrow-btn:active { background: #22252e; }
  .v2-gf-dropdown { background: #22252e; border-color: #2a2d36; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
}
