/* png2mc Design System */

:root {
  --bg: #0a0a0a;
  --surface: #111;
  --border: #222;
  --text: #e5e5e5;
  --text-dim: #666;
  --text-secondary: #999;
  --text-muted: #777;
  --accent: #a855f7;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visually-hidden {
  display: none;
}

/* Hidden file input */
#fileInput {
  display: none;
}

/* Scale groups - hidden by default, shown via .active class */
#unifiedScaleGroup,
#separateScaleGroup,
#customScaleGroup {
  display: none;
}

#unifiedScaleGroup.active,
#separateScaleGroup.active,
#customScaleGroup.active {
  display: block;
}

/* Slider header spacing */
.slider-header-spaced {
  margin-top: 8px;
}

/* Custom button row */
#customBtnRow {
  margin-top: 12px;
  gap: 8px;
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.2s, height 0.2s, margin 0.2s;
}

#customBtnRow.visible {
  opacity: 1;
  height: auto;
}

#customBlocksBtn {
  flex: 1;
}

/* Expensive blocks modal */
#expensiveBlocksModal .modal {
  max-width: 500px;
}

#expensiveBlocksModal .modal-body {
  padding: 20px;
}

.expensive-blocks-intro {
  margin: 0 0 16px 0;
  color: var(--text-secondary);
}

#expensiveBlocksList {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.expensive-blocks-tip {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Expensive block item */
.expensive-block-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: var(--surface);
  border-radius: 4px;
  margin-bottom: 6px;
}

.expensive-block-cost {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
}

.expensive-block-name {
  flex: 1;
  font-family: var(--font-mono);
}

.expensive-block-count {
  color: var(--text-secondary);
  font-size: 12px;
}

.expensive-block-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin: -4px 0 8px 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'IBM Plex Mono', 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* Layout */
.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  flex-direction: column;
}

.social-icons {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-shrink: 0;
}

.social-icons a {
  color: var(--text-dim);
  transition: color 0.15s;
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 0;
}

.social-icons a:hover {
  color: var(--text);
}

.social-icons svg {
  display: block;
  width: 18px;
  height: 18px;
}

.paypal-link {
  position: relative;
  z-index: 10;
}

.paypal-link.attention svg {
  animation: paypal-attention 1.5s ease-out;
}

/* Push other icons away when PayPal is getting attention */
.social-icons.paypal-attention a:not(.paypal-link) {
  animation: icon-push-away 1.5s ease-out;
}

