/**
 * Toggle switch — gooey pill style.
 * Wrap checkbox in <label class="toggle-switch">
 * or use standalone input[type="checkbox"].toggle-check
 */

/* === Standalone toggle (wrap in label.toggle-switch) === */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-switch .toggle-track {
  position: absolute;
  inset: 0;
  background: #d2d6e9;
  border-radius: 999px;
  transition: background-color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch .toggle-track::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch input:checked + .toggle-track {
  background: #275efe;
}

.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(20px);
}

.toggle-switch:hover .toggle-track {
  background: #c7cbdf;
}

.toggle-switch input:checked + .toggle-track:hover {
  background: #1e4fd6;
}

.toggle-switch input:focus-visible + .toggle-track {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.toggle-switch input:disabled + .toggle-track {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Variant colors */
.toggle-switch.toggle-success input:checked + .toggle-track { background: #10b981; }
.toggle-switch.toggle-success input:checked + .toggle-track:hover { background: #059669; }
.toggle-switch.toggle-warning input:checked + .toggle-track { background: #f59e0b; }
.toggle-switch.toggle-warning input:checked + .toggle-track:hover { background: #d97706; }
.toggle-switch.toggle-danger input:checked + .toggle-track { background: #ef4444; }
.toggle-switch.toggle-danger input:checked + .toggle-track:hover { background: #dc2626; }

/* === Simple checkbox override (for forms without wrapper) === */
input[type="checkbox"].toggle-check {
  -webkit-appearance: none;
  appearance: none;
  width: 52px;
  height: 32px;
  min-width: 52px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d2d6e9;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
  position: relative;
  transition: background-color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="checkbox"].toggle-check::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

input[type="checkbox"].toggle-check:checked {
  background: #275efe;
}

input[type="checkbox"].toggle-check:checked::before {
  transform: translateX(20px);
}

input[type="checkbox"].toggle-check:hover {
  background: #c7cbdf;
}

input[type="checkbox"].toggle-check:checked:hover {
  background: #1e4fd6;
}

input[type="checkbox"].toggle-check:focus {
  outline: none;
}

input[type="checkbox"].toggle-check:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

input[type="checkbox"].toggle-check:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* === Checkbox caixinha bonita === */
/* Checkbox caixinha — NÃO afeta inputs dentro de .option-chip (esses são hidden) */
.form-check-input[type="checkbox"],
:not(.option-chip) > input[type="checkbox"]:not(.toggle-check):not([class*="toggle"]) {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  border: 2px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s ease;
}

.form-check-input[type="checkbox"]:hover,
:not(.option-chip) > input[type="checkbox"]:not(.toggle-check):not([class*="toggle"]):hover {
  border-color: #275efe;
}

.form-check-input[type="checkbox"]:checked,
:not(.option-chip) > input[type="checkbox"]:not(.toggle-check):not([class*="toggle"]):checked {
  background: #275efe;
  border-color: #275efe;
}

.form-check-input[type="checkbox"]:checked::after,
:not(.option-chip) > input[type="checkbox"]:not(.toggle-check):not([class*="toggle"]):checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 6px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-check-input[type="checkbox"]:focus-visible,
:not(.option-chip) > input[type="checkbox"]:not(.toggle-check):not([class*="toggle"]):focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.form-check-input[type="checkbox"]:disabled,
:not(.option-chip) > input[type="checkbox"]:not(.toggle-check):not([class*="toggle"]):disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* === Option chips (radio + checkbox, visíveis sem dropdown) === */
.option-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 9px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  transition: all 0.15s ease;
  user-select: none;
}

.option-chip:hover {
  border-color: #93a3b8;
  background: #f8fafc;
}

/* Hide inputs inside chips completely */
.option-chip input[type="radio"],
.option-chip input[type="checkbox"] {
  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;
  border: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

/* Selected state — just border + bg change, no circles */
.option-chip:has(input:checked) {
  border-color: #275efe;
  background: #eef2ff;
  color: #1e3a8a;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .toggle-switch .toggle-track,
  .toggle-switch .toggle-track::before,
  input[type="checkbox"].toggle-check,
  input[type="checkbox"].toggle-check::before {
    transition-duration: 0.01ms;
  }
}
