/* Simple Button Module Styles */

/* Wrapper */
.sb-wrapper {
  position: relative;
  display: inline-block;
}

/* Base Button Styles */
.sb-button {
  display: inline-block;
  padding: 12px 24px;
  background-color: #f8f9fa;
  color: #333333;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  min-height: 44px;
  vertical-align: baseline;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Hover State */
.sb-button:hover {
  background-color: #e9ecef;
  color: #333333;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Active State */
.sb-button:active {
  background-color: #dee2e6;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(1px);
}

/* Focus State */
.sb-button:focus {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
  text-decoration: none;
}

/* Focus Visible (for better accessibility) */
.sb-button:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Visited State */
.sb-button:visited {
  color: inherit;
}

/* Disabled State */
.sb-button[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Loading State (for future use) */
.sb-button.sb-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.sb-button.sb-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #333;
  border-radius: 50%;
  animation: sb-spin 1s linear infinite;
}

@keyframes sb-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Smooth Scroll Indicator (optional visual feedback) */
.sb-button[data-smooth-scroll="true"] {
  position: relative;
}

.sb-button[data-smooth-scroll="true"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 49%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 51%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  border-radius: inherit;
}

.sb-button[data-smooth-scroll="true"]:hover::before {
  opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sb-button {
    min-height: 48px; /* Larger touch target on mobile */
    padding: 14px 20px;
  }
}

@media (max-width: 480px) {
  .sb-button {
    font-size: 15px;
    padding: 12px 18px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .sb-button {
    border: 2px solid currentColor;
  }

  .sb-button:focus {
    outline: 3px solid #0066cc;
    outline-offset: 3px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .sb-button,
  .sb-button::before,
  .sb-button::after {
    transition: none;
    animation: none;
  }

  .sb-button:active {
    transform: none;
  }
}

/* Print Styles */
@media print {
  .sb-button {
    background: transparent !important;
    color: #000 !important;
    border: 1px solid #000 !important;
    box-shadow: none !important;
  }

  .sb-button::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}

/* Theme Compatibility - Defensive CSS */
.sb-wrapper,
.sb-wrapper * {
  box-sizing: border-box;
}

.sb-wrapper .sb-button {
  font-family: inherit;
  line-height: inherit;
}

/* Override common theme conflicts */
.sb-button {
  list-style: none;
  margin: 0;
  background-image: none;
  text-shadow: none;
  border-collapse: separate;
  border-spacing: 0;
  empty-cells: show;
  caption-side: top;
  table-layout: auto;
}

.sb-button::before,
.sb-button::after {
  box-sizing: border-box;
}

/* Ensure proper stacking */
.sb-wrapper {
  z-index: auto;
}

/* Button Variants (for future use) */
.sb-button.sb-primary {
  background-color: #007cba;
  color: #ffffff;
  border-color: #007cba;
}

.sb-button.sb-primary:hover {
  background-color: #005a87;
  border-color: #005a87;
}

.sb-button.sb-secondary {
  background-color: #6c757d;
  color: #ffffff;
  border-color: #6c757d;
}

.sb-button.sb-secondary:hover {
  background-color: #5a6268;
  border-color: #5a6268;
}

.sb-button.sb-success {
  background-color: #28a745;
  color: #ffffff;
  border-color: #28a745;
}

.sb-button.sb-success:hover {
  background-color: #218838;
  border-color: #218838;
}

.sb-button.sb-danger {
  background-color: #dc3545;
  color: #ffffff;
  border-color: #dc3545;
}

.sb-button.sb-danger:hover {
  background-color: #c82333;
  border-color: #c82333;
}

.sb-button.sb-warning {
  background-color: #ffc107;
  color: #212529;
  border-color: #ffc107;
}

.sb-button.sb-warning:hover {
  background-color: #e0a800;
  border-color: #e0a800;
}

.sb-button.sb-info {
  background-color: #17a2b8;
  color: #ffffff;
  border-color: #17a2b8;
}

.sb-button.sb-info:hover {
  background-color: #138496;
  border-color: #138496;
}

.sb-button.sb-light {
  background-color: #f8f9fa;
  color: #212529;
  border-color: #f8f9fa;
}

.sb-button.sb-light:hover {
  background-color: #e2e6ea;
  border-color: #e2e6ea;
}

.sb-button.sb-dark {
  background-color: #343a40;
  color: #ffffff;
  border-color: #343a40;
}

.sb-button.sb-dark:hover {
  background-color: #23272b;
  border-color: #23272b;
}

/* Size Variants */
.sb-button.sb-small {
  padding: 8px 16px;
  font-size: 14px;
  min-height: 36px;
}

.sb-button.sb-large {
  padding: 16px 32px;
  font-size: 18px;
  min-height: 52px;
}

/* Block Button */
.sb-button.sb-block {
  display: block;
  width: 100%;
}

/* Outline Variants */
.sb-button.sb-outline {
  background-color: transparent;
  border-width: 2px;
}

.sb-button.sb-outline:hover {
  background-color: currentColor;
  color: #ffffff;
}

/* Ghost Button */
.sb-button.sb-ghost {
  background-color: transparent;
  border: none;
  box-shadow: none;
}

.sb-button.sb-ghost:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Gradient Button Support */
.sb-button.sb-gradient {
  border: none;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.sb-button.sb-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Icon Support (for future use) */
.sb-button .sb-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  margin-right: 0.5em;
}

.sb-button .sb-icon:last-child {
  margin-right: 0;
  margin-left: 0.5em;
}

.sb-button .sb-icon:only-child {
  margin: 0;
}

/* RTL Support */
[dir="rtl"] .sb-button .sb-icon {
  margin-right: 0;
  margin-left: 0.5em;
}

[dir="rtl"] .sb-button .sb-icon:last-child {
  margin-left: 0;
  margin-right: 0.5em;
}

/* Animation Classes */
.sb-button.sb-animate-pulse {
  animation: sb-pulse 2s infinite;
}

@keyframes sb-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.sb-button.sb-animate-bounce {
  animation: sb-bounce 1s infinite;
}

@keyframes sb-bounce {
  0%,
  20%,
  53%,
  80%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  40%,
  43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

/* Accessibility Improvements */
.sb-button[aria-pressed="true"] {
  background-color: #dee2e6;
  border-color: #dee2e6;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Screen Reader Only Text */
.sb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus Ring for Windows High Contrast Mode */
@media screen and (-ms-high-contrast: active) {
  .sb-button:focus {
    outline: 2px solid;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .sb-button {
    background-color: #495057;
    color: #ffffff;
    border-color: #6c757d;
  }

  .sb-button:hover {
    background-color: #6c757d;
    border-color: #868e96;
  }

  .sb-button:active {
    background-color: #343a40;
    border-color: #495057;
  }
}
