/*
    File: variant-modal.css
    Purpose: Styles for dual-variant product selection modal
    Contains: Modal layout, variant selectors, stock display
*/

/* ========================================
   VARIANT MODAL - OVERLAY & CONTAINER
   ======================================== */

.variant-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.variant-modal.active {
  display: flex;
}

.variant-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
}

.variant-modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10001;
}

/* ========================================
   MODAL ANIMATIONS
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========================================
   MODAL CLOSE BUTTON
   ======================================== */

.variant-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f5f5f5;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10002;
}

.variant-modal-close:hover {
  background: #ff6b35;
  color: white;
  transform: rotate(90deg);
}

/* ========================================
   MODAL HEADER
   ======================================== */

.variant-modal-header {
  padding: 30px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  gap: 20px;
  align-items: center;
}

.variant-modal-product-image {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: 12px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.variant-modal-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.variant-modal-product-info h3 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
  line-height: 1.3;
}

.modal_product_brand {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  font-weight: 500;
}

.modal-product-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.modal-current-price {
  font-size: 26px;
  font-weight: 500;
  color: #ff6b35;
}

/* ========================================
   MODAL BODY
   ======================================== */

.variant-modal-body {
  padding: 30px;
}

.variant-selection-group {
  margin-bottom: 24px;
}

.variant-selection-group label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.variant-selection-group label .required {
  color: #ff6b35;
  font-weight: 700;
}

.variant-select {
  width: 100%;
  padding: 14px 16px;
  padding-right: 40px;
  font-size: 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  color: #1a1a1a;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
}

.variant-select:hover {
  border-color: #ff6b35;
  background-color: #fff;
}

.variant-select:focus {
  outline: none;
  border-color: #ff6b35;
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
  background-color: #fff;
}

.variant-select option {
  padding: 12px 16px;
  background-color: white;
  color: #1a1a1a;
  font-weight: 500;
  font-size: 15px;
}

.variant-help-text {
  font-size: 13px;
  color: #666;
  margin-top: 6px;
  font-style: italic;
}

/* ========================================
   STOCK INFO
   ======================================== */

.stock-info {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 2px solid #22c55e;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.stock-available {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.stock-available svg {
  color: #22c55e;
  flex-shrink: 0;
}

.stock-available span {
  font-size: 15px;
  font-weight: 600;
  color: #166534;
}

.stock-sku {
  font-size: 13px;
  color: #166534;
  font-weight: 500;
}

/* Out of stock variant */
.stock-info.out-of-stock {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #ef4444;
}

.stock-info.out-of-stock .stock-available svg {
  color: #ef4444;
}

.stock-info.out-of-stock .stock-available span {
  color: #991b1b;
}

/* ========================================
   QUANTITY SELECTOR
   ======================================== */

.quantity-selector {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  max-width: 180px;
}

.quantity-selector .qty-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quantity-selector .qty-btn:hover {
  background: #ff6b35;
  color: white;
  border-color: #ff6b35;
}

.quantity-selector .qty-input {
  width: 60px;
  height: 40px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  border-radius: 8px;
  background: white;
}

.quantity-selector .qty-input:focus {
  outline: none;
  border-color: #ff6b35;
}

/* Remove spinner arrows from number input */
.quantity-selector .qty-input::-webkit-outer-spin-button,
.quantity-selector .qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.quantity-selector .qty-input[type="number"] {
  -moz-appearance: textfield;
}

/* ========================================
   MODAL FOOTER
   ======================================== */

.variant-modal-footer {
  padding: 20px 30px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: #f8f9fa;
  border-radius: 0 0 16px 16px;
}

.btn-primary,
.btn-secondary {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #cccccc;
  box-shadow: none;
}

.btn-secondary {
  background: white;
  color: #666;
  border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
  border-color: #1a1a1a;
  color: #1a1a1a;
}

.btn-primary svg,
.btn-secondary svg {
  width: 20px;
  height: 20px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media screen and (max-width: 768px) {
  .variant-modal {
    padding: 10px;
    align-items: flex-end;
  }

  .variant-modal-content {
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
    animation: slideUpMobile 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes slideUpMobile {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .variant-modal-header {
    padding: 20px;
    flex-direction: column;
    text-align: center;
  }

  .variant-modal-product-image {
    width: 100px;
    height: 100px;
  }

  .variant-modal-product-info h3 {
    font-size: 18px;
  }

  .modal-current-price {
    font-size: 22px;
  }

  .variant-modal-body {
    padding: 20px;
  }

  .variant-modal-footer {
    padding: 15px 20px;
    flex-direction: column-reverse;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    justify-content: center;
  }
}

@media screen and (max-width: 480px) {
  .variant-modal-close {
    width: 36px;
    height: 36px;
    font-size: 24px;
    top: 12px;
    right: 12px;
  }

  .variant-select {
    font-size: 14px;
    padding: 12px 14px;
  }

  .quantity-selector {
    max-width: 100%;
  }

  .quantity-selector .qty-btn {
    flex: 1;
    max-width: 50px;
  }

  .quantity-selector .qty-input {
    flex: 1;
    max-width: 80px;
  }
}

/* ========================================
   LOADING STATE
   ======================================== */

.variant-select.loading {
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 107, 53, 0.1) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ========================================
   ERROR STATE
   ======================================== */

.variant-select.error {
  border-color: #ef4444;
  background-color: #fef2f2;
}

.error-message {
  color: #ef4444;
  font-size: 13px;
  margin-top: 6px;
  font-weight: 500;
}
