/* AIMML Style - based on VRMML but enhanced */
:root { color-scheme: dark; }

/* Supply font */
@font-face {
  font-family: 'Supply';
  src: url('/fonts/Supply.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html, body { height: 100%; }
body {
  margin: 0;
  padding: 1.25rem 1rem 2rem;
  background: #020202;
  color: #e5e7eb;
  font-family: 'Supply', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  overflow-x: hidden;
}

/* Animated Background (Retrowave / AI Matrix) */
@keyframes retrowaveGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.retro-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, #0b0012, #1a002b, #001233, #002b4d);
  background-size: 400% 400%;
  animation: retrowaveGradient 20s ease infinite;
}

.retro-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.retro-overlay .retro-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 60% 20%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1.5px 1.5px at 80% 70%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(2px 2px at 35% 75%, rgba(255,255,255,.8), transparent 60%);
  opacity: 0.5;
}

@keyframes gridMove { 0%{ background-position: 0 0, 0 0; } 100%{ background-position: 0 40px, 80px 0; } }
.retro-overlay .retro-grid {
  position: absolute; left: 0; right: 0; bottom: 0; height: 60%;
  background-image: 
    linear-gradient(rgba(24, 153, 214, 0.2) 1px, transparent 1px), 
    linear-gradient(90deg, rgba(24, 153, 214, 0.2) 1px, transparent 1px);
  background-size: 40px 40px;
  transform-origin: center bottom;
  transform: perspective(1000px) rotateX(60deg);
  animation: gridMove 10s linear infinite;
  mask-image: linear-gradient(to bottom, transparent 0%, black 40%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 40%);
}

/* Layout */
header {
  max-width: 920px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 10;
}
header h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1;
  background: linear-gradient(90deg, #fff, #1899D6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(24, 153, 214, 0.5);
}

main {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
  position: relative;
  z-index: 10;
}

