/**
 * @file
 * Styles for cart quantity controls with plus/minus buttons.
 */

.quantity-control-wrapper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background-color: #ffffff;
  overflow: hidden;
  max-width: 120px;
}

.quantity-control-wrapper.loading {
  opacity: 0.6;
  pointer-events: none;
}

.quantity-control-wrapper.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.quantity-btn {
  background-color: #f3f4f6;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  user-select: none;
}

.quantity-btn:hover {
  background-color: #e5e7eb;
  color: #1f2937;
}

.quantity-btn:active {
  background-color: #d1d5db;
  transform: scale(0.95);
}

.quantity-btn:disabled {
  background-color: #f9fafb;
  color: #9ca3af;
  cursor: not-allowed;
}

.quantity-btn:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.quantity-edit-input,
.quantity-control-wrapper input[type="number"] {
  border: none !important;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  width: 56px;
  height: 32px;
  background-color: #ffffff !important;
  outline: none;
  color: #111827 !important;
  padding: 0;
  -moz-appearance: textfield !important; /* Firefox */
  -webkit-appearance: none !important;
  appearance: none !important;
}

.quantity-edit-input::-webkit-outer-spin-button,
.quantity-edit-input::-webkit-inner-spin-button,
.quantity-control-wrapper input[type="number"]::-webkit-outer-spin-button,
.quantity-control-wrapper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  margin: 0;
  display: none !important;
}

.quantity-edit-input:focus,
.quantity-control-wrapper input[type="number"]:focus {
  outline: none;
  background-color: #ffffff !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .quantity-control-wrapper {
    max-width: 100px;
  }
  
  .quantity-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
  
  .quantity-edit-input {
    width: 44px;
    height: 28px;
    font-size: 13px;
  }
}

/* Cart form table specific styles */
.cart-form-table .quantity-control-wrapper {
  justify-self: center;
}

.cart-form-table td.views-field-edit-quantity {
  text-align: left;
  vertical-align: middle;
}

.cart-form-table .add-comment-link {
  margin-left: 0px;
}

/* Loading state for the entire row */
.cart-form-table tr.quantity-updating {
  opacity: 0.7;
  pointer-events: none;
}

.cart-form-table tr.quantity-updating .quantity-control-wrapper {
  position: relative;
}

/* Success/error messaging */
.quantity-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 0.375rem;
  color: white;
  font-weight: 500;
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.quantity-message.show {
  transform: translateX(0);
}

.quantity-message.success {
  background-color: #10b981;
}

.quantity-message.error {
  background-color: #ef4444;
}

/* Hide label inside and around quantity control wrapper */
.quantity-control-wrapper label,
.quantity-control-wrapper .form-element-label,
.quantity-wrapper label,
.quantity-wrapper .form-element-label,
.quantity-wrapper .js-form-item label,
.quantity-wrapper .form-item label {
  display: none !important;
}

/* Hide ONLY the label for quantity fields - NOT the field itself */
.quantity-wrapper label[for*="quantity"],
.quantity-wrapper label[for*="edit-quantity"],
label[for*="edit-quantity-0-value"] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  position: absolute !important;
  left: -9999px !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .quantity-control-wrapper {
    border-color: #4b5563;
    background-color: #1f2937;
  }

  .quantity-btn {
    background-color: #374151;
    color: #e5e7eb;
  }

  .quantity-btn:hover {
    background-color: #4b5563;
    color: #f9fafb;
  }

  .quantity-edit-input {
    color: #e5e7eb;
  }

  .quantity-edit-input:focus {
    background-color: #374151;
  }
} 
