/* Global Button CSS Variables */
:root {
  /* Button Colors */
  --button-primary-bg: var(--color-secondary);
  --button-primary-bg-hover: var(--color-secondary-hover);
  --button-primary-bg-disabled: var(--color-secondary-disabled);
  --button-primary-text: white;
  
  --button-secondary-bg: var(--color-gray-disabled);
  --button-secondary-bg-hover: var(--color-gray);
  --button-secondary-bg-disabled: var(--color-gray-disabled);
  --button-secondary-text: var(--color-text);
  
  --button-danger-bg: var(--color-red, #C53030);
  --button-danger-bg-hover: #9B2C2C;
  --button-danger-bg-disabled: rgba(197, 48, 48, 0.4);
  --button-danger-text: white;
  
  --button-success-bg: var(--color-success, #38A169);
  --button-success-bg-hover: #2F855A;
  --button-success-bg-disabled: rgba(56, 161, 105, 0.4);
  --button-success-text: white;
  
  --button-warning-bg: #D69E2E;
  --button-warning-bg-hover: #B7791F;
  --button-warning-bg-disabled: rgba(214, 158, 46, 0.4);
  --button-warning-text: white;
  
  /* Button Sizes */
  --button-sm-padding: 6px 14px;
  --button-sm-font-size: 12px;
  --button-sm-icon-size: 14px;
  
  --button-md-padding: 8px 18px;
  --button-md-font-size: 14px;
  --button-md-icon-size: 16px;
  
  --button-lg-padding: 10px 22px;
  --button-lg-font-size: 15px;
  --button-lg-icon-size: 18px;
  
  /* Button Border Radius */
  --button-border-radius: 6px;
  
  /* Button Transitions */
  --button-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Button Styles */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--button-border-radius);
  font-family: var(--font-family);
  font-weight: 500;
  cursor: pointer;
  transition: var(--button-transition);
  text-decoration: none;
  outline: none;
  position: relative;
  white-space: nowrap;
  user-select: none;
  letter-spacing: 0.01em;
}

.button:focus-visible {
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px rgba(var(--color-secondary-rgb, 74, 111, 165), 0.5);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.button.loading {
  cursor: not-allowed;
  opacity: 0.65;
}

.button.loading .buttonIcon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Button Variants */
.buttonPrimary {
  background: linear-gradient(180deg, var(--button-primary-bg) 0%, var(--button-primary-bg-hover) 100%);
  color: var(--button-primary-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.buttonPrimary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--button-primary-bg-hover) 0%, var(--button-primary-bg-hover) 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.buttonPrimary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.buttonSecondary {
  background: linear-gradient(180deg, var(--color-bg, #fff) 0%, var(--button-secondary-bg) 100%);
  color: var(--button-secondary-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: 1px solid var(--color-border, #E2E8F0);
}

.buttonSecondary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--color-gray) 0%, var(--color-gray-hover) 100%);
  color: white;
  border-color: var(--color-gray);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.buttonSecondary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.buttonDanger {
  background: linear-gradient(180deg, var(--button-danger-bg) 0%, var(--button-danger-bg-hover) 100%);
  color: var(--button-danger-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.buttonDanger:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--button-danger-bg-hover) 0%, var(--button-danger-bg-hover) 100%);
  box-shadow: 0 2px 6px rgba(197, 48, 48, 0.25);
  transform: translateY(-1px);
}

.buttonDanger:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.buttonSuccess {
  background: linear-gradient(180deg, var(--button-success-bg) 0%, var(--button-success-bg-hover) 100%);
  color: var(--button-success-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.buttonSuccess:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--button-success-bg-hover) 0%, var(--button-success-bg-hover) 100%);
  box-shadow: 0 2px 6px rgba(56, 161, 105, 0.25);
  transform: translateY(-1px);
}

.buttonSuccess:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.buttonWarning {
  background: linear-gradient(180deg, var(--button-warning-bg) 0%, var(--button-warning-bg-hover) 100%);
  color: var(--button-warning-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.buttonWarning:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--button-warning-bg-hover) 0%, var(--button-warning-bg-hover) 100%);
  box-shadow: 0 2px 6px rgba(214, 158, 46, 0.25);
  transform: translateY(-1px);
}

.buttonWarning:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Button Sizes */
.buttonSm {
  padding: var(--button-sm-padding);
  font-size: var(--button-sm-font-size);
}

.buttonSm .buttonIcon {
  font-size: var(--button-sm-icon-size);
}

.buttonMd {
  padding: var(--button-md-padding);
  font-size: var(--button-md-font-size);
}

.buttonMd .buttonIcon {
  font-size: var(--button-md-icon-size);
}

.buttonLg {
  padding: var(--button-lg-padding);
  font-size: var(--button-lg-font-size);
}

.buttonLg .buttonIcon {
  font-size: var(--button-lg-icon-size);
}

/* Icon Styles */
.buttonIcon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.buttonIconLeft {
  order: -1;
}

.buttonIconRight {
  order: 1;
}

/* Loading Spinner */
.buttonSpinner {
  width: 1em;
  height: 1em;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Upload Button Specific Styles */
.uploadButton {
  position: relative;
}

.hiddenInput {
  display: none;
}

/* Spinner Icon for Upload Button */
.spinnerIcon {
  width: 1em;
  height: 1em;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
  .buttonSm {
    padding: 4px 10px;
    font-size: 11px;
  }
  
  .buttonMd {
    padding: 6px 14px;
    font-size: 13px;
  }
  
  .buttonLg {
    padding: 8px 18px;
    font-size: 14px;
  }
}
