/* PSify - PSX Texture Generator Styles */

* {
  font-family: 'MS Sans Serif', Arial, sans-serif;
}

body {
  background: teal;
  margin: 0;
  padding: 10px;
  overflow-x: hidden;
}

.window {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  box-shadow: 1px 1px 0 #ffffff inset, -1px -1px 0 #808080 inset;
  max-width: 600px;
  margin: 20px auto;
  padding: 0;
}

.title-bar {
  background: linear-gradient(to right, #000080, #1084d7);
  color: white;
  padding: 2px 2px 2px 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: bold;
}

.title-text {
  flex: 1;
  padding: 2px 4px;
}

.window-body {
  padding: 4px;
  background: #c0c0c0;
}

.section {
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  padding: 4px;
  margin-bottom: 4px;
}

.section-title {
  background: #000080;
  color: #dfdfdf;
  padding: 2px 2px;
  font-size: 11px;
  font-weight: bold;
  margin: -4px -4px 4px -4px;
  padding: 2px 4px;
}

.field-group {
  margin-bottom: 6px;
}

label {
  display: block;
  font-size: 11px;
  margin-bottom: 2px;
  color: #000;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  margin: 4px 0;
  cursor: pointer;
  background: transparent;
}

/* Track */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: #808080;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  box-shadow: 1px 1px 0 #000000 inset;
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  background: #808080;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  box-shadow: 1px 1px 0 #000000 inset;
}

/* Thumb */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 18px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  cursor: pointer;
  margin-top: -8px;
  box-shadow: 1px 1px 0 #ffffff inset;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 18px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  cursor: pointer;
  box-shadow: 1px 1px 0 #ffffff inset;
  border-radius: 0;
}

input[type="range"]:active::-webkit-slider-thumb {
  border-color: #808080 #dfdfdf #dfdfdf #808080;
}

input[type="range"]:active::-moz-range-thumb {
  border-color: #808080 #dfdfdf #dfdfdf #808080;
}

input[type="file"] {
  font-size: 11px;
}

select {
  width: 100%;
  padding: 2px;
  font-size: 11px;
  background: white;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  font-family: 'MS Sans Serif', Arial;
}

#paletteStatus,
#presetPaletteStatus {
  color: #808080;
  font-size: 10px;
  margin-top: 4px;
}

#presetPaletteSwatches {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
  margin-top: 4px;
}

.preset-palette-swatch {
  height: 14px;
  border: 1px solid #808080;
  box-shadow: 1px 1px 0 #dfdfdf inset, -1px -1px 0 #808080 inset;
}

#presetPaletteHexList {
  color: #404040;
  font-size: 9px;
  line-height: 1.3;
  margin-top: 4px;
  word-break: break-word;
}

input[type="checkbox"] {
  margin-right: 4px;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  font-size: 11px;
  cursor: pointer;
}

#seamlessControls {
  margin-left: 16px;
  padding-left: 8px;
  border-left: 2px solid #808080;
  margin-top: 6px;
}

.value-display {
  float: right;
  font-size: 11px;
  font-weight: bold;
  color: #000;
}

.button-group {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

button {
  padding: 4px 12px;
  font-size: 11px;
  font-family: 'MS Sans Serif', Arial;
  cursor: pointer;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  flex: 1;
  font-weight: bold;
}

button:active {
  border-color: #808080 #dfdfdf #dfdfdf #808080;
}

button:disabled {
  color: #808080;
  text-shadow: 1px 1px #dfdfdf;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.preview-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  padding: 4px;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  background: #b8b8b8;
}

.preview-switch-label {
  font-size: 10px;
  font-weight: bold;
  color: #000040;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.preview-tabs {
  display: flex;
  gap: 3px;
  margin: 0;
  flex: 1;
}

.preview-tab {
  flex: 1 1 0;
  padding: 4px 8px;
  font-size: 10px;
  line-height: 1;
  min-width: 0;
  white-space: nowrap;
}

.preview-tab.active {
  background: #000080;
  color: #fff;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  text-shadow: none;
}

.preview-panel {
  margin-top: 0;
}

.preview-2d-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  padding: 4px;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  background: #d4d4d4;
}

.preview-2d-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 2px 4px;
  font-size: 11px;
  background: #c8c8c8;
  border: 1px solid #a0a0a0;
}

.preview-3d-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 4px;
  border: 1px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  background: #d4d4d4;
}

.preview-3d-label {
  font-size: 10px;
  font-weight: bold;
  color: #202020;
  text-transform: uppercase;
}

.preview-focus-btn {
  flex: 0 0 auto;
  min-width: 56px;
  padding: 3px 8px;
  font-size: 10px;
}

