@font-face {
  font-family: "Monocraft";
  src: url("Monocraft.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

:root {
  --bg-color: #262626;
  --panel-bg: #313131;
  --text-color: #ffffff;
  --accent-color: #00e385;
  --border-light: #5d5d5d;
  --border-dark: #131313;
  --button-face: #3c3c3c;
  --font: "Monocraft", monospace;
}

/* Prevent flicker on load */
body.loading {
  visibility: hidden;
}

body.loaded {
  visibility: visible;
}

* {
  box-sizing: border-box;
  user-select: none;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Toolbar */
.toolbar {
  height: 48px;
  background: var(--panel-bg);
  border-bottom: 2px solid var(--border-dark);
  display: flex;
  align-items: center;
  padding: 0 16px;
  justify-content: space-between;
}

.logo {
  font-size: 24px;
  color: var(--accent-color);
  text-shadow: 2px 2px 0 #000;
}

.file-ops {
  display: flex;
  gap: 8px;
}

/* Username Lookup */
.username-lookup {
  display: flex;
  gap: 6px;
  align-items: center;
}

#username-input {
  width: 200px;
  padding: 6px 10px;
  background: #1a1a1a;
  border: 2px solid;
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

#username-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 1px var(--accent-color);
}

#username-input::placeholder {
  color: #666;
}

/* Minecraft-style buttons */
.mc-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--button-face);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  color: white;
  font-family: var(--font);
  font-size: 16px;
  padding: 4px 12px;
  cursor: pointer;
}

.mc-btn:hover {
  background: #4a4a4a;
}

.mc-btn:active {
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  background: #2a2a2a;
}

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

.mc-btn-danger {
  background: #5a3030;
}

.mc-btn-danger:hover {
  background: #6a4040;
}

/* Layout */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 250px;
  background: var(--bg-color);
  border-right: 2px solid var(--border-dark);
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel {
  background: var(--panel-bg);
  padding: 8px;
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
}

.panel h3 {
  margin: 0 0 6px 0;
  font-size: 13px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Tools */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.tool-btn {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--button-face);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  color: white;
  cursor: pointer;
}

.tool-btn:hover {
  background: #4a4a4a;
}

.tool-btn.active {
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  background: #2a2a2a;
  color: var(--accent-color);
}

/* Brush Size */
.brush-row {
  display: flex;
  gap: 3px;
}

.brush-btn {
  flex: 1;
  height: 28px;
  background: var(--button-face);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
}

.brush-btn.active {
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  background: #2a2a2a;
  color: var(--accent-color);
}

/* Advanced Color Picker */
.color-picker-advanced {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.color-picker-main {
  position: relative;
  border: 2px solid var(--border-dark);
}

#color-canvas {
  display: block;
  cursor: crosshair;
}

.color-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px black;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.hue-bar {
  position: relative;
  border: 2px solid var(--border-dark);
}

#hue-canvas {
  display: block;
  cursor: pointer;
}

.hue-cursor {
  position: absolute;
  left: -2px;
  right: -2px;
  height: 4px;
  border: 2px solid white;
  box-shadow: 0 0 0 1px black;
  pointer-events: none;
  transform: translateY(-50%);
}

.color-current {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

#color-preview {
  width: 36px;
  height: 28px;
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  background: var(--accent-color);
  flex-shrink: 0;
}

#hex-input {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  background: #1a1a1a;
  border: 2px solid;
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  color: white;
  font-family: var(--font);
  font-size: 12px;
  text-transform: uppercase;
}

.alpha-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.alpha-row label {
  font-size: 10px;
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
}

.alpha-row input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%),
    repeating-conic-gradient(#808080 0% 25%, #fff 0% 50%) 50% / 8px 8px;
  border: 1px solid #555;
  outline: none;
}

.alpha-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 14px;
  background: white;
  cursor: pointer;
  border: 1px solid #333;
}

