/* Button Component Global Styles
 * 
 * Uses CSS variables defined in variables.css
 * All colors can be customized by consumers via :root overrides
 * 
 * Implements DHCS Visual Identity Guidelines for buttons.
 */

/* Base wrapper */
.dhcs-button-wrapper {
  display: inline-block;
}

/* Base button styles - remove text transform */
.dhcs-button-wrapper .mud-button-root {
  text-transform: none !important;
  font-family: var(--dhcs-font-family-default) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 20px !important;
  padding: 10px var(--dhcs-spacing-md);
  border-radius: 4px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  white-space: normal;
  display: inline-flex;
  align-items: center;
}

/* Button text styling */
.dhcs-button-wrapper .dhcs-button-text,
.dhcs-button-wrapper .mud-button-label {
  font-weight: 700;
  text-transform: none !important;
}

/* ===== FILLED/PRIMARY BUTTONS ===== */
/* Default state */
.dhcs-button-wrapper .mud-button-root.dhcs-button-filled.dhcs-button-primary {
  background-color: var(--dhcs-color-primary) !important;
  color: var(--dhcs-color-text-white) !important;
  border: none;
}

/* Remove default focus outline */
.dhcs-button-wrapper .mud-button-root:focus {
  outline: none;
}

/* Hover state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-filled.dhcs-button-primary:hover:not(:disabled) {
  background-color: var(--dhcs-color-secondary) !important;
}

/* Focus ring - only show on keyboard navigation, not on click */
/* Must come AFTER hover to override */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-filled.dhcs-button-primary:focus-visible,
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-filled.dhcs-button-primary:focus-visible:hover {
  background-color: var(--dhcs-color-primary) !important;
  box-shadow:
    0 0 0 3px var(--dhcs-color-text-white),
    0 0 0 5px var(--dhcs-color-primary) !important;
}

/* Pressed/Active state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-filled.dhcs-button-primary:active:not(
    :disabled
  ) {
  background-color: var(--dhcs-color-primary-dark) !important;
}

/* Disabled state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-filled.dhcs-button-primary:disabled {
  background-color: var(--dhcs-color-disabled-light) !important;
  color: var(--dhcs-color-text-white) !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
}

/* ===== OUTLINED/SECONDARY BUTTONS ===== */
/* Default state */
.dhcs-button-wrapper .mud-button-root.dhcs-button-outlined {
  background-color: transparent !important;
  border-left-width: 2px;
  border-right-width: 2px;
  border-top-width: 2px;
  border-bottom-width: 2px;
  border-style: solid;
}

