/* Button Component Styles */
.btn {
  position: relative;
  overflow: hidden;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: 1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  border: 2px solid transparent;
  border-radius: var(--radius-base);
  padding: var(--space-3) var(--space-6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: all var(--transition-base);
  min-height: 44px; /* Accessibility: minimum touch target */
}

/* Button Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #1e40af);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
  color: white;
  border-color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #047857);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary-color);
  font-weight: var(--font-medium);
  cursor: pointer;
  padding: var(--space-2) 0;
  text-decoration: none;
  transition: all var(--transition-fast);
  min-height: auto;
}

.btn-text:hover {
  color: var(--primary-hover);
  text-decoration: underline;
  transform: none;
}

.btn-text:active {
  transform: none;
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  min-height: 36px;
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
  min-height: 52px;
}

.btn-xl {
  padding: var(--space-5) var(--space-10);
  font-size: var(--text-xl);
  min-height: 60px;
}

/* Button Width */
.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-auto {
  width: auto;
}

/* Button States */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn:disabled:hover {
  transform: none !important;
  box-shadow: var(--shadow-sm) !important;
}

.btn:disabled:active {
  transform: none !important;
}

/* Loading State */
.btn.loading {
  pointer-events: none;
}

.btn.loading .btn-text {
  opacity: 0;
}

.btn .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Button Icons */
.btn .icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-sm .icon {
  width: 16px;
  height: 16px;
}

.btn-lg .icon {
  width: 24px;
  height: 24px;
}

.btn-xl .icon {
  width: 28px;
  height: 28px;
}

/* Button Animations */
.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.2), 
    transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

/* Special Button Styles */
.btn-gradient {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
  border: none;
  box-shadow: var(--shadow-md);
}

.btn-gradient:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--accent-hover));
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-ghost:hover {
  background-color: var(--bg-secondary);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}

.btn-danger {
  background-color: #ef4444;
  color: white;
  border-color: #ef4444;
}

.btn-danger:hover {
  background-color: #dc2626;
  border-color: #dc2626;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.btn-success:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Button Groups */
.btn-group {
  display: flex;
  gap: var(--space-2);
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-top-left-radius: var(--radius-base);
  border-bottom-left-radius: var(--radius-base);
}

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

.btn-group .btn:not(:first-child):not(:last-child) {
  border-left: none;
  border-right: none;
}

.btn-group .btn:not(:first-child) {
  border-left: none;
}

.btn-group .btn:not(:last-child) {
  border-right: none;
}

/* Responsive Button Adjustments */
@media (max-width: 768px) {
  .btn {
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-sm);
  }
  
  .btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
  }
  
  .btn-xl {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
  }
}

@media (max-width: 480px) {
  .btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    min-height: 40px;
  }
  
  .btn-group {
    flex-direction: column;
  }
  
  .btn-group .btn {
    border-radius: var(--radius-base);
    border: 2px solid var(--primary-color);
  }
  
  .btn-group .btn:not(:first-child) {
    border-top: none;
  }
}

/* Focus States for Accessibility */
.btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.btn:focus:not(:focus-visible) {
  outline: none;
}

.btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .btn-primary {
    background: var(--primary-color);
    border-color: var(--text-primary);
  }
  
  .btn-outline {
    border-width: 3px;
  }
  
  .btn:focus {
    outline-width: 3px;
  }
}

/* Flickering Animation for Navigation Buttons */
/* Hero Section Buttons - All buttons same exact width (matching longest) */
.hero-cta .btn.btn-outline {
  width: 240px !important; /* Fixed width - same for all buttons, matching longest */
  min-width: 240px !important;
  max-width: 240px !important;
  padding: var(--space-3) var(--space-8) !important; /* Increased horizontal padding (32px) */
  gap: var(--space-4) !important; /* Increased gap between icon and text (16px) */
  justify-content: flex-start !important; /* Icon and text aligned to left with proper spacing */
  position: relative;
}

/* Ensure icon and text have proper spacing in hero buttons */
.hero-cta .btn.btn-outline .icon,
.hero-cta .btn.btn-outline svg {
  flex-shrink: 0; /* Prevent icon from shrinking */
  margin-right: 0; /* Gap handled by parent gap property */
}

.hero-cta .btn.btn-outline span.icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.hero-cta .btn.btn-outline[href="#projects"],
.hero-cta .btn.btn-outline[href="#contact"],
.hero-cta .btn.btn-outline[href*="resume"] {
  position: relative;
}

/* All hero buttons - bullets positioned at right edge of box (same for all) */
.hero-cta .btn.btn-outline[href="#projects"]::after,
.hero-cta .btn.btn-outline[href="#contact"]::after,
.hero-cta .btn.btn-outline[href*="resume"]::after {
  content: '';
  position: absolute;
  right: var(--space-6); /* Same position at right edge for all buttons */
  top: calc(50% - 5px); /* Moved up by 5px for proper alignment */
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
  -webkit-animation: rapidFlicker 0.3s ease-in-out infinite;
  -moz-animation: rapidFlicker 0.3s ease-in-out infinite;
  -ms-animation: rapidFlicker 0.3s ease-in-out infinite;
  -o-animation: rapidFlicker 0.3s ease-in-out infinite;
  animation: rapidFlicker 0.3s ease-in-out infinite;
  flex-shrink: 0; /* Prevent bullet from shrinking */
}

