/**
 * UV Grayscale Processor Styles
 * Tool for creating multi-layer UV reactive ink masks
 */

/* ========================================
   CSS CUSTOM PROPERTIES
   ======================================== */

:root {
  --uv-glow: #c8ff00;
  --uv-glow-dim: rgb(200, 255, 0, 0.3);
  --uv-dark: #1a1a2e;
  --uv-dark-lighter: #16213e;
  --uv-panel: #fff;
  --uv-panel-border: rgb(0, 0, 0, 0.08);
}

/* ========================================
   MAIN CONTAINER
   ======================================== */

.uv-processor {
  min-height: 100dvh;
  padding: 40px;
  background: linear-gradient(135deg, var(--uv-dark) 0%, var(--uv-dark-lighter) 100%);
}

/* ========================================
   HEADER
   ======================================== */

.uv-processor__header {
  max-width: 1400px;
  margin: 0 auto 40px;
  text-align: center;
}

.uv-processor__back {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 14px;
  text-decoration: none;
  color: rgb(255, 255, 255, 0.6);
  transition: color 0.2s;
}

.uv-processor__back:hover {
  color: var(--uv-glow);
}

.uv-processor__title {
  margin: 0 0 12px;
  font-size: 42px;
  font-weight: 900;
  text-shadow: 0 0 40px var(--uv-glow-dim);
  color: #fff;
}

.uv-processor__subtitle {
  margin: 0;
  font-size: 18px;
  color: rgb(255, 255, 255, 0.7);
}

/* ========================================
   LAYOUT
   ======================================== */

