/**
 * =====================================================
 * BUTTON-SPECIFIC VARIABLES
 * =====================================================
 * These extend the main styles.css variables
 */
:root {
  /* Button color mappings using existing variables */
  --btn-primary: #b5a881; /* Original tan color */
  --btn-primary-hover: #9a8d6f; /* Slightly darker on hover */

  /* Secondary Button - Dark Blue with White Text */
  --btn-secondary: pink;
  --btn-secondary-hover: #d85508; /* Darker orange for better contrast */

  /* Success Button - Green (not in main variables) */
  --btn-success: #198754;
  --btn-success-hover: #157347;

  /* Danger Button - Orange */
  --btn-danger: #d85508; /* Darker orange for contrast */
  --btn-danger-hover: #b54708; /* Even darker on hover */

  /* White Button */
  --btn-white: var(--white);
  --btn-white-hover: var(--light-bg);

  /* Text Colors */
  --btn-text-dark: #1a1a1a; /* Very dark for maximum contrast */
  --btn-text-light: var(--white);

  /* Button Properties */
  --btn-radius: var(--border-radius);
  --btn-transition: var(--transition);
}

/**
 * =====================================================
 * BASE BUTTON STYLES
 * =====================================================
 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600; /* Increased weight for better readability */
  line-height: 1.5;
  text-decoration: none;
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition: var(--btn-transition);
  position: relative;
  overflow: hidden;
}

/* Remove pseudo elements */
.btn::before,
.btn::after {
  display: none !important;
}

/* Focus State - High contrast */
.btn:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

/* Disabled State */
.btn:disabled {
  opacity: 0.7; /* Not too faint */
  cursor: not-allowed;
}

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

/* PRIMARY BUTTON - Original tan with black text for contrast */
.btn-primary {
  background-color: var(--btn-primary);
  color: var(--btn-text-dark); /* Black text for contrast */
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--btn-primary-hover);
  color: var(--btn-text-dark); /* Keep black text */
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(181, 168, 129, 0.25);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(181, 168, 129, 0.25);
}

/* SECONDARY BUTTON - Dark Blue BG with White Text */
.btn-secondary {
  background-color: var(--dark-blue);
  color: var(--btn-text-light);
  font-weight: 600;
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--btn-secondary-hover); /* Darker orange */
  color: var(--btn-text-light); /* Keep white text for contrast */
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(213, 85, 8, 0.3);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 27, 61, 0.25);
}

/* SUCCESS BUTTON - Green */
.btn-success {
  background-color: var(--btn-success);
  color: var(--btn-text-light);
  font-weight: 600;
}

.btn-success:hover:not(:disabled) {
  background-color: var(--btn-success-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25, 135, 84, 0.25);
}

.btn-success:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(25, 135, 84, 0.25);
}

/* DANGER BUTTON - Darker Orange for contrast */
.btn-danger {
  background-color: var(--btn-danger);
  color: var(--btn-text-light);
  font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--btn-danger-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(181, 71, 8, 0.3);
}

.btn-danger:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(181, 71, 8, 0.3);
}

/* WHITE BUTTON - For Dark Backgrounds */
.btn-white {
  background-color: var(--btn-white);
  color: var(--btn-text-dark); /* Very dark text for contrast */
  border: 1px solid #d0d0d0; /* Visible border */
  font-weight: 600;
}

.btn-white:hover:not(:disabled) {
  background-color: #f5f5f5;
  color: var(--btn-text-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #b0b0b0;
}

.btn-white:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/**
 * =====================================================
 * MOBILE MENU BUTTON FIX
 * =====================================================
 */

/* Fix for Mobile Menu Estimate Button */
.mobile-menu .btn-secondary {
  background-color: #b5a881; /* Use the tan color like primary buttons */
  color: #1a1a1a !important; /* Dark text for contrast */
  font-weight: 600;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 20px;
  border: 2px solid #1a1a1a;
  transition: all 0.3s ease;
}

.mobile-menu .btn-secondary:hover {
  background-color: #9a8d6f; /* Slightly darker tan on hover */
  color: #1a1a1a !important; /* Keep dark text */
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(181, 168, 129, 0.25);
}

.mobile-menu .btn-secondary:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(181, 168, 129, 0.25);
}

