/**
 * Modern PriceRunner Widget Styles
 * Mobile-first responsive design with accessibility features
 */

/* CSS Custom Properties */
:root {
  /* Brand Colors */
  --coffee-primary: #6B4423;
  --coffee-secondary: #8B5E3C;
  --coffee-light: #EFE0BF;
  --coffee-accent: #D4A574;
  
  /* Semantic Colors */
  --surface-primary: #ffffff;
  --surface-secondary: #f8f9fa;
  --surface-elevated: #ffffff;
  --border-primary: #e1e5e9;
  --border-secondary: #dee2e6;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #8e9297;
  
  /* Interactive Colors */
  --interactive-primary: var(--coffee-primary);
  --interactive-primary-hover: var(--coffee-secondary);
  --interactive-primary-active: #5a3319;
  --focus-ring: #0066cc;
  
  /* Status Colors */
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  
  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Typography */
  --font-family-base: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --line-height-tight: 1.2;
  --line-height-base: 1.5;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

/* Demo Page Styles */
.demo-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
  font-family: var(--font-family-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
}

.demo-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 2px solid var(--border-primary);
}

.demo-header h1 {
  font-size: 2.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--coffee-primary);
  margin-bottom: var(--space-sm);
}

.demo-header p {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  margin: 0;
}

.product-showcase {
  margin-bottom: var(--space-2xl);
  padding: var(--space-xl);
  background: var(--surface-secondary);
  border-radius: var(--radius-lg);
}

.product-showcase h2 {
  font-size: 1.875rem;
  font-weight: var(--font-weight-semibold);
  color: var(--coffee-primary);
  margin-bottom: var(--space-sm);
}

.product-showcase p {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.demo-footer {
  text-align: center;
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-secondary);
  color: var(--text-muted);
}

/* Widget Styles */
.bk-pricerunner-wrapper {
  font-family: var(--font-family-base);
  max-width: 100%;
  margin: 0 auto;
}

.bk-widget-container {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Tab Selector */
.bk-variant-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
  padding: var(--space-md);
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--border-primary);
  list-style: none;
}

.bk-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* Minimum touch target size */
  padding: var(--space-sm) var(--space-lg);
  background: transparent;
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-right: var(--space-sm);
  margin-bottom: var(--space-sm);
  outline: none;
}

.bk-tab:last-child {
  margin-right: 0;
}

.bk-tab-text {
  position: relative;
  z-index: 2;
}

.bk-tab-indicator {
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 3px;
  background: #8B5E3C; /* Bright blue for better contrast */
  border-radius: var(--radius-sm);
  transform: translateX(-50%);
  transition: width var(--transition-base);
}

/* Tab States */
.bk-tab:hover {
  background: var(--coffee-light);
  border-color: var(--interactive-primary-hover);
  transform: translateY(-1px);
}

.bk-tab:focus-visible {
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
  border-color: var(--focus-ring);
}

.bk-tab:active {
  transform: translateY(0);
}

.bk-tab.active {
  background: var(--interactive-primary);
  border-color: var(--interactive-primary);
  color: white;
  font-weight: var(--font-weight-semibold);
}

.bk-tab.active .bk-tab-indicator {
  width: 100%;
}

.bk-tab.active:hover {
  background: var(--interactive-primary-hover);
  border-color: var(--interactive-primary-hover);
  transform: none;
}

/* Panels Container */
.bk-panels-container {
  position: relative;
  min-height: 400px;
}

.bk-widget-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
  pointer-events: none;
}

.bk-widget-panel.active {
  position: static;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.bk-widget-content {
  padding: var(--space-lg);
}

/* Loading States */
.bk-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
}

.bk-loading-state[aria-hidden="true"] {
  display: none;
}

