/**
 * Toggle and ToggleGroup - Pressable toggle button styles
 * @countermeasure/web-components/primitives/toggle
 */

/* ============================================================================
   BASE TOGGLE
   ============================================================================ */
.cmm-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color var(--transition-fast) ease-in-out,
    color var(--transition-fast) ease-in-out,
    border-color var(--transition-fast) ease-in-out;
  user-select: none;
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid transparent;
}

/* ============================================================================
   VARIANTS
   ============================================================================ */

/* Default variant - no visible border, subtle hover */
.cmm-toggle--default {
  border-color: transparent;
}

.cmm-toggle--default:hover {
  background-color: hsl(var(--muted));
}

.cmm-toggle--default.cmm-toggle--pressed {
  background-color: hsl(var(--muted));
  color: hsl(var(--foreground));
}

/* Outline variant - visible border */
.cmm-toggle--outline {
  border-color: hsl(var(--border));
}

.cmm-toggle--outline:hover {
  background-color: hsl(var(--muted));
}

.cmm-toggle--outline.cmm-toggle--pressed {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

/* ============================================================================
   STATES
   ============================================================================ */

/* Focus */
.cmm-toggle:focus-visible {
  outline: 2px solid hsl(var(--focus-ring));
  outline-offset: 2px;
}

/* Disabled */
.cmm-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================================
   ICON
   ============================================================================ */
.cmm-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.cmm-toggle__icon > svg {
  width: 100%;
  height: 100%;
}

/* ============================================================================
   TOGGLE GROUP
   ============================================================================ */
.cmm-toggle-group {
  display: inline-flex;
}

/* Horizontal layout */
.cmm-toggle-group--horizontal {
  flex-direction: row;
}

/* Vertical layout */
.cmm-toggle-group--vertical {
  flex-direction: column;
}

/* ============================================================================
   CONNECTED BUTTONS - HORIZONTAL
   ============================================================================ */
.cmm-toggle-group--horizontal > .cmm-toggle {
  border-radius: 0;
}

.cmm-toggle-group--horizontal > .cmm-toggle:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.cmm-toggle-group--horizontal > .cmm-toggle:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

/* Remove double borders between items */
.cmm-toggle-group--horizontal > .cmm-toggle + .cmm-toggle {
  margin-left: -1px;
}

/* ============================================================================
   CONNECTED BUTTONS - VERTICAL
   ============================================================================ */
.cmm-toggle-group--vertical > .cmm-toggle {
  border-radius: 0;
  width: 100%;
}

.cmm-toggle-group--vertical > .cmm-toggle:first-child {
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.cmm-toggle-group--vertical > .cmm-toggle:last-child {
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

/* Remove double borders between items */
.cmm-toggle-group--vertical > .cmm-toggle + .cmm-toggle {
  margin-top: -1px;
}
