:root {
  --bg-deep: #070a12;
  --bg-panel: rgba(15, 23, 42, 0.88);
  --bg-card: rgba(30, 41, 59, 0.65);
  --border-subtle: rgba(148, 163, 184, 0.16);
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --emerald: #10b981;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
}

/* ==========================================================================
   LIENZO PIXEL-ART INTERACTIVO (PANZOOM VIEWPORT)
   ========================================================================== */
#viewport {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background-image:
    radial-gradient(rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    radial-gradient(rgba(148, 163, 184, 0.04) 1px, #070a12 1px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  cursor: crosshair;
}

#canvas-stage {
  display: inline-block;
  transform-origin: 0 0;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3), 0 25px 70px rgba(0, 0, 0, 0.85);
}

#pixel-canvas {
  display: block;
  width: 256px;
  height: 256px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0f19;
}

/* ==========================================================================
   HUD SUPERIOR IZQUIERDO (COORDENADAS, ZOOM Y ESTADO)
   ========================================================================== */
.hud-top-left {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.brand-pill {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.hud-coord {
  font-family: var(--font-mono);
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.9);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.hud-btn {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

/* ==========================================================================
   BARRA INFERIOR: PALETA DE 16 COLORES Y COOLDOWN
   ========================================================================== */
.palette-bar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
   flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.palette-swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.swatch:hover {
  transform: translateY(-2px) scale(1.08);
}

.swatch.active {
  border-color: #ffffff;
  transform: scale(1.16);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}

.palette-status {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.cooldown-badge {
  font-family: var(--font-mono);
  color: var(--warning);
  font-weight: 600;
}

/* ==========================================================================
   DOCK FLOTANTE EN ESQUINA SUPERIOR DERECHA
   ========================================================================== */
.floating-dock {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  width: 350px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
}

.dock-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.dock-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(7, 10, 18, 0.45);
}

.dock-tab {
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dock-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(56, 189, 248, 0.06);
}

.dock-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Formularios y Tarjetas del Dock */
.form-group {
  margin-bottom: 10px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.input-field, .select-field {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-main);
  background: rgba(7, 10, 18, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  outline: none;
}

.input-field:focus, .select-field:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #070a12;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.btn-emerald:hover {
  background: rgba(16, 185, 129, 0.28);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}

.uuid-box {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(7, 10, 18, 0.8);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  color: #cbd5e1;
  word-break: break-all;
  margin-bottom: 10px;
}

/* Lista de Galería de Archivos */
.files-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
}

.file-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.file-info {
  overflow: hidden;
}

.file-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.copy-btn {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.alert-msg {
  font-size: 11px;
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  display: none;
}

.alert-msg.error {
  display: block;
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.alert-msg.success {
  display: block;
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