.dhcs-button-wrapper .mud-button-root.dhcs-button-outlined.dhcs-button-primary {
  border-color: var(--dhcs-color-primary) !important;
  color: var(--dhcs-color-primary) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-secondary {
  border-color: var(--dhcs-color-secondary) !important;
  color: var(--dhcs-color-secondary) !important;
}

/* Hover state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-primary:hover:not(
    :disabled
  ) {
  background-color: rgba(45, 110, 141, 0.08) !important;
  border-color: var(--dhcs-color-secondary) !important;
  color: var(--dhcs-color-secondary) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-secondary:hover:not(
    :disabled
  ) {
  background-color: rgba(45, 110, 141, 0.08) !important;
  border-color: var(--dhcs-color-secondary) !important;
}

/* Focus ring - only show on keyboard navigation, not on click */
/* Must come AFTER hover to override */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-primary:focus-visible,
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-primary:focus-visible:hover {
  background-color: transparent !important;
  border-color: var(--dhcs-color-primary) !important;
  color: var(--dhcs-color-primary) !important;
  box-shadow:
    0 0 0 3px var(--dhcs-color-text-white),
    0 0 0 5px var(--dhcs-color-primary) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-secondary:focus-visible,
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-secondary:focus-visible:hover {
  background-color: transparent !important;
  border-color: var(--dhcs-color-secondary) !important;
  color: var(--dhcs-color-secondary) !important;
  box-shadow:
    0 0 0 3px var(--dhcs-color-text-white),
    0 0 0 5px var(--dhcs-color-secondary) !important;
}

/* Pressed/Active state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-primary:active:not(
    :disabled
  ) {
  background-color: rgba(23, 49, 90, 0.16) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-outlined.dhcs-button-secondary:active:not(
    :disabled
  ) {
  background-color: rgba(45, 110, 141, 0.16) !important;
}

/* Disabled state */
.dhcs-button-wrapper .mud-button-root.dhcs-button-outlined:disabled {
  border-color: var(--dhcs-color-disabled-light) !important;
  color: var(--dhcs-color-disabled-light) !important;
  background-color: transparent !important;
  cursor: not-allowed;
  opacity: 1 !important;
}

/* ===== TEXT/TERTIARY BUTTONS ===== */
/* Default state */
.dhcs-button-wrapper .mud-button-root.dhcs-button-text {
  background-color: transparent !important;
  border: none;
  padding: 10px var(--dhcs-spacing-md);
}

.dhcs-button-wrapper .mud-button-root.dhcs-button-text.dhcs-button-primary {
  color: var(--dhcs-color-primary) !important;
}

.dhcs-button-wrapper .mud-button-root.dhcs-button-text.dhcs-button-secondary {
  color: var(--dhcs-color-secondary) !important;
}

/* Hover state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-primary:hover:not(:disabled) {
  background-color: rgba(45, 110, 141, 0.08) !important;
  color: var(--dhcs-color-secondary) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-secondary:hover:not(:disabled) {
  background-color: rgba(45, 110, 141, 0.08) !important;
}

/* Focus ring - only show on keyboard navigation, not on click */
/* Must come AFTER hover to override */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-primary:focus-visible,
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-primary:focus-visible:hover {
  background-color: transparent !important;
  color: var(--dhcs-color-primary) !important;
  box-shadow:
    0 0 0 3px var(--dhcs-color-text-white),
    0 0 0 5px var(--dhcs-color-primary) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-secondary:focus-visible,
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-secondary:focus-visible:hover {
  background-color: transparent !important;
  color: var(--dhcs-color-secondary) !important;
  box-shadow:
    0 0 0 3px var(--dhcs-color-text-white),
    0 0 0 5px var(--dhcs-color-secondary) !important;
}

/* Pressed/Active state */
.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-primary:active:not(:disabled) {
  background-color: rgba(23, 49, 90, 0.16) !important;
}

.dhcs-button-wrapper
  .mud-button-root.dhcs-button-text.dhcs-button-secondary:active:not(
    :disabled
  ) {
  background-color: rgba(45, 110, 141, 0.16) !important;
}

/* Disabled state */
.dhcs-button-wrapper .mud-button-root.dhcs-button-text:disabled {
  color: var(--dhcs-color-disabled-light) !important;
  background-color: transparent !important;
  cursor: not-allowed;
  opacity: 1 !important;
}

/* ===== ICON BUTTONS ===== */
.dhcs-button-wrapper .mud-button-root .mud-icon-root {
  font-size: 20px;
  vertical-align: middle;
  display: inline-flex;
  align-items: center;
}

/* Icon spacing */
.dhcs-button-wrapper .mud-button-root .mud-button-icon-start {
  margin-right: var(--dhcs-spacing-sm);
}

.dhcs-button-wrapper .mud-button-root .mud-button-icon-end {
  margin-left: var(--dhcs-spacing-sm);
}

/* Icon-only buttons - square shape */
.dhcs-button-wrapper .mud-button-root.mud-icon-button {
  width: 40px;
  min-width: 40px;
  padding: 10px;
}

/* ===== BACK TO TOP BUTTON ===== */
.dhcs-button-wrapper .mud-button-root.dhcs-button-back-to-top {
  min-width: 120px;
}

/* ===== TOGGLE BUTTON ===== */
.toggle-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  outline: none;
}

.toggle-button:focus-visible {
  box-shadow:
    0 0 0 3px var(--dhcs-color-text-white),
    0 0 0 5px var(--dhcs-color-primary);
  border-radius: 20px;
}

.toggle-button.toggle-disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.toggle-track {
  position: relative;
  width: 48px;
  height: 24px;
  border-radius: 12px;
  transition: background-color 0.2s ease;
}

.toggle-track-off {
  background-color: var(--dhcs-color-disabled-light);
}

.toggle-track-on {
  background-color: var(--dhcs-color-primary);
}

.toggle-button.toggle-disabled .toggle-track {
  background-color: var(--dhcs-color-border-default);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: var(--dhcs-color-text-white);
  transition: transform 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-thumb-off {
  transform: translateX(2px);
}

.toggle-thumb-on {
  transform: translateX(26px);
}

/* ===== RESPONSIVE DESIGN ===== */
/* Full width buttons */
.dhcs-button-wrapper-fullwidth {
  display: block !important;
  width: 100%;
}

.dhcs-button-wrapper .mud-button-root.mud-button-fullwidth {
  width: 100%;
  display: flex;
}