/* Panels/Sections */
.panel-box {
  background: rgba(18, 18, 20, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(45, 45, 52, 0.8);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Uploader */
.uploader {
  display: grid;
  gap: 1rem;
}

.upload-area {
  border: 2px dashed #2d2d34;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(0,0,0,0.2);
}
.upload-area:hover, .upload-area.dragover {
  border-color: #1899D6;
  background: rgba(24, 153, 214, 0.1);
  transform: translateY(-2px);
}
.upload-icon { font-size: 3rem; margin-bottom: 1rem; filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
.upload-text { color: #e5e7eb; margin-bottom: 0.5rem; font-size: 1.1rem; }
.upload-hint { color: #9ca3af; font-size: 0.9rem; }

#file-input { display: none; }

/* Previews */
.preview-container { display: none; margin-top: 1rem; }
.preview-container.visible { display: block; }
#preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  max-width: 320px;
  margin: 0 auto;
}
.preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2d2d34;
  aspect-ratio: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.remove-btn:hover { transform: scale(1.1); background: #ef4444; }
.multiview-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(99, 102, 241, 0.85);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Forms */
.form-group { margin-top: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #1899D6;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group textarea, .form-group input[type="text"] {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(18, 18, 20, 0.6);
  border: 1px solid #2d2d34;
  border-radius: 8px;
  color: #e5e7eb;
  font-family: 'Supply', monospace;
  font-size: 0.95rem;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.form-group textarea:focus, .form-group input[type="text"]:focus {
  outline: none;
  border-color: #1899D6;
  background: rgba(18, 18, 20, 0.9);
}
.hint { color: #9ca3af; font-size: 0.8rem; margin-top: 0.5rem; }

/* Buttons */
.button-19 {
  appearance: button;
  position: relative;
  background-color: #1899D6;
  border: solid transparent;
  border-radius: 16px;
  border-width: 0 0 4px;
  box-sizing: border-box;
  color: #FFFFFF;
  cursor: pointer;
  display: inline-block;
  font-family: 'Supply', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .8px;
  line-height: 20px;
  margin: 0;
  outline: none;
  padding: 12px 16px;
  text-align: center;
  text-transform: uppercase;
  transform: translateZ(0);
  transition: filter .2s;
  vertical-align: middle;
  white-space: nowrap;
  width: auto;
  text-decoration: none;
}
.button-19:after {
  background-clip: padding-box;
  background-color: #1CB0F6;
  border: solid transparent;
  border-radius: 16px;
  border-width: 0 0 4px;
  bottom: -4px;
  content: "";
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  z-index: -1;
}
.button-19:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.button-19:disabled { cursor: not-allowed; opacity: .6; filter: grayscale(0.5); }
.button-19:active { border-width: 4px 0 0; background: none; transform: translateY(2px); }
.button-19.full-width { width: 100%; margin-top: 1.5rem; }
.button-19.secondary { background-color: #374151; }
.button-19.secondary:after { background-color: #4b5563; }

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #2d2d34;
  border-radius: 3px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #1899D6;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Progress Section */
.panel { display: none; }
.panel.visible { display: block; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.progress-bar-container { height: 6px; background: #121214; border-radius: 3px; overflow: hidden; margin-bottom: 1rem; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1899D6, #6366f1);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
  box-shadow: 0 0 10px rgba(24, 153, 214, 0.5);
}

.progress-steps { display: flex; flex-direction: column; gap: 0.5rem; }
.step {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem;
  background: rgba(18, 18, 20, 0.5);
  border-radius: 8px;
  border-left: 3px solid transparent;
  opacity: 0.5;
  font-size: 0.9rem;
  transition: all 0.3s;
}
.step.active { opacity: 1; border-left-color: #1899D6; background: rgba(24, 153, 214, 0.1); }
.step.completed { opacity: 1; border-left-color: #22c55e; color: #22c55e; }
.step-icon { width: 24px; text-align: center; font-size: 1.2rem; }

/* Viewer */
.viewer {
  position: relative;
  margin: 1.5rem auto 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #333;
  max-width: 500px;
  aspect-ratio: 1 / 1;
}
.viewer-canvas, model-viewer {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1a1a1c 0%, #000 100%);
  display: block;
}

/* Intermediate Results */
.intermediate-results { display: none; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #2d2d34; }
.intermediate-results.visible { display: block; }
.preview-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.preview-compare img {
  max-width: 100%; max-height: 200px; border-radius: 8px; border: 1px solid #2d2d34;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.stacked-preview { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.stacked-preview img {
  position: absolute; width: 90px; height: 90px; object-fit: cover;
  border-radius: 8px; border: 2px solid #2d2d34; box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.stacked-preview img:nth-child(1) { top: 0; left: 0; z-index: 4; }
.stacked-preview img:nth-child(2) { top: 10px; left: 45px; z-index: 3; }
.stacked-preview img:nth-child(3) { top: 45px; left: 0; z-index: 2; }
.stacked-preview img:nth-child(4) { top: 45px; left: 45px; z-index: 1; }
.stacked-preview.single img { width: 140px; height: 140px; top: 0; left: 0; }
.image-count-badge {
  position: absolute; bottom: -8px; right: -8px; background: #1899D6; color: white;
  font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; z-index: 5;
}

/* Result Section */
.result { display: none; margin-top: 1rem; }
.result.visible { display: block; animation: fadeIn 0.5s ease; }
.result-header { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.5rem; }
.result-header h3 { margin: 0; color: #22c55e; font-size: 1.4rem; text-shadow: 0 0 10px rgba(34, 197, 94, 0.3); }

.download-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem;
}
.download-card {
  background: rgba(18, 18, 20, 0.5); border: 1px solid #2d2d34; border-radius: 12px; padding: 1.5rem; text-align: center;
  transition: transform 0.2s;
}
.download-card:hover { transform: translateY(-3px); border-color: #1899D6; }
.download-card h4 { margin: 0 0 0.5rem 0; font-size: 1.1rem; }
.download-card p { color: #9ca3af; font-size: 0.85rem; margin: 0 0 1.25rem 0; }

.mml-section { background: rgba(18, 18, 20, 0.5); border-radius: 12px; padding: 1.5rem; border: 1px solid #2d2d34; }
.mml-code {
  background: #0b0b0c; padding: 1rem; border-radius: 8px; font-family: 'Monaco', monospace;
  font-size: 0.85rem; overflow-x: auto; margin-bottom: 1rem; border: 1px solid #2d2d34; color: #1CB0F6;
}

/* AI MML Enhancement Section */
.ai-enhance-section {
  background: rgba(18, 18, 20, 0.5);
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #1a3a4a;
  margin-top: 1rem;
  background: linear-gradient(135deg, rgba(18,18,20,0.6), rgba(24,40,60,0.3));
}
.ai-enhance-section h4 { font-size: 1rem; color: #e5e7eb; }
.ai-enhance-section .mml-code {
  margin-bottom: 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Footer */
footer {
  max-width: 920px; margin: 2rem auto 0; color: #6b7280; font-size: 0.85rem; text-align: center;
  position: relative; z-index: 10;
}
footer a { color: #1899D6; text-decoration: none; transition: color 0.2s; }
footer a:hover { color: #1CB0F6; text-decoration: underline; }

/* Utilities */
.hidden { display: none !important; }
.spinner {
  width: 24px; height: 24px; border: 3px solid #2d2d34; border-top-color: #1899D6;
  border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.login-box {
  background: #121214; border: 1px solid #2d2d34; border-radius: 16px; padding: 2.5rem;
  width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.login-box h2 { margin: 0 0 1.5rem 0; text-align: center; color: #1899D6; }
.login-box input {
  width: 100%; padding: 0.8rem; background: #0a0a0a; border: 1px solid #2d2d34;
  border-radius: 8px; color: #e5e7eb; margin-bottom: 1rem; box-sizing: border-box;
}
.login-box input:focus { outline: none; border-color: #1899D6; }
.login-box .btn {
  width: 100%; padding: 0.8rem; background: #1899D6; border: none; border-radius: 8px;
  color: white; font-weight: bold; cursor: pointer; transition: background 0.2s;
}
.login-box .btn:hover { background: #1CB0F6; }

/* Loading/Animation Status */
.vrm-loading-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center; border-radius: 8px;
}
.animation-status { display: none; }

/* VRM Viewer Container */
.vrm-viewer-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.vrm-viewer-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Service Toggle */
.service-toggle {
  display: flex;
  gap: 0.5rem;
  padding: 4px;
  background: #121214;
  border-radius: 10px;
  border: 1px solid #2d2d34;
}

.service-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #9ca3af;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.service-btn:hover {
  background: rgba(24, 153, 214, 0.1);
  color: #e5e7eb;
}

.service-btn.active {
  background: linear-gradient(135deg, #1899D6, #1CB0F6);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(24, 153, 214, 0.3);
}

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

.service-btn.disabled:hover {
  background: transparent;
  color: #9ca3af;
}

.service-icon {
  font-size: 1rem;
}

.service-name {
  font-size: 0.85rem;
}
