/* ==========================================================================
   CABIX 3D STUDIO — MODULE SWAP MODAL (DARK LUXURY GOLD & OBSIDIAN)
   Compact, High-Density & Mobile Responsive (Telegram WebApp & Desktop)
   User: iRealBy_3D
   ========================================================================== */

/* Modal Backdrop */
.cb-swap-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(8, 7, 6, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.cb-swap-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Floating Dialog Shell (Desktop) */
.cb-swap-dialog {
  width: 95%;
  max-width: 1080px;
  max-height: 86vh;
  background: rgba(18, 16, 13, 0.96);
  border: 1px solid rgba(255, 199, 0, 0.22);
  border-radius: 20px;
  box-shadow: 
    0 24px 60px -12px rgba(0, 0, 0, 0.9),
    0 0 1px 1px rgba(255, 199, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
}

.cb-swap-backdrop.active .cb-swap-dialog {
  transform: scale(1) translateY(0);
}

/* Mobile Bottom-Sheet Transformation */
@media (max-width: 768px) {
  .cb-swap-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .cb-swap-dialog {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    max-height: 85vh;
    transform: translateY(100%);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.9), 0 0 1px 1px rgba(255, 199, 0, 0.2);
  }

  .cb-swap-backdrop.active .cb-swap-dialog {
    transform: translateY(0);
  }
}

/* Mobile Pull / Drag Bar */
.cb-swap-drag-handle {
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 99px;
  margin: 8px auto 2px;
  display: none;
}

@media (max-width: 768px) {
  .cb-swap-drag-handle {
    display: block;
  }
}

/* Header */
.cb-swap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.015);
}

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

.cb-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 199, 0, 0.12);
  border: 1px solid rgba(255, 199, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFC700;
  font-size: 14px;
  flex: none;
  box-shadow: 0 0 12px rgba(255, 199, 0, 0.15);
}

.cb-header-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cb-header-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cb-header-title {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #F7F4EE;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.cb-header-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: rgba(255, 199, 0, 0.12);
  border: 1px solid rgba(255, 199, 0, 0.28);
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 800;
  color: #FFC700;
  letter-spacing: 0.4px;
}

.cb-header-sub {
  font-size: 11px;
  color: #9E968B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-header-sub b {
  color: #E2DDD5;
  font-weight: 600;
}

.cb-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1C1915;
  color: #9E968B;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  flex: none;
  transition: all 0.15s ease;
}
.cb-close-btn:hover {
  background: #24201B;
  color: #FFF;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Category Filter Ribbon */
.cb-filter-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: #14120F;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-x: auto;
  scrollbar-width: none;
}
.cb-filter-strip::-webkit-scrollbar {
  display: none;
}

.cb-filter-tab {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1C1915;
  color: #9E968B;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}
.cb-filter-tab:hover {
  color: #F7F4EE;
  border-color: rgba(255, 255, 255, 0.18);
}
.cb-filter-tab.active {
  background: #FFC700;
  color: #0B0A09;
  border-color: #FFC700;
  box-shadow: 0 2px 8px rgba(255, 199, 0, 0.32);
}

.cb-filter-tab-count {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.22);
  font-weight: 800;
}
.cb-filter-tab:not(.active) .cb-filter-tab-count {
  background: rgba(255, 255, 255, 0.08);
  color: #6E6860;
}

/* Dialog Body */
.cb-swap-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 56vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cb-swap-body::-webkit-scrollbar {
  width: 5px;
}
.cb-swap-body::-webkit-scrollbar-thumb {
  background: rgba(255, 199, 0, 0.25);
  border-radius: 4px;
}

@media (min-width: 860px) {
  .cb-swap-body {
    max-height: 64vh;
  }
}

/* Category Group */
.cb-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cb-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cb-group-title {
  font-size: 12px;
  font-weight: 800;
  color: #E2DDD5;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.cb-group-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(255, 199, 0, 0.12);
  border: 1px solid rgba(255, 199, 0, 0.25);
  color: #FFC700;
}