.bk-skeleton {
  width: 100%;
  max-width: 400px;
  height: 120px;
  background: linear-gradient(90deg, 
    var(--surface-secondary) 25%, 
    var(--border-primary) 50%, 
    var(--surface-secondary) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-md);
  animation: skeleton-loading 1.5s infinite;
  margin-bottom: var(--space-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.bk-loading-text {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}

/* Widget Embed */
.bk-widget-embed {
  min-height: 200px;
  border-radius: var(--radius-md);
  background: var(--surface-primary);
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.bk-widget-embed.loaded {
  opacity: 1;
}

/* Attribution */
.bk-attribution {
  margin-top: var(--space-lg);
  text-align: center;
}

.bk-attribution a {
  display: inline-block;
  color: var(--coffee-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-style: italic;
  transition: color var(--transition-fast);
}

.bk-attribution a:hover {
  color: var(--coffee-secondary);
  text-decoration: underline;
}

.bk-attribution strong {
  font-weight: var(--font-weight-semibold);
}

/* Error States */
.bk-error,
.bk-widget-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: var(--space-lg);
  background: rgb(239 68 68 / 0.1);
  border: 1px solid rgb(239 68 68 / 0.2);
  border-radius: var(--radius-md);
  text-align: center;
}

.bk-error-icon {
  font-size: 1.5rem;
  margin-right: var(--space-sm);
}

.bk-error-message {
  color: var(--error);
  font-weight: var(--font-weight-medium);
}

/* Responsive Design */
@media (max-width: 640px) {
  .demo-container {
    padding: var(--space-md);
  }
  
  .demo-header h1 {
    font-size: 2rem;
  }
  
  .product-showcase {
    padding: var(--space-md);
  }
  
  .product-showcase h2 {
    font-size: 1.5rem;
  }
  
  .bk-variant-selector {
    padding: var(--space-sm);
  }
  
  .bk-tab {
    flex: 1;
    min-width: 0;
    margin-right: var(--space-xs);
    padding: var(--space-sm);
    font-size: var(--font-size-sm);
  }
  
  .bk-widget-content {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  .bk-variant-selector {
    flex-direction: column;
  }
  
  .bk-tab {
    width: 100%;
    margin-right: 0;
    margin-bottom: var(--space-xs);
  }
  
  .bk-tab:last-child {
    margin-bottom: 0;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --border-primary: #666666;
    --border-secondary: #999999;
  }
  
  .bk-tab {
    border-width: 2px;
  }
  
  .bk-tab:focus-visible {
    outline: 3px solid;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .bk-tab,
  .bk-widget-panel,
  .bk-tab-indicator {
    transition: none;
  }
  
  .bk-skeleton {
    animation: none;
    background: var(--surface-secondary);
  }
}

/* Print Styles */
@media print {
  .bk-pricerunner-wrapper {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .bk-variant-selector {
    display: none;
  }
  
  .bk-widget-panel {
    display: block !important;
    position: static !important;
    opacity: 1 !important;
    transform: none !important;
  }
  
  .bk-attribution a {
    color: #000 !important;
  }
}

/* Increase specificity to override Elementor */
.elementor-kit-46 .bk-pricerunner-wrapper .bk-tab,
.bk-pricerunner-wrapper .bk-tab {
  /* Reset Elementor styles */
  background-color: transparent !important;
  border: 2px solid #e1e5e9 !important;
  color: #212529 !important;
  
  /* Ensure your styles take precedence */
  font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  transition: all 200ms ease;
}

/* Hover state - override Elementor */
.elementor-kit-46 .bk-pricerunner-wrapper .bk-tab:hover,
.bk-pricerunner-wrapper .bk-tab:hover {
  background-color: #EFE0BF !important;
  border-color: #8B5E3C !important;
  color: #212529 !important;
  transform: translateY(-1px);
}

/* Active/Selected state - override Elementor */
.elementor-kit-46 .bk-pricerunner-wrapper .bk-tab.active,
.bk-pricerunner-wrapper .bk-tab.active {
  background-color: #6B4423 !important;
  border-color: #6B4423 !important;
  color: #ffffff !important;
  font-weight: 600;
}

/* Focus state - override Elementor */
.elementor-kit-46 .bk-pricerunner-wrapper .bk-tab:focus-visible,
.bk-pricerunner-wrapper .bk-tab:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3) !important;
  border-color: #0066cc !important;
}

/* Make sure the indicator works correctly */
.bk-pricerunner-wrapper .bk-tab-indicator {
  background: #8B5E3C !important;
}

/* Optional: If you want to completely isolate the widget from Elementor styles */
.bk-pricerunner-wrapper {
  /* Create a new stacking context */
  position: relative;
  z-index: 1;
  
  /* Reset any inherited Elementor styles */
  all: initial;
  font-family: 'Quicksand', sans-serif;
}