/* Ensure proper focus state for accessibility */
.mobile-menu .btn-secondary:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

/* Fix any potential text alignment issues */
.mobile-menu-content .mobile-nav-item:last-child {
  margin-top: 20px;
  padding: 0 20px;
}

.mobile-menu-content .mobile-nav-item .btn {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/**
 * =====================================================
 * BUTTON SIZES
 * =====================================================
 */

/* Small Button */
.btn-sm {
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 4px;
}

/* Large Button */
.btn-lg {
  padding: 14px 28px;
  font-size: 18px;
  border-radius: 8px;
}

/* Full Width Button */
.btn-block {
  display: flex;
  width: 100%;
}

/* Icon Only Button */
.btn-icon {
  padding: 8px;
  min-width: 40px;
  gap: 0;
}

/**
 * =====================================================
 * SPECIAL BUTTONS
 * =====================================================
 */

/* Emergency Button Override - IMPROVED CONTRAST */
.emergency-btn.btn-primary {
  background: #2d3e50 !important; /* Dark background */
  color: var(--white) !important; /* White text for contrast */
  border-color: #2d3e50 !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.emergency-btn.btn-primary:hover {
  background: #1a252f !important; /* Even darker on hover */
  color: var(--white) !important;
  border-color: #1a252f !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Loading State */
.btn.is-loading {
  color: transparent;
  pointer-events: none;
  position: relative;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-top-color: transparent;
  animation: button-spin 0.8s linear infinite;
}

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

/**
 * =====================================================
 * FLOATING PHONE BUTTON
 * =====================================================
 */
.floating-phone {
  position: fixed;
  top: 100px;
  right: 20px;
  z-index: 999;
  animation: slideInRight 0.8s ease-out, subtle-bounce 3s infinite 0.8s;
}

.floating-phone-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background-color: var(--btn-primary); /* Original tan color */
  color: var(--btn-text-dark); /* Black text for contrast */
  border: 2px solid #000000;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 700; /* Bolder for readability */
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 0 #000000,
    0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Remove pseudo elements */
.floating-phone-link::before {
  display: none !important;
}

/* Bottom edge effect */
.floating-phone-link::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 3px;
  background: #000000;
  border-radius: 50%;
  opacity: 0.3;
  transition: all 0.3s ease;
  display: block !important;
}

/* Hover */
.floating-phone-link:hover {
  background-color: var(--btn-primary-hover); /* Slightly darker tan */
  color: var(--btn-text-dark) !important; /* Keep black text */
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 0 #000000,
    0 6px 12px rgba(0, 0, 0, 0.25);
}

.floating-phone-link:hover::after {
  bottom: -4px;
  width: 85%;
  opacity: 0.25;
}

/* Active */
.floating-phone-link:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 0 #000000,
    0 2px 4px rgba(0, 0, 0, 0.15);
}

.floating-phone-link:active::after {
  bottom: -2px;
  width: 75%;
  opacity: 0.4;
}

/* Focus - High contrast */
.floating-phone-link:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

/* Icon */
.floating-phone-link i {
  font-size: 18px;
}

/**
 * =====================================================
 * FLOATING FINANCING BUTTON
 * =====================================================
 */
.floating-financing {
  position: fixed;
  top: 100px;
  left: 20px;
  z-index: 999;
  animation: slideInLeft 0.8s ease-out;
}

.floating-financing-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-primary); /* Original tan color */
  color: var(--btn-text-dark) !important; /* Black text for contrast */
  padding: 12px 20px;
  border: 2px solid #000000;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 700; /* Bolder for readability */
  font-size: 16px;
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 0 #000000,
    0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Bottom edge */
.floating-financing-link::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 3px;
  background: #000000;
  border-radius: 50%;
  opacity: 0.3;
  transition: all 0.3s ease;
}

/* Red badge */
.floating-financing-link::before {
  content: 'See Financing Options';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #cc0000; /* Darker red for contrast */
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: pulseShowHide 20s ease-in-out 3;
}

/* Hover */
.floating-financing-link:hover {
  background: var(--btn-primary-hover); /* Slightly darker tan */
  color: var(--btn-text-dark) !important; /* Keep black text */
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 0 #000000,
    0 6px 12px rgba(0, 0, 0, 0.25);
}

