/* Custom Addon Form Styles */
:root {
  --addon-primary: #0F172A;
  --addon-primary-light: #1E293B;
  --addon-accent: #3B82F6;
  --addon-accent-hover: #2563EB;
  --addon-success: #10B981;
  --addon-border: #E2E8F0;
  --addon-bg: #F8FAFC;
  --addon-text: #334155;
  --addon-text-muted: #64748B;
  --addon-shadow: 0 1px 3px rgba(0,0,0,0.1);
  --addon-shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

.custom-addon-wrapper {
  margin-bottom: 30px !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Accordion Styles */
.custom-addon-wrapper .accordion {
  background: white;
  border-radius: 12px;
  box-shadow: var(--addon-shadow-lg);
  overflow: hidden;
  border: 1px solid var(--addon-border);
}

.custom-addon-wrapper .accordion-section {
  border-bottom: 1px solid var(--addon-border);
  transition: all 0.3s ease;
}

.custom-addon-wrapper .accordion-section:last-child {
  border-bottom: none;
}

.custom-addon-wrapper .accordion-section.completed {
  background: linear-gradient(to right, #F0FDF4 0%, white 100%);
}

.custom-addon-wrapper .section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.custom-addon-wrapper .section-header:hover {
  background: var(--addon-bg);
}

.custom-addon-wrapper .section-header:active {
  background: #E2E8F0;
}

.custom-addon-wrapper .section-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--addon-bg);
  border: 2px solid var(--addon-border);
  transition: all 0.3s ease;
}

.custom-addon-wrapper .accordion-section.active .section-icon {
  background: var(--addon-accent);
  border-color: var(--addon-accent);
  color: white;
}

.custom-addon-wrapper .accordion-section.completed .section-icon {
  background: var(--addon-success);
  border-color: var(--addon-success);
  color: white;
}

.custom-addon-wrapper .section-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.5;
}

.custom-addon-wrapper .section-info {
  flex: 1;
}

.custom-addon-wrapper .section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--addon-primary);
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}

