/**
 * Zentrale Button-Komponenten
 * Optimiert für maximale Usability und Barrierefreiheit
 */

/* === BASE BUTTON === */
.cc-btn {
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  
  /* Sizing */
  min-height: 44px; /* Touch-optimiert für mobile Geräte */
  padding: var(--space-md) var(--space-xl);
  
  /* Typography */
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  
  /* Visual */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  
  /* Interaction */
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  
  /* Accessibility */
  outline: none;
}

/* Hover State */
.cc-btn:hover {
  background: var(--bg);
  border-color: var(--teal);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Focus State - Barrierefreiheit */
.cc-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  box-shadow: var(--shadow-md), 0 0 0 2px rgba(18, 157, 156, 0.2);
}

/* Active State */
.cc-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Disabled State */
.cc-btn:disabled,
.cc-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

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

/* Primary - Hauptaktionen */
.cc-btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  font-weight: 600;
}

.cc-btn-primary:hover {
  background: var(--teal-600);
  border-color: var(--teal-600);
  color: white;
  box-shadow: 0 4px 12px rgba(18, 157, 156, 0.3);
}

/* Secondary - Sekundäre Aktionen */
.cc-btn-secondary {
  background: var(--accent);
  border-color: var(--teal);
  color: var(--teal);
}

.cc-btn-secondary:hover {
  background: var(--teal);
  color: white;
}

/* Ghost/Outline - Weniger prominente Aktionen */
.cc-btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
  box-shadow: none;
}

.cc-btn-ghost:hover {
  background: var(--accent);
  border-color: var(--teal);
  color: var(--teal);
}

/* Danger - Kritische Aktionen */
.cc-btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.cc-btn-danger:hover {
  background: #a91b1b;
  border-color: #a91b1b;
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.3);
}

/* Success - Erfolgsaktionen */
.cc-btn-success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.cc-btn-success:hover {
  background: #1b5e20;
  border-color: #1b5e20;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

/* Warning - Warnungsaktionen */
.cc-btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

.cc-btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

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

/* Small */
.cc-btn-sm {
  min-height: 36px;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
}

/* Large */
.cc-btn-lg {
  min-height: 52px;
  padding: var(--space-lg) var(--space-4xl);
  font-size: var(--text-lg);
  font-weight: 600;
}

/* Extra Large */
.cc-btn-xl {
  min-height: 60px;
  padding: var(--space-xl) var(--space-4xl);
  font-size: var(--text-xl);
  font-weight: 700;
}

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

/* Full Width */
.cc-btn-full {
  width: 100%;
  justify-content: center;
}

/* Icon Only - Quadratisch */
.cc-btn-icon {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
}

.cc-btn-icon.cc-btn-sm {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

.cc-btn-icon.cc-btn-lg {
  width: 52px;
  height: 52px;
  min-height: 52px;
}

/* Floating Action Button */
.cc-btn-fab {
  width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  border-radius: 50%;
  position: fixed;
  bottom: var(--space-3xl);
  right: var(--space-3xl);
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.cc-btn-fab:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

/* === SPECIAL BUTTON TYPES === */

/* Toggle Button */
.cc-btn-toggle {
  background: var(--card);
  border-color: var(--border);
}

.cc-btn-toggle.active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
}

.cc-btn-toggle:hover:not(.active) {
  background: var(--accent);
  border-color: var(--teal);
  color: var(--teal);
}

/* Segment Button (für Button-Gruppen) */
.cc-btn-segment {
  border-radius: 0;
  border-right-width: 0;
  margin-left: -1px;
}

.cc-btn-segment:first-child {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
  margin-left: 0;
}

.cc-btn-segment:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  border-right-width: 1px;
}

.cc-btn-segment.active {
  background: var(--teal);
  border-color: var(--teal);
  color: white;
  z-index: 1;
  position: relative;
}

/* Link Button - Sieht aus wie Text-Link */
.cc-btn-link {
  background: transparent;
  border: none;
  color: var(--teal);
  padding: var(--space-sm);
  min-height: auto;
  box-shadow: none;
  text-decoration: underline;
  font-weight: normal;
}

.cc-btn-link:hover {
  background: transparent;
  color: var(--teal-600);
  transform: none;
  box-shadow: none;
}

/* === ACCESSIBILITY IMPROVEMENTS === */

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .cc-btn {
    transition: none;
  }
  
  .cc-btn:hover,
  .cc-btn:active {
    transform: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .cc-btn {
    border-width: 2px;
  }
  
  .cc-btn:focus-visible {
    outline-width: 3px;
  }
}

/* === LOADING STATE === */
.cc-btn.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.cc-btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: cc-spin 0.8s linear infinite;
  color: var(--text-secondary);
}

.cc-btn-primary.loading::after,
.cc-btn-danger.loading::after,
.cc-btn-success.loading::after,
.cc-btn-warning.loading::after {
  color: white;
}

@keyframes cc-spin {
  to {
    transform: rotate(360deg);
  }
}

/* === MOBILE OPTIMIZATIONS === */
@media (max-width: 768px) {
  .cc-btn {
    min-height: 48px; /* Größere Touch-Targets */
    padding: var(--space-lg) var(--space-2xl);
  }
  
  .cc-btn-sm {
    min-height: 40px;
    padding: var(--space-md) var(--space-xl);
  }
  
  .cc-btn-icon {
    width: 48px;
    height: 48px;
    min-height: 48px;
  }
  
  .cc-btn-icon.cc-btn-sm {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
  
  /* Mobile-First: Buttons in Gruppen werden full-width */
  .cc-actions .cc-btn:not(.cc-btn-icon) {
    flex: 1;
    min-width: 0;
  }
}

/* === BUTTON GROUPS === */
.cc-btn-group {
  display: inline-flex;
  align-items: center;
}

.cc-btn-group .cc-btn {
  margin-left: -1px;
  border-radius: 0;
}

.cc-btn-group .cc-btn:first-child {
  margin-left: 0;
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

.cc-btn-group .cc-btn:last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.cc-btn-group .cc-btn:hover,
.cc-btn-group .cc-btn.active {
  z-index: 1;
  position: relative;
}

/* === UTILITY CLASSES === */
.cc-btn-rounded {
  border-radius: var(--radius-full);
}

.cc-btn-square {
  border-radius: 0;
}

.cc-btn-shadow {
  box-shadow: var(--shadow-lg);
}

.cc-btn-shadow:hover {
  box-shadow: var(--shadow-xl);
}

/* Material Icons in Buttons */
.cc-btn .material-icons-outlined {
  font-size: 18px;
  flex-shrink: 0;
}

.cc-btn-sm .material-icons-outlined {
  font-size: 16px;
}

.cc-btn-lg .material-icons-outlined {
  font-size: 20px;
}

.cc-btn-xl .material-icons-outlined {
  font-size: 24px;
}