/* CSS Custom Properties for Customization */
:root {
  --opt-tryon-primary-color: #0073aa;
  --opt-tryon-secondary-color: #666666;
  --opt-tryon-background-color: #ffffff;
  --opt-tryon-border-radius: 4px;
  --opt-tryon-text-color: #333333;
  --opt-tryon-border-color: #ddd;
  --opt-tryon-hover-color: #005a87;
}

/* Try-on button */
.opt-tryon { margin: 10px 0; }
.opt-tryon-open { 
  background-color: var(--opt-tryon-primary-color) !important; 
  border-color: var(--opt-tryon-primary-color) !important; 
  color: white !important; 
  border-radius: var(--opt-tryon-border-radius) !important;
  transition: all 0.3s ease;
}
.opt-tryon-open:hover { 
  background-color: var(--opt-tryon-hover-color) !important; 
  border-color: var(--opt-tryon-hover-color) !important; 
}

/* Button style variations */
.opt-tryon-open.opt-tryon-primary {
    background-color: var(--opt-tryon-primary-color);
    color: var(--opt-tryon-text-color);
    border: 1px solid var(--opt-tryon-primary-color);
}

.opt-tryon-open.opt-tryon-primary:hover {
    background-color: var(--opt-tryon-hover-color);
    border-color: var(--opt-tryon-hover-color);
}

.opt-tryon-open.opt-tryon-outline {
    background-color: transparent;
    color: var(--opt-tryon-primary-color);
    border: 2px solid var(--opt-tryon-primary-color);
}

.opt-tryon-open.opt-tryon-outline:hover {
    background-color: var(--opt-tryon-primary-color);
    color: var(--opt-tryon-text-color);
}

.opt-tryon-open.opt-tryon-minimal {
    background-color: transparent;
    color: var(--opt-tryon-primary-color);
    border: none;
    text-decoration: underline;
    padding: 8px 0;
}

.opt-tryon-open.opt-tryon-minimal:hover {
    color: var(--opt-tryon-hover-color);
    background-color: transparent;
}
.opt-tryon-open.style-primary {
  background-color: var(--opt-tryon-primary-color) !important;
  border-color: var(--opt-tryon-primary-color) !important;
  color: white !important;
}

.opt-tryon-open.style-outline {
  background-color: transparent !important;
  border: 2px solid var(--opt-tryon-primary-color) !important;
  color: var(--opt-tryon-primary-color) !important;
}

.opt-tryon-open.style-outline:hover {
  background-color: var(--opt-tryon-primary-color) !important;
  color: white !important;
}

.opt-tryon-open.style-minimal {
  background-color: transparent !important;
  border: none !important;
  color: var(--opt-tryon-primary-color) !important;
  text-decoration: underline;
  padding: 8px 0 !important;
}

.opt-tryon-open.style-minimal:hover {
  color: var(--opt-tryon-hover-color) !important;
}

/* Modal */
.opt-tryon-modal { 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  z-index: 999999; 
  display: none; 
}
/* Show modal when aria-hidden is false */
.opt-tryon-modal[aria-hidden="false"] {
  display: block;
}
/* Lock body scroll when modal is open */
body.opt-tryon-modal-open {
  overflow: hidden;
}
.opt-tryon-backdrop { 
  position: absolute; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%; 
  background: rgba(0,0,0,0.5); 
}
.opt-tryon-dialog { 
  position: relative; 
  max-width: 500px; 
  margin: 50px auto; 
  background: var(--opt-tryon-background-color); 
  border-radius: var(--opt-tryon-border-radius); 
  box-shadow: 0 4px 20px rgba(0,0,0,0.15); 
  max-height: 90vh; 
  overflow-y: auto; 
}
.opt-tryon-close { 
  position: absolute; 
  top: 10px; 
  right: 15px; 
  background: none; 
  border: none; 
  font-size: 24px; 
  cursor: pointer; 
  color: var(--opt-tryon-secondary-color); 
  z-index: 1; 
}
.opt-tryon-close:hover { 
  color: var(--opt-tryon-text-color); 
}
.opt-tryon-body { 
  padding: 20px; 
}