.custom-addon-wrapper .section-status {
  font-size: 13px;
  color: var(--addon-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-addon-wrapper .status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.custom-addon-wrapper .status-badge.required {
  background: #FEF2F2;
  color: #DC2626;
}

.custom-addon-wrapper .status-badge.complete {
  background: #F0FDF4;
  color: #16A34A;
}

.custom-addon-wrapper .section-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--addon-bg);
  border: 1px solid var(--addon-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.custom-addon-wrapper .section-toggle:active {
  transform: scale(0.95);
}

.custom-addon-wrapper .section-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

.custom-addon-wrapper .accordion-section.active .section-toggle svg {
  transform: rotate(180deg);
}

.custom-addon-wrapper .section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.custom-addon-wrapper .accordion-section.active .section-content {
  max-height: 3000px;
}

.custom-addon-wrapper .section-inner {
  padding: 0 24px 28px 24px;
}

/* Form Fields */
.custom-addon-wrapper .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.custom-addon-wrapper .form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-addon-wrapper .form-field.full-width {
  grid-column: 1 / -1;
}

.custom-addon-wrapper .form-label {
  font-weight: 500;
  color: var(--addon-primary);
  font-size: 14px;
  margin: 0;
}

.custom-addon-wrapper .form-label .required {
  color: #DC2626;
  margin-left: 2px;
}

.custom-addon-wrapper .form-input {
  padding: 11px 14px;
  border: 2px solid var(--addon-border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--addon-primary);
  transition: all 0.2s ease;
  background: white;
  font-family: inherit;
}

.custom-addon-wrapper .form-input:hover {
  border-color: #CBD5E1;
}

.custom-addon-wrapper .form-input:focus {
  outline: none;
  border-color: var(--addon-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-addon-wrapper .form-input::placeholder {
  color: var(--addon-text-muted);
}

/* Select dropdown styling */
.custom-addon-wrapper select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748B' 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 10px center;
  background-size: 18px;
  padding-right: 38px;
  cursor: pointer;
}

/* Model input with prefix */
.custom-addon-wrapper .model-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.custom-addon-wrapper .model-prefix {
  position: absolute;
  left: 14px;
  font-weight: 600;
  color: var(--addon-accent);
  font-size: 15px;
  z-index: 1;
  pointer-events: none;
  user-select: none;
}

.custom-addon-wrapper .model-input {
  padding-left: 42px !important;
}

/* Upload Grid */
.custom-addon-wrapper .upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.custom-addon-wrapper .upload-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.custom-addon-wrapper .upload-preview {
  aspect-ratio: 4/3;
  border: 2px dashed var(--addon-border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--addon-bg);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.custom-addon-wrapper .upload-preview:hover {
  border-color: var(--addon-accent);
  background: #EFF6FF;
}

.custom-addon-wrapper .upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--addon-text-muted);
  text-align: center;
  padding: 16px;
}

.custom-addon-wrapper .upload-placeholder svg {
  width: 36px;
  height: 36px;
  opacity: 0.5;
}

.custom-addon-wrapper .upload-placeholder span {
  font-size: 13px;
  font-weight: 500;
}

.custom-addon-wrapper .upload-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-addon-wrapper .upload-input {
  display: none;
}

.custom-addon-wrapper .upload-button {
  padding: 9px 14px;
  border: 2px solid var(--addon-border);
  border-radius: 7px;
  background: white;
  color: var(--addon-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.custom-addon-wrapper .upload-button:hover {
  background: var(--addon-bg);
  border-color: var(--addon-accent);
  color: var(--addon-accent);
}

.custom-addon-wrapper .upload-button:active {
  transform: scale(0.98);
}

.custom-addon-wrapper .remove-button {
  padding: 7px 14px;
  border: none;
  border-radius: 7px;
  background: #FEE2E2;
  color: #DC2626;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.custom-addon-wrapper .remove-button:hover {
  background: #FEF2F2;
}

.custom-addon-wrapper .remove-button:active {
  transform: scale(0.98);
}

.custom-addon-wrapper .upload-item.has-image .upload-preview {
  border-style: solid;
  border-color: var(--addon-success);
  background: white;
}

/* Helper Text */
.custom-addon-wrapper .helper-text {
  background: #F8FAFC;
  border-left: 3px solid var(--addon-accent);
  padding: 14px;
  border-radius: 6px;
  margin-top: 18px;
}

.custom-addon-wrapper .helper-text p {
  font-size: 13px;
  color: var(--addon-text);
  margin: 0 0 6px 0;
  font-weight: 500;
}

.custom-addon-wrapper .helper-text ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.custom-addon-wrapper .helper-text li {
  font-size: 12px;
  color: var(--addon-text-muted);
  padding-left: 18px;
  position: relative;
  margin-bottom: 4px;
}

.custom-addon-wrapper .helper-text li:before {
  content: "•";
  position: absolute;
  left: 6px;
  color: var(--addon-accent);
  font-weight: bold;
}

/* Responsive */
@media (max-width: 768px) {
  .custom-addon-wrapper .section-header {
    padding: 16px 18px;
    gap: 12px;
  }
  
  .custom-addon-wrapper .section-icon {
    width: 38px;
    height: 38px;
  }
  
  .custom-addon-wrapper .section-icon svg {
    width: 18px;
    height: 18px;
  }
  
  .custom-addon-wrapper .section-title {
    font-size: 16px;
  }
  
  .custom-addon-wrapper .section-inner {
    padding: 0 18px 22px 18px;
  }
  
  .custom-addon-wrapper .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 16px;
  }
  
  .custom-addon-wrapper .form-input {
    padding: 11px 13px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .custom-addon-wrapper select.form-input {
    background-size: 16px;
    background-position: right 9px center;
    padding-right: 34px;
  }
  
  .custom-addon-wrapper .model-prefix {
    left: 13px;
    font-size: 16px;
  }
  
  .custom-addon-wrapper .model-input {
    padding-left: 38px !important;
  }
  
  .custom-addon-wrapper .upload-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  
  .custom-addon-wrapper .upload-preview {
    aspect-ratio: 16/9;
  }
  
  .custom-addon-wrapper .upload-button,
  .custom-addon-wrapper .remove-button {
    width: 100%;
    padding: 11px 14px;
    font-size: 14px;
  }
  
  .custom-addon-wrapper .helper-text {
    padding: 12px;
    margin-top: 14px;
  }
}

/* Product Search Popup */
.clipon-product-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.clipon-product-popup {
  background: white;
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.clipon-popup-header {
  padding: 24px;
  border-bottom: 1px solid var(--addon-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clipon-popup-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--addon-primary);
}

.clipon-popup-close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--addon-bg);
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--addon-text-muted);
  transition: all 0.2s;
}

.clipon-popup-close:hover {
  background: var(--addon-border);
  color: var(--addon-primary);
}

.clipon-popup-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.clipon-popup-message {
  margin: 0 0 20px 0;
  color: var(--addon-text);
  font-size: 15px;
}

.clipon-product-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.clipon-product-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  border: 2px solid var(--addon-border);
  border-radius: 8px;
  transition: all 0.2s;
}

.clipon-product-item:hover {
  border-color: var(--addon-accent);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.clipon-product-image {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--addon-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.clipon-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clipon-product-image .no-image {
  color: var(--addon-text-muted);
  font-size: 13px;
}

.clipon-product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clipon-product-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--addon-primary);
}

.clipon-product-price {
  font-size: 18px;
  font-weight: 600;
  color: var(--addon-accent);
}

.clipon-product-stock {
  font-size: 13px;
  font-weight: 500;
}

.clipon-product-stock.in-stock {
  color: var(--addon-success);
}

.clipon-product-stock.out-of-stock {
  color: #EF4444;
}

.clipon-product-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.clipon-btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  border: none;
  font-family: inherit;
}