/* Preview CV Buttons (outside hero) - Always Flickering */
/* Sidebar Preview CV - Add flicker but DON'T increase length */
.sidebar .btn.btn-outline[href*="resume"],
.sidebar .btn.btn-outline.btn-block[href*="resume"] {
  position: relative;
  /* NO min-width or padding changes - keep original size */
  gap: var(--space-4) !important; /* Proper gap between icon and text */
  justify-content: flex-start !important; /* Icon and text aligned to left */
}

.sidebar .btn.btn-outline[href*="resume"]::after,
.sidebar .btn.btn-outline.btn-block[href*="resume"]::after {
  content: '';
  position: absolute;
  right: var(--space-6); /* Proper gap from right edge */
  top: calc(50% - 5px); /* Moved up by 5px for proper alignment */
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
  -webkit-animation: rapidFlicker 0.3s ease-in-out infinite;
  -moz-animation: rapidFlicker 0.3s ease-in-out infinite;
  -ms-animation: rapidFlicker 0.3s ease-in-out infinite;
  -o-animation: rapidFlicker 0.3s ease-in-out infinite;
  animation: rapidFlicker 0.3s ease-in-out infinite;
}

/* Preview CV in Contact Section - Add flicker with increased length */
#contact .btn.btn-outline[href*="resume"],
.contact-section .btn.btn-outline[href*="resume"],
#contact a.btn.btn-outline[href*="resume"],
.contact-section a.btn.btn-outline[href*="resume"] {
  position: relative;
  min-width: 200px !important; /* Increased minimum width for contact section */
  padding: var(--space-3) var(--space-8) !important; /* Increased horizontal padding */
  gap: var(--space-4) !important; /* Proper gap between icon and text */
  justify-content: flex-start !important;
}

#contact .btn.btn-outline[href*="resume"]::after,
.contact-section .btn.btn-outline[href*="resume"]::after,
#contact a.btn.btn-outline[href*="resume"]::after,
.contact-section a.btn.btn-outline[href*="resume"]::after {
  content: '';
  position: absolute;
  right: var(--space-6);
  top: calc(50% - 5px); /* Moved up by 5px for proper alignment */
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
  -webkit-animation: rapidFlicker 0.3s ease-in-out infinite;
  -moz-animation: rapidFlicker 0.3s ease-in-out infinite;
  -ms-animation: rapidFlicker 0.3s ease-in-out infinite;
  -o-animation: rapidFlicker 0.3s ease-in-out infinite;
  animation: rapidFlicker 0.3s ease-in-out infinite;
}

/* View All Projects on GitHub - Always Flickering with proper alignment */
.projects-cta .btn.btn-outline[href*="github"] {
  position: relative;
  min-width: 350px; /* Increased minimum width for longer button */
  padding: var(--space-3) var(--space-8) !important; /* Increased horizontal padding (32px) */
  gap: var(--space-4) !important; /* Proper gap between icon and text (16px) */
  justify-content: flex-start !important; /* Icon and text aligned to left */
}

.projects-cta .btn.btn-outline[href*="github"]::after {
  content: '';
  position: absolute;
  right: var(--space-6); /* Same gap as "View My Work" and "Let's Connect" */
  top: calc(50% - 5px); /* Moved up by 5px for proper alignment */
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
  -webkit-animation: rapidFlicker 0.3s ease-in-out infinite;
  -moz-animation: rapidFlicker 0.3s ease-in-out infinite;
  -ms-animation: rapidFlicker 0.3s ease-in-out infinite;
  -o-animation: rapidFlicker 0.3s ease-in-out infinite;
  animation: rapidFlicker 0.3s ease-in-out infinite;
}

/* Import rapidFlicker keyframes - they're defined in sidebar-skills.css */
/* If not imported, define here */
@keyframes rapidFlicker {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  25% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  75% {
    opacity: 0.5;
    transform: scale(0.9);
  }
}

@-webkit-keyframes rapidFlicker {
  0%, 100% {
    opacity: 1;
    -webkit-transform: scale(1);
    transform: scale(1);
  }
  25% {
    opacity: 0.3;
    -webkit-transform: scale(0.8);
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    -webkit-transform: scale(1.2);
    transform: scale(1.2);
  }
  75% {
    opacity: 0.5;
    -webkit-transform: scale(0.9);
    transform: scale(0.9);
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
  
  .btn::before {
    display: none;
  }
  
  .btn:hover {
    transform: none;
  }
  
  .btn:active {
    transform: none;
  }
  
  /* Disable flicker animation for reduced motion */
  .btn::after,
  .hero-cta .btn::after,
  a.btn[href*="resume"]::after,
  .projects-cta .btn::after {
    -webkit-animation: none !important;
    -moz-animation: none !important;
    -ms-animation: none !important;
    -o-animation: none !important;
    animation: none !important;
  }
}
