/* Billing switch toggle styles */
/* Container for the switch and labels to ensure perfect centering */
.switch-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* This will perfectly center the switch */
  grid-template-rows: auto auto; /* Two rows: one for the switch, one for the message */
  grid-template-areas: 
    "left switch right"
    "message message message"; /* Full width message area */
  align-items: center;
  gap: 18px 18px; /* Row gap, column gap */
  padding: 12px 0 35px; /* Extra padding at bottom for message */
  position: relative;
  margin: 0 auto;
  box-sizing: border-box;
  
  /* Position the container in the center of the page */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  
  /* Width needs to be fixed for stable positioning */
  width: 350px; /* Slightly wider to accommodate message */
  top: 0;
}

.switch-label {
  font-size: 1.2rem; /* Further increased from 1rem */
  font-weight: 500;
  color: #666;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  /* Set fixed width to ensure perfect centering */
  min-width: 110px; /* Slightly wider to prevent text overlap */
  box-sizing: border-box;
  padding: 0 5px; /* Minimal padding */
  transition: all 0.2s ease;
}

/* Position-specific alignment */
.switch-label[data-position="left"] {
  justify-content: flex-end; /* Right align trimestral text */
  padding-right: 0; /* No need for extra padding with grid layout */
  text-align: right; /* Ensure text aligns to the right */
  grid-area: left; /* Place in left grid area */
}

.switch-label[data-position="right"] {
  justify-content: flex-start; /* Left align mensual text */
  padding-left: 0; /* No need for extra padding with grid layout */
  text-align: left; /* Ensure text aligns to the left */
  grid-area: right; /* Place in right grid area */
}

.switch-label.active {
  color: var(--secondary-color);
  font-weight: 700; /* Increased from 600 for better visibility */
}

/* Position switch exactly in the center */
.switch {
  position: relative;
  display: inline-block;
  width: 54px; /* Total width of the switch track */
  height: 30px; /* Height of the switch track */
  margin: 0;
  /* Center in grid cell */
  justify-self: center;
  align-self: center;
  /* Remove any margins that might affect centering */
  margin-left: 0;
  margin-right: 0;
  grid-area: switch; /* Place in switch grid area */
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--secondary-color); /* ON by default (trimestral) */
  transition: .3s;
  border-radius: 34px;
  /* Enhanced shadow and border for more visibility */
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 2px 5px rgba(47, 97, 171, 0.2);
  border: 1px solid rgba(47, 97, 171, 0.3);
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px; /* Size of the circle */
  width: 20px; /* Size of the circle */
  left: 5px; /* Precisely measured 5px distance from left edge when OFF */
  /* Center vertically instead of using bottom property */
  top: 50%;
  transform: translateY(-50%);
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  /* Enhanced shadow for the slider button */
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  /* Subtle inner border */
  border: 1px solid rgba(255,255,255,0.9);
}

/* When checked (mensual), slider is grey (OFF) */
input:checked + .slider {
  background-color: #d8dce0;
  border-color: rgba(0,0,0,0.15);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 2px 5px rgba(0,0,0,0.1);
}

/* Slider button moves to the right when checked, maintaining vertical centering */
input:checked + .slider:before {
  /* Ensuring perfect symmetry between left and right positions */
  transform: translate(24px, -50%); /* 54px (total width) - 20px (button width) - 10px (total margins) = 24px displacement */
  /* This puts the button exactly 5px from the right edge, matching the 5px from left edge in OFF position */
}

/* Hide the original AHORRA tag */
.ahorra-tag {
  display: none; /* Hide the inline tag completely */
}

/* Add a full-width savings message for all devices */
.switch-container::after {
  content: "Ahorra 10% con tu plan trimestral";
  grid-area: message; /* Place in message area */
  font-size: 1rem; /* Increased size */
  color: var(--secondary-color);
  font-weight: 700; /* Bolder */
  text-align: center;
  width: 100%;
  margin-top: 10px;
  grid-column: 1 / -1; /* Span all columns */
  display: block;
  background-color: rgba(47, 97, 171, 0.1);
  padding: 8px 14px; /* More padding */
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .switch-container {
    width: 300px; /* Slightly smaller for mobile */
    gap: 12px; /* Tighter spacing on mobile */
    padding-bottom: 25px; /* Slightly less space on mobile */
  }
  
  .switch-label {
    min-width: 100px;
    font-size: 1.1rem; /* Slightly smaller font on mobile */
    padding: 0 3px; /* Minimal padding */
  }
  
  /* Larger message text on mobile */
  .switch-container::after {
    font-size: 1rem; /* Increased to match desktop */
    padding: 7px 12px; /* Slightly more padding */
    margin-top: 8px;
    /* Keep bold weight from main rule */
    letter-spacing: 0.2px; /* Slightly improved readability */
  }
  
  .switch {
    width: 50px; /* Slightly smaller than desktop but still has equal padding */
    height: 28px; /* Proportional height */
    justify-self: center;
    grid-area: switch; /* Place in switch area */
  }
  
  .slider:before {
    height: 18px;
    width: 18px;
    left: 5px; /* Equal spacing from left */
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
  }
  
  input:checked + .slider:before {
    transform: translate(22px, -50%); /* 50px (switch width) - 18px (button width) - 10px (total horizontal margins) = 22px movement */
  }
}