.clipon-btn-primary {
  background: var(--addon-accent);
  color: white;
}

.clipon-btn-primary:hover {
  background: var(--addon-accent-hover);
}

.clipon-btn-secondary {
  background: white;
  color: var(--addon-accent);
  border: 2px solid var(--addon-accent);
}

.clipon-btn-secondary:hover {
  background: var(--addon-bg);
}

.clipon-btn-text {
  background: transparent;
  color: var(--addon-text-muted);
}

.clipon-btn-text:hover {
  color: var(--addon-primary);
  background: var(--addon-bg);
}

.clipon-popup-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--addon-border);
  text-align: center;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .clipon-product-item {
    flex-direction: column;
  }
  
  .clipon-product-image {
    width: 100%;
    height: 200px;
  }
  
  .clipon-product-actions {
    flex-direction: column;
  }
  
  .clipon-btn {
    width: 100%;
  }
}

/* Image Popup / Lightbox */
.clipon-image-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999999;
  padding: 20px;
  animation: fadeIn 0.2s ease;
  cursor: pointer;
}

.clipon-image-popup {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.clipon-image-popup img {
  max-width: 100%;
  max-height: 90vh;
  height: auto;
  display: block;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.clipon-image-popup-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #333;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.clipon-image-popup-close:hover {
  background: #f0f0f0;
  transform: scale(1.1);
}

@media (max-width: 640px) {
  .clipon-image-popup-close {
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
  }
}

/* Semi-Rimless Form Styles */
.custom-addon-semi-rimless {
  background: white;
  border-radius: 12px;
  box-shadow: var(--addon-shadow-lg);
  border: 1px solid var(--addon-border);
  overflow: hidden;
}

.custom-addon-semi-rimless .accordion-section {
  /* No border needed for single section */
  border: none;
}

.custom-addon-semi-rimless .accordion-section.completed {
  background: linear-gradient(to right, #F0FDF4 0%, white 100%);
}

.custom-addon-semi-rimless .section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default; /* Not clickable */
  pointer-events: none; /* Disable all interactions */
}

.custom-addon-semi-rimless .section-header:hover {
  background: transparent; /* No hover effect */
}

.custom-addon-semi-rimless .section-content {
  padding: 0 24px 24px 24px;
}

.custom-addon-semi-rimless .single-upload {
  display: flex;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

.custom-addon-semi-rimless .upload-item {
  width: 100%;
}

.custom-addon-semi-rimless .upload-preview {
  pointer-events: auto; /* Re-enable for the preview area */
}