.uv-processor__layout {
  display: flex;
  gap: 40px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ========================================
   OPTIONS PANEL (LEFT)
   ======================================== */

.uv-processor__options {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: 24px;
  width: 340px;
}

.options-section {
  padding: 24px;
  background: var(--uv-panel);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgb(0, 0, 0, 0.2);
}

.options-section--info {
  background: rgb(255, 255, 255, 0.05);
  border: 1px solid rgb(255, 255, 255, 0.1);
}

.options-section--info .options-section__title {
  color: rgb(255, 255, 255, 0.9);
}

.options-section--info .options-section__text {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: rgb(255, 255, 255, 0.7);
}

.options-section--info .options-section__text:last-child {
  margin-bottom: 0;
}

.options-section__title {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary, #022662);
}

/* ========================================
   DROPZONE
   ======================================== */

.uv-processor__dropzone {
  padding: 40px 20px;
  text-align: center;
  background: #fafbfc;
  border: 2px dashed var(--primary, #022662);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.uv-processor__dropzone:hover,
.uv-processor__dropzone.is-dragover {
  background: var(--highlight, #fff1e6);
  border-color: var(--secondary, #f68b1f);
}

.uv-processor__dropzone.has-file {
  background: #f1f8e9;
  border-style: solid;
  border-color: #4caf50;
}

.dropzone__icon {
  margin-bottom: 12px;
  font-size: 48px;
  opacity: 0.4;
}

.dropzone__text {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary, #022662);
}

.dropzone__subtext {
  margin: 0;
  font-size: 13px;
  color: #888;
}

.dropzone__filename {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
  color: #4caf50;
}

.dropzone__filename:empty {
  display: none;
}

/* ========================================
   OPTION CONTROLS
   ======================================== */

.option-group {
  margin-bottom: 20px;
}

.option-group:last-child {
  margin-bottom: 0;
}

.option-group__label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.option-group__row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.option-group__range {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  outline: none;
  appearance: none;
}

.option-group__range::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  background: var(--secondary, #f68b1f);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
  appearance: none;
}

.option-group__range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.option-group__value {
  min-width: 24px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--primary, #022662);
}

.option-group__checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  color: #333;
  cursor: pointer;
}

.option-group__checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--secondary, #f68b1f);
}

.option-group__select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
}

.option-group__select:focus {
  border-color: var(--secondary, #f68b1f);
  outline: none;
}

.option-group__hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: #888;
}

.option-group__nested {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding: 12px;
  background: #f5f5f5;
  border-radius: 6px;
}

.option-group__inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.option-group__inline label {
  font-size: 12px;
  white-space: nowrap;
  color: #666;
}

.option-group__number {
  width: 60px;
  padding: 6px 8px;
  font-size: 14px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.option-group__number:focus {
  border-color: var(--secondary, #f68b1f);
  outline: none;
}

/* ========================================
   COLLAPSIBLE SECTION
   ======================================== */

.options-section--collapsible {
  padding: 0;
  overflow: hidden;
}

.options-section__toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 16px 24px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary, #022662);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.options-section__toggle:hover {
  background: #f5f5f5;
}

.options-section__toggle-icon {
  font-size: 10px;
  transition: transform 0.2s;
}

.options-section__content {
  max-height: 0;
  padding: 0 24px;
  overflow: hidden;
  transition:
    max-height 0.3s ease,
    padding 0.3s ease;
}

.options-section__content.is-expanded {
  max-height: 600px;
  padding: 0 24px 24px;
}

.options-section__toggle[aria-expanded='true'] .options-section__toggle-icon {
  transform: rotate(90deg);
}

/* ========================================
   PROCESS BUTTON
   ======================================== */

.uv-processor__process-btn {
  width: 100%;
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--primary, #022662);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.uv-processor__process-btn:hover:not(:disabled) {
  background: #033a8c;
  box-shadow: 0 4px 12px rgb(2, 38, 98, 0.4);
  transform: translateY(-2px);
}

.uv-processor__process-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   PREVIEW PANEL (RIGHT)
   ======================================== */

.uv-processor__preview {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 32px;
}

/* ========================================
   PROCESSING OVERLAY
   ======================================== */

.processing-overlay {
  position: absolute;
  z-index: 100;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgb(26, 26, 46, 0.95);
  border-radius: 12px;
  inset: 0;
}

.processing-overlay.is-visible {
  display: flex;
}

.processing-overlay__spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgb(200, 255, 0, 0.2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  border-top-color: var(--uv-glow);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.processing-overlay__text {
  margin-top: 16px;
  font-size: 16px;
  color: #fff;
}

/* ========================================
   EMPTY STATE
   ======================================== */

.preview-empty {
  padding: 80px 40px;
  text-align: center;
  background: rgb(255, 255, 255, 0.03);
  border: 1px dashed rgb(255, 255, 255, 0.2);
  border-radius: 12px;
}

.preview-empty__icon {
  margin-bottom: 16px;
  font-size: 64px;
  opacity: 0.3;
}

.preview-empty__text {
  margin: 0 0 8px;
  font-size: 20px;
  color: rgb(255, 255, 255, 0.8);
}

.preview-empty__subtext {
  margin: 0;
  font-size: 14px;
  color: rgb(255, 255, 255, 0.5);
}

/* ========================================
   PREVIEW SECTIONS
   ======================================== */

.preview-section {
  padding: 24px;
  background: var(--uv-panel);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgb(0, 0, 0, 0.2);
}

.preview-section__title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary, #022662);
}

.preview-section__badge {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: #1a1a2e;
  background: var(--uv-glow);
  border-radius: 4px;
}

.preview-section__caption {
  margin: 12px 0 0;
  font-size: 12px;
  text-align: center;
  color: #888;
}

.preview-canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #f5f5f5;
  border-radius: 8px;
}

.preview-canvas-wrapper--dark {
  background: #1a1a2e;
}

.preview-canvas-wrapper canvas {
  max-width: 100%;
  max-height: 400px;
  border-radius: 4px;
}

/* ========================================
   MASK GRID
   ======================================== */

.mask-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.mask-grid__item {
  padding: 12px;
  text-align: center;
  background: #f9f9f9;
  border-radius: 8px;
}

.mask-grid__canvas {
  width: 100%;
  height: auto;
  margin-bottom: 8px;
  background-color: #fff;

  /* Checkered background to show transparency */
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-position:
    0 0,
    0 6px,
    6px -6px,
    -6px 0;
  background-size: 12px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.mask-grid__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary, #022662);
}

.mask-grid__coverage {
  margin-top: 2px;
  font-size: 11px;
  color: #888;
}

/* ========================================
   DOWNLOAD SECTION
   ======================================== */

.preview-download {
  padding: 24px;
  text-align: center;
  background: var(--uv-panel);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgb(0, 0, 0, 0.2);
}

.uv-processor__download-btn {
  display: inline-flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  padding: 16px 48px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: var(--secondary, #f68b1f);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.uv-processor__download-btn:hover:not(:disabled) {
  background: #e67a0e;
  box-shadow: 0 4px 16px rgb(246, 139, 31, 0.4);
  transform: translateY(-2px);
}

.uv-processor__download-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.download-btn__icon {
  font-size: 24px;
}

.preview-download__note {
  margin: 16px 0 0;
  font-size: 13px;
  color: #888;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
  .uv-processor {
    padding: 24px;
    overflow-x: clip;
  }

  .uv-processor__layout {
    flex-direction: column;
    min-width: 0;
  }

  .uv-processor__options {
    width: 100%;
    min-width: 0;
  }

  .options-section {
    min-width: 0;
  }

  .mask-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mask-grid img,
  .preview-canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 480px) {
  .uv-processor {
    padding: 16px;
  }

  .uv-processor__layout {
    gap: 16px;
  }

  .uv-processor__title {
    font-size: 28px;
  }

  .uv-processor__subtitle {
    font-size: 14px;
  }

  .options-section {
    padding: 16px;
  }

  .mask-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mask-grid__item {
    padding: 8px;
  }

  .preview-canvas-wrapper canvas {
    max-height: 250px;
  }
}

/* ========================================
   EMBED MODE
   ======================================== */

.embed-mode .uv-processor__back {
  display: none;
}

.embed-mode .uv-processor__header {
  margin-bottom: 24px;
}

.embed-mode .uv-processor__title {
  font-size: 28px;
}