#alpha-value {
  font-size: 10px;
  color: #888;
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* Model Type Toggle */
.model-type-row {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.model-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--button-face);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  color: white;
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
}

.model-type-btn input {
  display: none;
}

.model-type-btn.active {
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  background: #2a2a2a;
  color: var(--accent-color);
}

/* Skin Diagram */
.skin-diagram {
  position: relative;
  width: 160px;
  height: 210px;
  margin: 0 auto 10px;
  margin-bottom: -20px;
  margin-top: 20px;
}

.skin-part {
  position: absolute;
  background: var(--accent-color);
  border: 2px solid rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition:
    opacity 0.15s,
    transform 0.1s;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.skin-part:hover {
  filter: brightness(1.2);
  transform: scale(1.05);
  z-index: 1;
}

.skin-part.hidden {
  opacity: 0.25;
  background: #444;
  box-shadow: none;
}

.skin-part.head {
  width: 50px;
  height: 50px;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  border-radius: 3px;
}

.skin-part.head:hover {
  transform: translateX(-50%) scale(1.05);
}

.skin-part.body {
  width: 50px;
  height: 65px;
  left: 50%;
  top: 52px;
  transform: translateX(-50%);
}

.skin-part.body:hover {
  transform: translateX(-50%) scale(1.05);
}

.skin-part.arm-l {
  width: 25px;
  height: 65px;
  left: calc(50% + 27px);
  top: 52px;
}

.skin-part.arm-r {
  width: 25px;
  height: 65px;
  right: calc(50% + 27px);
  top: 52px;
}

.skin-part.leg-l {
  width: 25px;
  height: 65px;
  left: calc(50% + 1px);
  top: 119px;
}

.skin-part.leg-r {
  width: 25px;
  height: 65px;
  right: calc(50% + 1px);
  top: 119px;
}

/* History */
.history-row {
  display: flex;
  gap: 4px;
}

.history-row .mc-btn {
  flex: 1;
  justify-content: center;
  padding: 6px;
}

/* Minecraft-Style Toggle Switches */
.layer-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.mc-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.mc-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 44px;
  height: 22px;
  background: linear-gradient(180deg, #3a3a3a 0%, #4a4a4a 50%, #3a3a3a 100%);
  border: 2px solid #222;
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.4),
    inset -1px -1px 0 rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  background: linear-gradient(180deg, #888 0%, #666 50%, #555 100%);
  border: 2px solid;
  border-color: #aaa #444 #333 #777;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.3),
    inset -1px -1px 0 rgba(0, 0, 0, 0.3);
  transition: left 0.1s ease;
}

.mc-switch input[type="checkbox"]:checked + .switch-track {
  /* Active track uses a darker site green */
  background: linear-gradient(180deg, #006a4b 0%, #008f61 50%, #006a4b 100%);
}

.mc-switch input[type="checkbox"]:checked + .switch-track .switch-thumb {
  left: 23px;
  /* Active thumb styling using site green */
  background: linear-gradient(180deg, #33f7c0 0%, #00e385 50%, #00b56a 100%);
  border-color: #7ff4c6 #0a6a47 #06583a #27f0a1;
}

.switch-label {
  font-size: 13px;
  color: #ccc;
  text-shadow: 1px 1px 0 #000;
  font-weight: 500;
}

.mc-switch:hover .switch-thumb {
  background: linear-gradient(180deg, #999 0%, #777 50%, #666 100%);
}

.mc-switch:hover input[type="checkbox"]:checked + .switch-track .switch-thumb {
  /* Hovered active thumb — slightly brighter */
  background: linear-gradient(180deg, #6cffb7 0%, #00e385 50%, #00b56a 100%);
}

/* Split View */
.split-view {
  flex: 1;
  display: flex;
  flex-direction: row-reverse; /* Swap: 3D on left, 2D on right */
}

.viewport-2d {
  flex: 1;
  background: #1a1a1a;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border-left: 2px solid var(--border-dark); /* Border on left now */
  overflow: hidden; /* Handle zoom overflow */
}

/* Zoom controls */
.zoom-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.8);
  padding: 6px 10px;
  border: 1px solid #333;
  z-index: 100;
}

.zoom-controls button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  background: var(--button-face);
  color: white;
  font-size: 20px;
  cursor: pointer;
  font-family: var(--font);
}

.zoom-controls button:hover {
  background: #4a4a4a;
}

.zoom-controls button:active {
  border-color: var(--border-dark) var(--border-light) var(--border-light) var(--border-dark);
  background: var(--accent-color);
}

.zoom-controls span {
  font-size: 14px;
  color: #ccc;
  min-width: 50px;
  text-align: center;
  font-family: var(--font);
}

.canvas-wrapper {
  position: relative;
  border: 2px solid var(--border-light);
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  background-image: linear-gradient(45deg, #222 25%, transparent 25%), linear-gradient(-45deg, #222 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #222 75%), linear-gradient(-45deg, transparent 75%, #222 75%);
  background-size: 16px 16px;
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0px;
  background-color: #1a1a1a;
}

#zone-bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 512px;
  height: 512px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 1;
  display: none;
}

.canvas-wrapper.grid #zone-bg-canvas {
  display: block;
}

#cursor-preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 512px;
  height: 512px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 20; /* Above skin-canvas and grid-overlay */
}