@keyframes paypal-attention {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  15% {
    transform: scale(2.2);
    filter: drop-shadow(0 0 20px rgba(0, 112, 186, 1)) drop-shadow(0 0 40px rgba(0, 112, 186, 0.8)) drop-shadow(0 0 60px rgba(0, 112, 186, 0.5));
  }
  25% {
    transform: scale(2.2) rotate(-12deg);
    filter: drop-shadow(0 0 25px rgba(0, 112, 186, 1)) drop-shadow(0 0 50px rgba(0, 112, 186, 0.8));
  }
  35% {
    transform: scale(2.2) rotate(12deg);
    filter: drop-shadow(0 0 20px rgba(0, 112, 186, 1)) drop-shadow(0 0 40px rgba(0, 112, 186, 0.7));
  }
  45% {
    transform: scale(2.1) rotate(-8deg);
    filter: drop-shadow(0 0 18px rgba(0, 112, 186, 0.9)) drop-shadow(0 0 35px rgba(0, 112, 186, 0.6));
  }
  55% {
    transform: scale(2.0) rotate(6deg);
    filter: drop-shadow(0 0 15px rgba(0, 112, 186, 0.8)) drop-shadow(0 0 30px rgba(0, 112, 186, 0.5));
  }
  70% {
    transform: scale(1.5) rotate(0deg);
    filter: drop-shadow(0 0 10px rgba(0, 112, 186, 0.6));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
}

@keyframes icon-push-away {
  0% {
    transform: translateX(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  15% {
    transform: translateX(var(--push-direction, -20px)) rotate(var(--tilt-direction, -15deg)) scale(0.8);
    opacity: 0.6;
  }
  50% {
    transform: translateX(var(--push-direction, -20px)) rotate(var(--tilt-direction, -15deg)) scale(0.8);
    opacity: 0.6;
  }
  100% {
    transform: translateX(0) rotate(0deg) scale(1);
    opacity: 1;
  }
}

/* Different push directions for icons before and after PayPal */
.social-icons.paypal-attention a:nth-child(1),
.social-icons.paypal-attention a:nth-child(2),
.social-icons.paypal-attention a:nth-child(3) {
  --push-direction: -25px;
  --tilt-direction: -20deg;
}

.social-icons.paypal-attention a:nth-child(5) {
  --push-direction: 25px;
  --tilt-direction: 20deg;
}

.paypal-tooltip {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 11px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(-4px);
  width: 220px;
  line-height: 1.5;
  z-index: 1000;
}

.paypal-tooltip::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 12px;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

.paypal-link:hover .paypal-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.app-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.app-subtitle {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1px;
  background: var(--border);
  height: calc(100vh - 60px);
  overflow: hidden;
}

.panel {
  background: var(--surface);
  padding: 24px;
  overflow-y: auto;
}

.panel-left {
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.panel-right {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Section Structure */
.section {
  margin-bottom: 28px;
}

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* Upload Zone */
.upload-zone {
  border: 1px solid var(--border);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.upload-zone:hover {
  border-color: #333;
  background: #161616;
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: #161616;
}

.upload-icon {
  font-size: 24px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.upload-text {
  font-size: 12px;
  color: var(--text);
}

.upload-hint {
  font-size: 10px;
  color: #444;
  margin-top: 8px;
}

/* Selects */
select {
  width: 100%;
  padding: 8px 32px 8px 10px;
  font-family: inherit;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

.select-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 8px;
}

/* Toggle Buttons */
.toggle-group {
  display: flex;
  border: 1px solid var(--border);
}

.toggle-btn {
  flex: 1;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 11px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.toggle-btn:last-child {
  border-right: none;
}

.toggle-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.toggle-btn.active {
  background: var(--bg);
  color: var(--text);
}

/* Sliders */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-value {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  height: 2px;
  background: var(--border);
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text);
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background-color 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--text);
  border: none;
  border-radius: 0;
  cursor: pointer;
}

.slider-hint {
  font-size: 10px;
  color: #444;
}

/* Scale toggles */
.scale-toggles {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.scale-toggles .checkbox-item {
  font-size: 10px;
  color: var(--text-dim);
}

.scale-toggles .checkbox-item:hover {
  color: var(--text);
}

/* Custom scale inputs */
.custom-inputs-row {
  display: flex;
  gap: 12px;
}

.custom-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-input-group label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.custom-input-group input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.custom-input-group input[type="number"]::-webkit-outer-spin-button,
.custom-input-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-input-group input[type="number"]:hover {
  border-color: #333;
}

.custom-input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* Checkboxes */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.checkbox-item input {
  display: none;
}

.checkbox-box {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, background-color 0.15s;
}

.checkbox-item:hover .checkbox-box {
  border-color: #333;
}

.checkbox-item input:checked + .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-item input:checked + .checkbox-box::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  background: var(--bg);
}

.checkbox-label {
  color: var(--text-dim);
  transition: color 0.15s;
}

.checkbox-item:hover .checkbox-label {
  color: var(--text);
}

.checkbox-item input:checked ~ .checkbox-label {
  color: var(--text);
}

/* Single checkbox */
.checkbox-single {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}

.checkbox-single input {
  display: none;
}

.checkbox-single .checkbox-box {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  position: relative;
  flex-shrink: 0;
}

.checkbox-single input:checked + .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-single input:checked + .checkbox-box::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  background: var(--bg);
}

/* Text Input */
.text-input {
  width: 100%;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.text-input::placeholder {
  color: var(--text-dim);
}

.input-with-extension {
  display: flex;
  border: 1px solid var(--border);
  background: var(--bg);
}

.input-with-extension .text-input {
  border: none;
  flex: 1;
}

.input-extension {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--accent);
  background: #1a1a1a;
  opacity: 0;
  transition: opacity 0.15s;
}

.input-extension.visible {
  opacity: 1;
}

/* Buttons */
.btn-group {
  display: flex;
  gap: 1px;
  background: var(--border);
}

.btn {
  flex: 1;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #161616;
}

.btn-text {
  padding: 8px 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-text:hover {
  color: var(--text);
  border-color: #333;
}

.btn-row {
  display: flex;
  gap: 8px;
}

/* Preview Area */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.preview-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.preview-controls {
  display: flex;
  gap: 4px;
}

.preview-btn {
  width: 28px;
  height: 28px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.preview-btn:hover {
  border-color: #333;
  color: var(--text);
}

.preview-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.preview-zoom {
  padding: 0 8px;
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  background-image: 
    linear-gradient(45deg, #151515 25%, transparent 25%),
    linear-gradient(-45deg, #151515 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151515 75%),
    linear-gradient(-45deg, transparent 75%, #151515 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.preview-container:active {
  cursor: grabbing;
}

.preview-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  will-change: transform;
}

.preview-placeholder {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.preview-canvas {
  image-rendering: pixelated;
  transition: transform 0.05s ease-out;
  will-change: transform;
}

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  image-rendering: pixelated;
}

.grid-overlay.visible {
  opacity: 0.5;
}

/* Stats Row */
.stats-row {
  display: flex;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-top: 16px;
}

.stat-item {
  flex: 1;
  background: var(--surface);
  padding: 12px 16px;
  text-align: center;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.stat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Block Tooltip */
.block-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  pointer-events: none;
  z-index: 1000;
  display: none;
}

.block-tooltip.visible {
  display: block;
}

.tooltip-color {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  background-size: cover;
  image-rendering: pixelated;
}

.tooltip-name {
  font-size: 11px;
  color: var(--text);
}

.tooltip-coords {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Grid Overlay */
.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.grid-overlay.visible {
  opacity: 1;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.loading-bar-container {
  width: 200px;
  height: 2px;
  background: var(--border);
}

.loading-bar {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.2s;
}

.loading-text {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 12px;
  text-transform: lowercase;
}

/* Block Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(-10px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.modal-close {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  border-color: #333;
  color: var(--text);
}

.modal-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.modal-search {
  flex: 1;
  min-width: 200px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions .btn {
  padding: 8px 12px;
  font-size: 10px;
}

.category-tabs {
  display: flex;
  gap: 1px;
  background: var(--border);
  margin: 0 20px;
  margin-top: 12px;
}

.category-tab {
  padding: 8px 12px;
  background: var(--bg);
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: color 0.15s;
}

.category-tab:hover {
  color: var(--text);
}

.category-tab.active {
  color: var(--accent);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.block-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s;
}

.block-item:hover {
  border-color: #333;
}

.block-item.selected {
  border-color: var(--accent);
}

.block-item.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.block-color {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background-size: cover;
  image-rendering: pixelated;
  margin-bottom: 8px;
}

.block-name {
  font-size: 9px;
  color: var(--text-dim);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.block-item.selected .block-name {
  color: var(--text);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.block-count {
  font-size: 10px;
  color: var(--text-dim);
}

.modal-footer .btn {
  padding: 8px 16px;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
}

::-webkit-scrollbar-thumb:hover {
  background: #333;
}