/* Form elements */
.opt-tryon-file-label, .opt-tryon-camera-label { 
  display: block; 
  padding: 12px; 
  border: 2px dashed var(--opt-tryon-border-color); 
  border-radius: var(--opt-tryon-border-radius); 
  text-align: center; 
  cursor: pointer; 
  margin-bottom: 10px; 
  color: var(--opt-tryon-text-color);
  transition: border-color 0.3s ease;
}
.opt-tryon-file-label:hover, .opt-tryon-camera-label:hover { 
  border-color: var(--opt-tryon-primary-color); 
}
.opt-tryon-file-label input, .opt-tryon-camera-label input { 
  display: none; 
}
.opt-tryon-or { 
  text-align: center; 
  margin: 10px 0; 
  color: var(--opt-tryon-secondary-color); 
}

/* Actions */
.opt-tryon-actions { 
  display: flex; 
  gap: 10px; 
  margin-top: 16px; 
}
.opt-tryon-actions .button { 
  min-width: 200px; 
  border-radius: var(--opt-tryon-border-radius) !important;
}
.opt-tryon-actions .button-primary {
  background-color: var(--opt-tryon-primary-color) !important;
  border-color: var(--opt-tryon-primary-color) !important;
}
.opt-tryon-actions .button-primary:hover {
  background-color: var(--opt-tryon-hover-color) !important;
  border-color: var(--opt-tryon-hover-color) !important;
}

/* Camera area */
.opt-tryon-capture-controls { 
  display: none; 
}

/* Status and result */
.opt-tryon-status { 
  margin-top: 8px; 
  min-height: 20px; 
  font-size: 13px; 
  color: var(--opt-tryon-text-color); 
}
.opt-tryon-result { 
  margin-top: 14px; 
  text-align: center; 
}
.opt-tryon-result img { 
  max-width: 100%; 
  height: auto; 
  border-radius: var(--opt-tryon-border-radius); 
  border: 1px solid var(--opt-tryon-border-color); 
}

/* Loader block */
.opt-tryon-loading { 
  display: none; 
  align-items: center; 
  justify-content: center; 
  gap: 10px; 
  padding: 20px; 
  color: var(--opt-tryon-text-color);
}
.opt-tryon-loading .spinner { 
  display: inline-block; 
  width: 20px; 
  height: 20px; 
  border: 2px solid var(--opt-tryon-border-color); 
  border-top-color: var(--opt-tryon-primary-color); 
  border-radius: 50%; 
  animation: opt-tryon-spin .9s linear infinite; 
}

/* Consent section */
.opt-tryon-consent {
  margin: 10px 0;
  padding: 12px;
  background-color: #f9f9f9;
  border-radius: var(--opt-tryon-border-radius);
  border: 1px solid var(--opt-tryon-border-color);
}

.opt-tryon-consent label {
  display: block;
  margin-bottom: 8px;
  color: var(--opt-tryon-text-color);
  font-size: 14px;
}

.opt-tryon-consent input[type="checkbox"] {
  margin-right: 8px;
}

/* Stored photos and comparison grid */
.opt-tryon-stored-photos h4,
.opt-tryon-comparison-grid h4 {
  margin: 0 0 10px 0;
  color: var(--opt-tryon-text-color);
  font-size: 16px;
}

.opt-tryon-photo-grid,
.opt-tryon-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.opt-tryon-photo-grid img,
.opt-tryon-images-grid img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: var(--opt-tryon-border-radius);
  border: 2px solid var(--opt-tryon-border-color);
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.opt-tryon-photo-grid img:hover,
.opt-tryon-images-grid img:hover {
  border-color: var(--opt-tryon-primary-color);
}

/* Loader spinner animation */
@keyframes opt-tryon-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Lightbox styles for enlarged preview */
.opt-tryon-lightbox { position: fixed; inset: 0; z-index: 9999; }
.opt-tryon-lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.65); }
.opt-tryon-lightbox-content { position: relative; max-width: 90vw; max-height: 90vh; margin: 5vh auto; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.opt-tryon-lightbox-content img { display: block; max-width: 90vw; max-height: 80vh; object-fit: contain; }
.opt-tryon-lightbox-close { position: absolute; top: 8px; right: 12px; background: transparent; border: none; font-size: 24px; line-height: 1; cursor: pointer; }

/* Upload thumbnail preview */
.opt-tryon-upload-preview { 
    margin-top: 8px; 
    text-align: center;
}
#opt-tryon-upload-thumb { 
    width: 96px; 
    height: 96px; 
    object-fit: cover; 
    border-radius: 6px; 
    border: 1px solid #ddd; 
    background: #f9f9f9;
}
#opt-tryon-upload-thumb[style*="display: none"] {
    display: none !important;
}

/* Clickable cursors for images */
.opt-tryon-images-grid img, #opt-tryon-result-img { cursor: zoom-in; }