.floating-financing-link:hover::after {
  bottom: -4px;
  width: 85%;
  opacity: 0.25;
}

/* Active */
.floating-financing-link:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 0 #000000,
    0 2px 4px rgba(0, 0, 0, 0.15);
}

.floating-financing-link:active::after {
  bottom: -2px;
  width: 75%;
  opacity: 0.4;
}

/* Focus - High contrast */
.floating-financing-link:focus {
  outline: 3px solid #0066cc;
  outline-offset: 2px;
}

/* Icon */
.floating-financing-link i {
  font-size: 18px;
}

/* Arrow icon animation */
.arrow-icon {
  transition: transform 0.3s ease;
}

.floating-financing-link:hover .arrow-icon {
  transform: translateX(3px);
}

/**
 * =====================================================
 * ANIMATIONS
 * =====================================================
 */

/* Slide in from right */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Subtle bounce */
@keyframes subtle-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* Pulse show/hide for badge */
@keyframes pulseShowHide {
  0%,
  45% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0;
    transform: scale(0.8);
  }
  55%,
  95% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/**
 * =====================================================
 * MOBILE RESPONSIVE STYLES
 * =====================================================
 */

/* Tablet (1020px) */
@media (max-width: 1020px) {
  .floating-phone {
    top: 90px;
    right: 15px;
  }

  .floating-phone-link,
  .floating-financing-link {
    padding: 10px 16px;
    font-size: 14px;
  }

  .floating-phone-link i,
  .floating-financing-link i {
    font-size: 16px;
  }

  .floating-financing {
    top: 90px;
    left: 15px;
  }
}

/* Mobile (768px) */
@media (max-width: 768px) {
  /* General button styles */
  .btn {
    padding: 12px 24px;
    font-size: 16px;
  }

  .btn-sm {
    padding: 8px 16px;
    font-size: 14px;
  }

  .btn-lg {
    padding: 16px 32px;
    font-size: 18px;
  }

  /* Remove hover effects on mobile */
  .btn:hover {
    transform: none;
    box-shadow: none;
  }

  /* Touch feedback */
  .btn:active:not(:disabled) {
    opacity: 0.9;
    transform: scale(0.98);
  }

  /* Floating buttons */
  .floating-phone {
    animation: none;
    max-width: calc(100% - 20px);
  }

  .floating-phone-link,
  .floating-financing-link {
    padding: 8px 14px;
    font-size: 13px;
    gap: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 0 #000000,
      0 3px 6px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* Remove hover on mobile */
  .floating-phone-link:hover {
    transform: none;
    background-color: var(--btn-primary);
  }

  /* Touch feedback */
  .floating-phone-link:active,
  .floating-financing-link:active {
    opacity: 0.9;
    transform: scale(0.98);
  }

  .floating-phone-link i,
  .floating-financing-link i {
    font-size: 14px;
  }

  /* CTA section */
  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }
}

/* Small Mobile (480px) */
@media (max-width: 480px) {
  /* Floating buttons */
  .floating-phone {
    top: 90px;
    right: 10px;
    max-width: calc(100% - 10px);
  }

  .floating-financing {
    left: 10px;
  }

  .floating-phone-link,
  .floating-financing-link {
    padding: 8px 12px;
    font-size: 12px;
    max-width: 100%;
  }

  /* General buttons */
  .btn {
    max-width: 100%;
    box-sizing: border-box;
  }

  .btn-large {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/**
 * =====================================================
 * CARD-SPECIFIC BUTTON FIXES
 * =====================================================
 */

/* Center buttons in service card backs */
.service-card .card-back .btn,
.skylight-benefit-card .card-back .btn {
  margin: 0 auto;
  display: inline-flex;
}

/* Ensure proper button sizing in cards */
.btn-small {
  padding: 8px 16px;
  font-size: 14px;
}

/**
 * =====================================================
 * ACCESSIBILITY ENHANCEMENTS
 * =====================================================
 */

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000000;
  color: #ffffff;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }

  .btn:focus {
    outline-width: 4px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .floating-phone,
  .floating-financing,
  .floating-phone-link,
  .floating-financing-link {
    transition: none;
    animation: none;
  }

  .btn:hover,
  .btn:active {
    transform: none;
  }
}
