/* ===========================
 * Checkbox Component Styles
 * ===========================
 * Sizes: sm (16px), md (20px default)
 * States: default, hover, focused, disabled
 * Checked: unchecked, checked, indeterminate
 * Elements: checkbox-group (wrapper), checkbox-input (hidden input + visual box),
 *           checkbox-label, checkbox-supporting-text
 * ===========================
 * Dark mode handled by CSS custom properties via data-theme attribute
 * =========================== */


/* ─── 1. Checkbox Group (wrapper: input + label + supporting text) ─── */

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md, 8px);
  padding: var(--spacing-xs, 4px);
  cursor: pointer;
}

.checkbox-group.checkbox-disabled {
  cursor: not-allowed;
}


/* ─── 2. Checkbox Input Wrapper (contains hidden input + visual box) ─── */

.checkbox-input {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* md size defaults */
  width: 20px;
  height: 20px;
  /* align with first line of label text */
  margin-top: var(--spacing-xxs, 2px);
}


/* ─── 3. Hidden Native Input ─── */

.checkbox-input input[type="checkbox"] {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.checkbox-disabled .checkbox-input input[type="checkbox"] {
  cursor: not-allowed;
}


/* ─── 4. Visual Checkbox Box ─── */

.checkbox-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xs, 4px);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

/* Check / Indeterminate icon */
.checkbox-box i {
  display: none;
  font-size: 12px;
  color: var(--fg-white, #fff);
  line-height: 1;
}


/* ─── 5. Checked State ─── */

.checkbox-input input:checked ~ .checkbox-box {
  background-color: var(--bg-brand-solid);
  border-color: var(--bg-brand-solid);
}

.checkbox-input input:checked ~ .checkbox-box i.fa-check {
  display: block;
}


/* ─── 6. Indeterminate State ─── */

.checkbox-input input.is-indeterminate ~ .checkbox-box,
.checkbox-input input:indeterminate ~ .checkbox-box {
  background-color: var(--bg-brand-solid);
  border-color: var(--bg-brand-solid);
}

.checkbox-input input.is-indeterminate ~ .checkbox-box i.fa-check,
.checkbox-input input:indeterminate ~ .checkbox-box i.fa-check {
  display: none;
}

.checkbox-input input.is-indeterminate ~ .checkbox-box i.fa-minus,
.checkbox-input input:indeterminate ~ .checkbox-box i.fa-minus {
  display: block;
}


/* ─── 7. Hover State ─── */

.checkbox-group:hover:not(.checkbox-disabled) .checkbox-input input:not(:checked):not(.is-indeterminate):not(:indeterminate) ~ .checkbox-box {
  border-color: var(--border-brand);
  background-color: var(--bg-primary);
}

.checkbox-group:hover:not(.checkbox-disabled) .checkbox-input input:checked ~ .checkbox-box,
.checkbox-group:hover:not(.checkbox-disabled) .checkbox-input input.is-indeterminate ~ .checkbox-box,
.checkbox-group:hover:not(.checkbox-disabled) .checkbox-input input:indeterminate ~ .checkbox-box {
  background-color: var(--bg-brand-solid_hover);
  border-color: var(--bg-brand-solid_hover);
}


/* ─── 8. Focused State ─── */

.checkbox-input input:focus-visible ~ .checkbox-box,
.checkbox-group.checkbox-focused .checkbox-box {
  box-shadow: 0 0 0 1px var(--bg-primary), 0 0 0 3px var(--focus-ring, #92acf7);
}


/* ─── 9. Disabled State ─── */

.checkbox-disabled .checkbox-box {
  background-color: var(--bg-disabled_subtle, #fcfcfd);
  border-color: var(--border-disabled);
}

.checkbox-disabled .checkbox-input input:checked ~ .checkbox-box,
.checkbox-disabled .checkbox-input input.is-indeterminate ~ .checkbox-box,
.checkbox-disabled .checkbox-input input:indeterminate ~ .checkbox-box {
  background-color: var(--bg-disabled_subtle, #fcfcfd);
  border-color: var(--border-disabled);
}

.checkbox-disabled .checkbox-input input:checked ~ .checkbox-box i,
.checkbox-disabled .checkbox-input input.is-indeterminate ~ .checkbox-box i,
.checkbox-disabled .checkbox-input input:indeterminate ~ .checkbox-box i {
  color: var(--fg-disabled_subtle, #d0d5dd);
}

.checkbox-disabled .checkbox-input input {
  pointer-events: none;
}


/* ─── 10. Size: sm (16px) ─── */

.checkbox-sm .checkbox-input {
  width: 16px;
  height: 16px;
}

.checkbox-sm .checkbox-box {
  border-radius: var(--radius-xxs, 2px);
}

.checkbox-sm .checkbox-box i {
  font-size: 10px;
}


/* ─── 11. Label & Supporting Text ─── */

.checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.checkbox-label {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  /* md defaults */
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
  color: var(--text-primary);
}

.checkbox-supporting-text {
  font-family: var(--font-primary);
  font-weight: var(--font-weight-regular);
  /* md defaults */
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  color: var(--text-quaternary-500, #85888e);
}

/* sm text sizes */
.checkbox-sm .checkbox-label {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
}

.checkbox-sm .checkbox-supporting-text {
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
}

/* Disabled text */
.checkbox-disabled .checkbox-label {
  color: var(--text-disabled);
}

.checkbox-disabled .checkbox-supporting-text {
  color: var(--text-disabled);
}


/* ─── 12. Demo State Classes (pointer-events: none for showcase) ─── */

.checkbox-group.checkbox-focused {
  pointer-events: none;
}


/* ─── 13. Documentation Display Styles ─── */

.checkbox-demo-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.checkbox-states-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 24px 0;
}

.checkbox-state-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
}

.checkbox-state-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.checkbox-matrix {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 24px 0;
}

.checkbox-matrix-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
}

.checkbox-matrix-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}