/* Cards Container: Flexible row on mobile, spacious multi-column grid on desktop */
.cb-cards-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.cb-cards-row::-webkit-scrollbar {
  height: 5px;
}
.cb-cards-row::-webkit-scrollbar-thumb {
  background: rgba(255, 199, 0, 0.28);
  border-radius: 4px;
}

@media (min-width: 860px) {
  .cb-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 14px;
    overflow-x: visible;
    padding-bottom: 4px;
  }
}

/* Card */
.cb-card {
  flex: 0 0 118px;
  width: 118px;
  height: 165px;
  background: #181512;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  cursor: pointer;
  position: relative;
  scroll-snap-align: start;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

@media (min-width: 860px) {
  .cb-card {
    flex: initial;
    width: 100%;
    min-width: 135px;
    height: 195px;
    padding: 10px 10px 12px;
    border-radius: 14px;
  }
}

.cb-card:hover {
  background: #231E18;
  border-color: rgba(255, 199, 0, 0.45);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 1px 1px rgba(255, 199, 0, 0.2);
}

/* Active Selected Card with CABIX Gold Aura */
.cb-card.active {
  background: rgba(255, 199, 0, 0.09) !important;
  border: 1.8px solid #FFC700 !important;
  box-shadow: 
    0 0 20px rgba(255, 199, 0, 0.38),
    inset 0 0 12px rgba(255, 199, 0, 0.12);
  transform: translateY(-2px);
}

.cb-card.active::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  background: #FFC700;
  color: #07080A;
  font-size: 11px;
  font-weight: 900;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  z-index: 2;
}

/* Thumbnail Box with Warm Studio Vignette Lighting */
.cb-card-thumb {
  width: 100%;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 80%, rgba(255, 199, 0, 0.08) 0%, rgba(35, 30, 24, 0.55) 45%, rgba(13, 12, 10, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  padding: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@media (min-width: 860px) {
  .cb-card-thumb {
    height: 105px;
  }
}

.cb-card-thumb img {
  max-height: 94%;
  max-width: 94%;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8)) contrast(1.06) brightness(0.96);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), filter 0.22s ease;
}

.cb-card:hover .cb-card-thumb img {
  transform: scale(1.08) translateY(-3px);
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.95)) contrast(1.1) brightness(1.02);
}

/* Card Details */
.cb-card-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}

.cb-card-art {
  font-family: 'Space Grotesk', 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 800;
  color: #FFC700;
  letter-spacing: 0.2px;
  line-height: 1.1;
}

.cb-card-title {
  font-size: 11px;
  font-weight: 600;
  color: #DDD4C6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
  width: 100%;
}

@media (min-width: 860px) {
  .cb-card-title {
    font-size: 11.5px;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 29px;
  }
}

.cb-card.active .cb-card-title {
  color: #FFF;
}

.cb-card-dims {
  font-family: 'Space Grotesk', monospace;
  font-size: 10px;
  font-weight: 600;
  color: #7A7268;
  letter-spacing: -0.3px;
}
.cb-card.active .cb-card-dims {
  color: #DDD4C6;
}

/* Sticky Action Footer */
.cb-swap-footer {
  padding: 10px 18px;
  background: #14120F;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cb-footer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cb-footer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFC700;
  box-shadow: 0 0 8px #FFC700;
  flex: none;
}

.cb-footer-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cb-footer-selected {
  font-size: 11px;
  font-weight: 700;
  color: #F7F4EE;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-footer-hint {
  font-size: 9.5px;
  color: #6E6860;
}

.cb-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.cb-btn-cancel {
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #9E968B;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}
.cb-btn-cancel:hover {
  background: #1C1915;
  color: #F7F4EE;
}

.cb-btn-apply {
  padding: 7px 16px;
  border-radius: 9px;
  font-size: 11.5px;
  font-weight: 800;
  color: #07080A;
  background: linear-gradient(135deg, #FFC700 0%, #E5A800 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(255, 199, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.cb-btn-apply:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 199, 0, 0.45);
}
.cb-btn-apply:active {
  transform: translateY(0);
}
