/* Theme Variable Definitions - These will be overridden by theme CSS variables */
:root {
  --mm-border-color: #e1e5e9;
  --mm-background-color: #ffffff;
  --mm-primary-color: #0073aa;
  --mm-text-color: #2c3e50;
  --mm-success-color: #27ae60;
  --mm-success-background: rgba(39, 174, 96, 0.1);
  --mm-active-background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
}

/* Theme Integration Examples:
   To customize colors, add this to your theme's CSS:
   
   :root {
     --mm-primary-color: #your-brand-color;
     --mm-background-color: #your-background;
     --mm-text-color: #your-text-color;
     --mm-border-color: #your-border-color;
   }
   
   Or for specific themes:
   .woocommerce { --mm-primary-color: #your-color; }
   .single-product { --mm-primary-color: #your-color; }
*/

.mm-variation-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin: 15px 0;
  max-width: 100%;
  position: relative;
}

.mm-variation-boxes.loading {
  opacity: 0.7;
  pointer-events: none;
}

.mm-variation-boxes.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #0073aa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.mm-variation-box {
  border: 2px solid var(--mm-border-color, #e1e5e9);
  padding: 16px 12px;
  border-radius: 12px;
  cursor: pointer;
  flex: 1 0 140px;
  min-width: 120px;
  text-align: center;
  transition: all 0.3s ease;
  background: var(--mm-background-color, #ffffff);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  position: relative;
  overflow: hidden;
}

.mm-variation-box:hover {
  border-color: var(--mm-primary-color, #0073aa);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,115,170,0.15);
}

.mm-variation-box.active {
  border-color: var(--mm-primary-color, #0073aa);
  background: var(--mm-active-background, linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,115,170,0.2);
}

.mm-variation-box.active::before {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--mm-primary-color, #0073aa);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.mm-label {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--mm-text-color, #2c3e50);
  line-height: 1.3;
}

.mm-price {
  font-size: 15px;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--mm-primary-color, #0073aa);
}

.mm-price .woocommerce-Price-amount {
  font-weight: 600;
}

.mm-save {
  font-size: 12px;
  color: var(--mm-success-color, #27ae60);
  font-weight: 500;
  background: var(--mm-success-background, rgba(39, 174, 96, 0.1));
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .mm-variation-boxes {
    gap: 10px;
    margin: 10px 0;
  }
  
  .mm-variation-box {
    flex: 1 0 calc(50% - 5px);
    min-width: 100px;
    padding: 12px 8px;
  }
  
  .mm-label {
    font-size: 14px;
  }
  
  .mm-price {
    font-size: 13px;
  }
  
  .mm-save {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .mm-variation-box {
    flex: 1 0 100%;
    margin-bottom: 8px;
  }
}

/* Theme Compatibility */
.woocommerce .mm-variation-boxes {
  margin: 20px 0;
}

/* Ensure compatibility with various themes */
.single-product .mm-variation-boxes {
  clear: both;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .mm-variation-box {
    background: #2c3e50;
    border-color: #34495e;
    color: #ecf0f1;
  }
  
  .mm-label {
    color: #ecf0f1;
  }
  
  .mm-variation-box:hover {
    border-color: #3498db;
  }
  
  .mm-variation-box.active {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    border-color: #3498db;
  }
}

/* Style Variations */
.mm-style-minimal .mm-variation-box {
  border: 1px solid var(--border-color-light, #ddd);
  background: var(--background-light, #fafafa);
  box-shadow: none;
}

.mm-style-minimal .mm-variation-box:hover {
  background: var(--background-hover, #f0f0f0);
  transform: none;
  box-shadow: none;
}

.mm-style-minimal .mm-variation-box.active {
  background: var(--active-background-light, #e8f4fd);
  border-color: var(--primary-color, #0073aa);
  transform: none;
  box-shadow: none;
}

.mm-style-bold .mm-variation-box {
  border: 3px solid var(--text-color-dark, #333);
  background: var(--background-color, #fff);
  font-weight: bold;
}

.mm-style-bold .mm-variation-box:hover {
  border-color: var(--primary-color, #0073aa);
  background: var(--background-hover, #f0f8ff);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,115,170,0.3);
}

.mm-style-bold .mm-variation-box.active {
  border-color: var(--primary-color, #0073aa);
  background: var(--primary-gradient, linear-gradient(135deg, #0073aa 0%, #005a87 100%));
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,115,170,0.4);
}

.mm-style-bold .mm-variation-box.active .mm-label,
.mm-style-bold .mm-variation-box.active .mm-price {
  color: white;
}

/* Hide the original dropdowns so only boxes show */
.variations select,
.mm-fallback {
  display: none !important;
}

/* Hide specific price elements that are redundant */
.mm-variation-box .woocommerce-Price-amount[aria-hidden="true"] {
  display: none !important;
}

/* Billing period styling */
.mm-billing-period {
  font-size: 0.9em;
  color: #666;
  font-weight: normal;
  margin-left: 2px;
}

/* Per month styling */
.mm-per-month {
  font-size: 0.8em;
  color: #666;
  font-weight: normal;
  margin-top: 2px;
}

/* Duration styling */
.mm-duration {
  font-size: 0.8em;
  color: #888;
  font-weight: normal;
  margin-top: 2px;
  font-style: italic;
}

/* Total duration styling for WooCommerce price display */
.mm-total-duration {
  font-size: 0.9em;
  color: #666;
  font-weight: normal;
  margin-left: 5px;
  font-style: italic;
}

/* Out of stock styling */
.mm-variation-box.out-of-stock {
  opacity: 0.6;
  cursor: not-allowed;
  position: relative;
}

.mm-variation-box.out-of-stock:hover {
  border-color: #e1e5e9 !important;
  background: #ffffff !important;
  transform: none !important;
}

.mm-variation-box.out-of-stock::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
}

.mm-stock-status {
  color: #d63638;
  font-size: 0.85em;
  font-weight: 600;
  text-align: center;
  margin-top: 5px;
  padding: 2px 5px;
  background: rgba(214, 54, 56, 0.1);
  border-radius: 3px;
}