.preview-focus-btn.active {
  background: #000080;
  color: #fff;
  text-shadow: none;
}

.preview-box {
  background: white;
  border: 2px solid;
  border-color: #808080 #dfdfdf #dfdfdf #808080;
  padding: 4px;
  margin: 4px 0;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.preview-box.panning {
  cursor: grabbing;
}

.preview-box img {
  max-width: 100%;
  max-height: 300px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: transform 0.1s ease-out;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.preview-box.zoomed img {
  max-width: none;
  max-height: none;
  position: absolute;
}

.preview-hint {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 9px;
  padding: 2px 4px;
  border-radius: 2px;
  pointer-events: none;
  opacity: 0.6;
}

.preview-3d {
  padding: 0;
  background: #111;
  cursor: default;
  min-height: 260px;
}

#preview3dCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.preview-3d-hint {
  left: 8px;
  right: auto;
}

.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: #c0c0c0;
  border-left: 1px solid #808080;
  border-top: 1px solid #808080;
  cursor: ns-resize;
  z-index: 100;
  pointer-events: auto;
}

.resize-handle::before {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: linear-gradient(
    135deg,
    transparent 0%, transparent 40%,
    #808080 40%, #808080 45%,
    transparent 45%, transparent 50%,
    #808080 50%, #808080 55%,
    transparent 55%, transparent 60%,
    #808080 60%, #808080 65%,
    transparent 65%
  );
}

.preview-box.user-resized {
  min-height: 100px;
  max-height: 800px;
}

.preview-box.zoomed.user-resized {
  height: var(--user-height, auto);
}

body.in-iframe .preview-box {
  min-height: min(220px, 45vh);
  max-height: none;
}

body.in-iframe .preview-3d {
  min-height: min(280px, 50vh);
}

body.in-iframe .preview-box.user-resized {
  max-height: 90vh;
}

body.in-iframe .resize-handle {
  display: block !important;
}

.comparison-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.comparison-before,
.comparison-after {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity 0.2s ease;
}

.comparison-after {
  clip-path: inset(0 0 0 var(--slider-position, 50%));
}

.comparison-slider {
  position: absolute;
  left: var(--slider-position, 50%);
  top: 0;
  bottom: 0;
  width: 4px;
  background: #000080;
  cursor: ew-resize;
  z-index: 10;
  border: 1px solid #dfdfdf;
}

.slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slider-handle::before {
  content: '⟷';
  font-size: 12px;
  color: #000;
  user-select: none;
}

.preview-box.comparison-mode {
  cursor: default;
}

.preview-box.comparison-mode > img:not(.comparison-before):not(.comparison-after) {
  display: none;
}

.status-text {
  font-size: 11px;
  padding: 2px 4px;
  margin-top: 4px;
  min-height: 16px;
}

.status-text.processing {
  background: #dfdfdf;
  border: 1px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  color: #000;
}

.status-text.success {
  background: #dfdfdf;
  border: 1px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  color: #008000;
}

.status-text.error {
  background: #dfdfdf;
  border: 1px solid;
  border-color: #dfdfdf #808080 #808080 #dfdfdf;
  color: #ff0000;
}

.drag-over {
  background: #000080 !important;
}

.drag-over label, .drag-over p {
  color: white !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 5px;
  }

  .window {
    max-width: 100%;
    margin: 10px auto;
  }

  .window-body {
    padding: 8px;
  }

  .field-group {
    margin-bottom: 10px;
  }

  .field-group label {
    font-size: 10px;
  }

  input[type="range"] {
    height: 18px;
  }

  button {
    font-size: 11px;
    padding: 4px 12px;
  }

  .preview-switch {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .preview-switch-label {
    font-size: 9px;
  }

  .preview-2d-controls {
    gap: 4px;
  }

  .preview-2d-option {
    width: 100%;
  }

  .preview-3d-controls {
    gap: 4px;
  }

  .preview-box {
    min-height: 150px;
    max-height: 250px;
  }

  .preview-3d {
    min-height: 180px;
  }

  .preview-box img {
    max-height: 250px;
  }

  .preview-box.user-resized {
    min-height: 150px;
    max-height: 400px;
  }
}

@media (max-width: 768px) and (pointer: coarse) {
  .resize-handle {
    display: none;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 12px;
  }

  .field-group label {
    font-size: 9px;
  }

  button {
    font-size: 10px;
    padding: 3px 10px;
  }

  .value-display {
    font-size: 9px;
    min-width: 25px;
  }

  .preview-box {
    min-height: 120px;
    max-height: 200px;
  }

  .preview-3d {
    min-height: 160px;
  }

  .preview-box img {
    max-height: 200px;
  }
}
