/* ==========================================================================
   Tactical Sprite Studio Stylesheet
   ========================================================================== */

:root {
  --bg-dark-900: #090d16;
  --bg-dark-800: #0f172a;
  --bg-dark-700: #1e293b;
  --bg-dark-600: #334155;
  --border-dark: rgba(51, 65, 85, 0.8);
  --border-light: rgba(148, 163, 184, 0.2);
  --accent-cyan: #38bdf8;
  --accent-blue: #0284c7;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark-900);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.studio-header {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dark);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.studio-logo-badge {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  font-size: 1.1rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.studio-title-group h1 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.studio-title-group p {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.studio-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-studio {
  background: var(--bg-dark-700);
  border: 1px solid var(--bg-dark-600);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-studio:hover {
  background: var(--bg-dark-600);
  border-color: var(--accent-cyan);
  color: #fff;
}

.btn-studio-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.btn-studio-primary:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
  transform: translateY(-1px);
}

.btn-studio-success {
  background: linear-gradient(135deg, #059669, #047857);
  border-color: #34d399;
  color: #fff;
}

.btn-studio-success:hover {
  background: linear-gradient(135deg, #047857, #059669);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
}

/* Main Layout */
.studio-layout {
  display: grid;
  grid-template-columns: 1fr 440px;
  flex: 1;
  min-height: calc(100vh - 65px);
}

@media (max-width: 1100px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

/* Left Workspace Panel */
.studio-workspace-pane {
  background: #060911;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid var(--border-dark);
}

.workspace-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--bg-dark-800);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 0.6rem 1rem;
}

.drop-zone-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.file-input-hidden {
  display: none;
}

/* Viewport Controls */
.viewport-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-dark-900);
  border: 1px solid var(--bg-dark-600);
  border-radius: 6px;
  padding: 3px;
}

.btn-vp-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-vp-tab:hover {
  color: #fff;
}

.btn-vp-tab.active {
  background: var(--bg-dark-700);
  color: var(--accent-cyan);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Canvas Container */
.studio-canvas-container {
  flex: 1;
  min-height: 480px;
  position: relative;
  background: #020408;
  border: 1.5px dashed rgba(51, 65, 85, 0.8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.studio-canvas-container.dragover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.06);
}

/* Checkerboard Pattern for Transparency */
.checkerboard-pattern {
  background-image: 
    linear-gradient(45deg, #1e293b 25%, transparent 25%),
    linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%),
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #0f172a;
}

.sim-scene-bg-preview {
  background: linear-gradient(rgba(15, 23, 42, 0.7), rgba(15, 23, 42, 0.85)), url('../images/preview_building.jpg') center/cover no-repeat #0b1120;
}

.solid-dark-bg {
  background: #090d16 !important;
}

.solid-white-bg {
  background: #ffffff !important;
}

.canvas-element {
  max-width: 95%;
  max-height: 82vh;
  object-fit: contain;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  display: block;
}

/* Empty Drop Prompt */
.canvas-empty-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
  cursor: pointer;
}

.empty-icon {
  font-size: 3rem;
  color: var(--accent-cyan);
  opacity: 0.8;
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
}

.empty-subtitle {
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

/* Retouch Brush Toolbar */
.studio-brush-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-dark-800);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  flex-wrap: wrap;
}

.brush-tool-btn {
  background: var(--bg-dark-700);
  border: 1px solid var(--bg-dark-600);
  color: var(--text-main);
  font-size: 0.76rem;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.brush-tool-btn:hover {
  background: var(--bg-dark-600);
  border-color: var(--accent-cyan);
}

.brush-tool-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.brush-tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--bg-dark-600);
  background: var(--bg-dark-800);
}

/* Brush Size Dynamic Reticle Outline */
.studio-brush-outline {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9), inset 0 0 0 1px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%);
  z-index: 100;
  display: none;
  mix-blend-mode: normal;
  transition: width 0.04s ease-out, height 0.04s ease-out;
}

.studio-brush-outline.mode-erase {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px #000, 0 0 6px rgba(239, 68, 68, 0.6), inset 0 0 0 1px #000;
}

.studio-brush-outline.mode-restore {
  border-color: #10b981;
  box-shadow: 0 0 0 1px #000, 0 0 6px rgba(16, 185, 129, 0.6), inset 0 0 0 1px #000;
}

/* Right Control & Properties Panel */
.studio-control-pane {
  background: var(--bg-dark-800);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 65px);
}

/* Section Box */
.studio-section {
  background: var(--bg-dark-900);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: all 0.15s ease;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  padding-bottom: 0.45rem;
}

.btn-toggle-studio-collapse {
  cursor: pointer;
  user-select: none;
}

.btn-toggle-studio-collapse:hover .section-title {
  filter: brightness(1.2);
}

.studio-section-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
  display: inline-block;
}

.studio-section-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: fadeIn 0.15s ease;
}

.studio-section.is-collapsed {
  padding-bottom: 0.6rem;
}

.studio-section.is-collapsed .section-header {
  border-bottom: none;
  padding-bottom: 0;
}

.studio-section.is-collapsed .studio-section-body {
  display: none;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Keying Controls */
.keying-modes-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.btn-key-mode {
  background: var(--bg-dark-700);
  border: 1px solid var(--bg-dark-600);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 0.45rem 0.2rem;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.btn-key-mode:hover {
  background: var(--bg-dark-600);
  color: #fff;
}

.btn-key-mode.active {
  background: var(--accent-blue);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* Sliders */
.studio-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.slider-val-badge {
  color: var(--accent-cyan);
  font-weight: 700;
}

.studio-range {
  width: 100%;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* Form Fields */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-label {
  font-size: 0.74rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
}

.form-input,
.form-select {
  background: var(--bg-dark-800);
  border: 1px solid var(--bg-dark-600);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.45rem 0.65rem;
  border-radius: 5px;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Catalog Drawer Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.catalog-card {
  background: var(--bg-dark-800);
  border: 1px solid var(--bg-dark-600);
  border-radius: 6px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.catalog-card:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
  transform: translateY(-2px);
}

.catalog-card.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.catalog-thumb-box {
  width: 100%;
  height: 70px;
  background: #020408;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.catalog-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.catalog-card-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  color: #f8fafc;
}

.catalog-card-pose {
  font-size: 0.6rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.btn-card-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-size: 0.65rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  opacity: 0.85;
}

.catalog-card:hover .btn-card-delete {
  opacity: 1;
}

.btn-card-delete:hover {
  background: #dc2626;
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

