/* ============================================
   VR CONNECT AI - BILLING TOGGLE PRECISION FIX
   
   Purpose: Fix overlapping blue backgrounds on billing toggle
   Root Cause: Incorrect width and transform calculations
   Approach: Single sliding indicator with proper measurements
   
   ONLY BILLING TOGGLE - NO OTHER CHANGES
============================================ */

/* ============================================
   BILLING TOGGLE CONTAINER
   Clean single pill container
============================================ */
.billing-toggle {
  /* Layout */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important; /* No gap - buttons are adjacent */
  
  /* Sizing */
  width: auto !important;
  max-width: fit-content !important;
  padding: 4px !important;
  
  /* Appearance */
  background: rgba(255, 255, 255, 0.98) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1.5px solid rgba(226, 232, 240, 0.8) !important;
  border-radius: 100px !important;
  box-shadow: 
    0 2px 12px rgba(15, 23, 42, 0.08),
    0 1px 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
  
  /* Position for ::before indicator */
  position: relative !important;
  
  /* Spacing */
  margin-bottom: 56px !important;
}

/* ============================================
   SINGLE SLIDING ACTIVE INDICATOR
   This is the ONLY blue background that should appear
   
   Strategy: Dynamic width based on content
   - Bulanan button: padding (24×2) + text (~52px) ≈ 100px
   - Tahunan area: padding (24×2) + text (~54px) + badge (~76px) ≈ 178px
============================================ */
.billing-toggle::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  background: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
  border-radius: 100px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
  pointer-events: none;
}

/* MONTHLY ACTIVE STATE - Cover "Bulanan" button only */
.billing-toggle[data-cycle="monthly"]::before {
  width: 100px; /* Bulanan button width */
  transform: translateX(0);
}

/* YEARLY ACTIVE STATE - Cover "Tahunan + Hemat 20%" */
.billing-toggle[data-cycle="yearly"]::before {
  width: 178px; /* Tahunan + badge width */
  transform: translateX(100px); /* Move right by Bulanan width */
}

/* ============================================
   BILLING LABELS (Buttons)
   These are the clickable areas
============================================ */
.billing-label {
  /* Position */
  position: relative;
  z-index: 2; /* Above the sliding indicator */
  
  /* Sizing - NO BACKGROUND, transparent by default */
  padding: 10px 24px !important;
  flex: 0 0 auto; /* Don't grow or shrink */
  
  /* Typography */
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  white-space: nowrap;
  
  /* Appearance - TRANSPARENT by default */
  color: #64748B !important;
  background: transparent !important; /* CRITICAL: No background */
  border: none !important;
  border-radius: 100px !important;
  
  /* Interaction */
  cursor: pointer;
  transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover state */
.billing-label:hover {
  color: #475569 !important;
}

/* Active state - ONLY change text color, background comes from ::before */
.billing-label.active {
  color: #FFFFFF !important;
  background: transparent !important; /* CRITICAL: Still no background on button itself */
}

/* Remove focus outline but keep accessible */
.billing-label:focus {
  outline: none;
}

.billing-label:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.5);
  outline-offset: 2px;
}

/* ============================================
   TOGGLE SWITCH - VISUALLY HIDDEN
   Keep in DOM for JavaScript but hide visually
============================================ */
.toggle-switch {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.toggle-slider {
  display: none !important;
}

/* ============================================
   SAVE BADGE - Compact orange pill
============================================ */
.save-badge {
  display: inline-flex !important;
  align-items: center;
  padding: 4px 10px !important;
  background: linear-gradient(135deg, #F59E0B 0%, #F97316 100%) !important;
  color: #FFFFFF !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.03em;
  border-radius: 100px !important;
  margin-left: 8px !important;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
  white-space: nowrap;
}

/* ============================================
   RESPONSIVE - MOBILE ADJUSTMENTS
============================================ */

/* Small mobile (360-430px) */
@media (max-width: 430px) {
  .billing-toggle {
    padding: 3px !important;
    margin-bottom: 40px !important;
    max-width: calc(100% - 32px) !important;
  }
  
  .billing-label {
    padding: 9px 18px !important;
    font-size: 13px !important;
  }
  
  .save-badge {
    font-size: 9px !important;
    padding: 3px 8px !important;
    margin-left: 6px !important;
  }
  
  /* Adjust indicator widths for smaller text and padding */
  .billing-toggle[data-cycle="monthly"]::before {
    width: 85px; /* Smaller padding + smaller text */
  }
  
  .billing-toggle[data-cycle="yearly"]::before {
    width: 155px; /* Tahunan + smaller badge */
    transform: translateX(85px); /* Match Bulanan width */
  }
}

/* Medium mobile (431-767px) */
@media (min-width: 431px) and (max-width: 767px) {
  .billing-toggle {
    margin-bottom: 48px !important;
  }
  
  .billing-label {
    padding: 10px 22px !important;
  }
  
  /* Standard widths work fine here */
  .billing-toggle[data-cycle="monthly"]::before {
    width: 95px;
  }
  
  .billing-toggle[data-cycle="yearly"]::before {
    width: 168px;
    transform: translateX(95px);
  }
}

/* Tablet (768-1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .billing-toggle {
    margin-bottom: 52px !important;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .billing-toggle {
    margin-bottom: 56px !important;
  }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
============================================ */
@media (prefers-reduced-motion: reduce) {
  .billing-toggle::before,
  .billing-label {
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   PERFORMANCE
============================================ */
.billing-toggle::before {
  will-change: transform, width;
}

/* Remove will-change after animation completes */
.billing-toggle:not([data-transitioning])::before {
  will-change: auto;
}

/* ============================================
   DEBUG HELPER (Remove in production)
   Uncomment to visualize layout boundaries
============================================ */
/*
.billing-toggle {
  outline: 2px solid red !important;
}

.billing-label {
  outline: 1px solid blue !important;
}

.save-badge {
  outline: 1px solid green !important;
}
*/

/* ============================================
   END OF BILLING TOGGLE FIX
   
   Summary:
   - Single container with one sliding ::before indicator
   - Buttons have NO background themselves
   - Text color changes on active
   - Blue background only from ::before pseudo-element
   - Proper width and transform calculations
   - No overlap, no double backgrounds
   - Responsive across all breakpoints
   
   NO OTHER SECTION MODIFIED
============================================ */