#skin-canvas {
  position: relative;
  display: block;
  width: 512px;
  height: 512px;
  image-rendering: pixelated;
  cursor: crosshair;
  z-index: 5;
}

/* Grid overlay container */
#grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  display: none;
}

.canvas-wrapper.grid #grid-overlay {
  display: block;
}

.viewport-3d {
  flex: 1;
  background: #1a1a1a;
  position: relative;
  overflow: hidden;
}

.viewport-3d canvas {
  cursor: grab;
}

.viewport-3d canvas:active {
  cursor: grabbing;
}

.viewport-label {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.8);
  padding: 6px 12px;
  font-size: 16px;
  pointer-events: none;
  border: 1px solid #333;
}

.viewport-label.top-label {
  z-index: 1;
}

.help-text {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  color: #888;
  font-size: 13px;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.8);
  padding: 6px 10px;
  border: 1px solid #333;
}

/* Custom Confirmation Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-box {
  background: var(--panel-bg);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  padding: 20px;
  min-width: 320px;
  max-width: 90%;
  text-align: center;
}

.modal-title {
  font-size: 20px;
  color: var(--accent-color);
  margin-bottom: 12px;
  text-shadow: 2px 2px 0 #000;
}

.modal-message {
  font-size: 14px;
  color: #ccc;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-buttons .mc-btn {
  min-width: 100px;
  justify-content: center;
}

/* Notifications */
.notification {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--panel-bg);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-dark) var(--border-light);
  padding: 10px 20px;
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
}

.notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.notification-success {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

.notification-error {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.notification-info {
  color: #4dabf7;
  border-color: #4dabf7;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: 6px;
  font-size: 14px;
  text-align: center;
}

/* Pizza Button */
.pizza-btn {
  background: #ff813f !important;
  color: white !important;
  text-decoration: none;
}

.pizza-btn:hover {
  background: #ff9b6a !important;
}

/* Mobile Overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #1a1a1a;
  z-index: 100000;
  justify-content: center;
  align-items: center;
  padding: 40px;
  text-align: center;
}

.mobile-message-box {
  background: var(--panel-bg);
  border: 4px solid var(--border-dark);
  padding: 30px;
  max-width: 500px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
}

.mobile-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.mobile-message-box h2 {
  color: var(--accent-color);
  margin-bottom: 15px;
  text-shadow: 2px 2px 0 #000;
}

.mobile-message-box p {
  color: #ccc;
  line-height: 1.6;
}

@media (max-width: 1324px) {
  .app-container {
    display: none;
  }
  .mobile-overlay {
    display: flex;
  }
}
