/**
 * OneStepOrder Addon - Stock Display Styling
 * Real-time inventory display with urgency indicators
 * 
 * @package    WHMCS OneStepOrder Addon
 * @version    1.0.0
 * @updated    2025-10-31
 */

/* Stock Display Container */
.stock-display-container {
  display: inline-block;
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.5;
}

/* Stock Item Base */
.stock-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.3s ease;
  animation: stockEnter 0.4s ease-out;
}

@keyframes stockEnter {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stock Available */
.stock-item.stock-available {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.stock-item.stock-available .stock-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: #28a745;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 20px;
  font-size: 12px;
  font-weight: bold;
}

/* Stock Low - Critical Warning */
.stock-item.stock-low {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
  border-left: 4px solid #ff9800;
}

.stock-item.stock-low .stock-warning {
  display: inline-block;
  width: 24px;
  height: 24px;
  background-color: #ff9800;
  color: white;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  font-size: 16px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

.stock-item.stock-low strong {
  font-size: 15px;
}

.stock-item.stock-low .stock-urgency {
  display: block;
  font-size: 12px;
  color: #856404;
  margin-left: auto;
  font-weight: normal;
}

/* Stock Out */
.stock-item.stock-out {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.stock-item.stock-out strong {
  text-decoration: line-through;
}

/* Stock Unavailable */
.stock-unavailable {
  color: #6c757d;
  font-style: italic;
  font-size: 13px;
}

/* Stock Level Badge */
.stock-level-badge {
  display: inline-block;
  background-color: #007bff;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  margin-left: 4px;
}

.stock-level-badge.critical {
  background-color: #dc3545;
}

.stock-level-badge.warning {
  background-color: #ff9800;
}

.stock-level-badge.good {
  background-color: #28a745;
}

/* Stock Display in Product Card */
.product-card .stock-display-container {
  margin-top: 10px;
}

.product-card .stock-item {
  padding: 6px 10px;
  font-size: 13px;
}

/* Stock Display in Checkout */
.checkout-product .stock-display-container {
  margin-top: 5px;
  font-size: 12px;
}

.checkout-product .stock-item {
  padding: 4px 8px;
}

/* Stock Display in Cart Items */
.cart-item .stock-display-container {
  margin-top: 8px;
}

/* Stock Display Progress Bar */
.stock-progress {
  display: block;
  height: 6px;
  background-color: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.stock-progress-bar {
  height: 100%;
  background-color: #28a745;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.stock-progress-bar.warning {
  background-color: #ff9800;
}

.stock-progress-bar.critical {
  background-color: #dc3545;
}

/* Stock Counter Animation */
.stock-counter-update {
  animation: counterUpdate 0.6s ease-out;
}

@keyframes counterUpdate {
  0% {
    background-color: #fff3cd;
    transform: scale(1.05);
  }
  50% {
    transform: scale(1);
  }
  100% {
    background-color: transparent;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .stock-item.stock-available {
    background-color: rgba(40, 167, 69, 0.15);
    color: #66bb6a;
    border-color: rgba(40, 167, 69, 0.3);
  }

  .stock-item.stock-low {
    background-color: rgba(255, 152, 0, 0.15);
    color: #ffb74d;
    border-color: rgba(255, 152, 0, 0.3);
  }

  .stock-item.stock-out {
    background-color: rgba(220, 53, 69, 0.15);
    color: #ef5350;
    border-color: rgba(220, 53, 69, 0.3);
  }

  .stock-progress {
    background-color: #2c3e50;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .stock-item {
    padding: 6px 10px;
    font-size: 13px;
    gap: 6px;
  }

  .stock-item.stock-low .stock-urgency {
    display: none;
  }

  .stock-item.stock-available .stock-icon {
    width: 18px;
    height: 18px;
    line-height: 18px;
    font-size: 11px;
  }

  .stock-item.stock-low .stock-warning {
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .stock-item {
    padding: 5px 8px;
    font-size: 12px;
    gap: 5px;
  }

  .stock-item strong {
    font-size: 13px;
  }

  .stock-level-badge {
    font-size: 11px;
    padding: 3px 6px;
  }
}

/* Accessibility */
.stock-item[role="status"] {
  contain: layout style;
}

.stock-warning[aria-label],
.stock-icon[aria-label] {
  position: relative;
}

/* Print Styles */
@media print {
  .stock-item.stock-low .stock-warning {
    animation: none;
  }

  .stock-item.stock-out strong {
    text-decoration: none;
    font-weight: bold;
  }
}
