/* OPTIMIZED BUILD */
/* PixelForge — main.css */

/* ── VARIABLES ─────────────────────────────────── */
:root {
  --bg:      #0A0A0D;
  --bg2:     #111116;
  --bg3:     #17171E;
  --bg4:     #1E1E27;
  --line:    rgba(255,255,255,0.055);
  --line2:   rgba(255,255,255,0.10);
  --tx:      #E6E6F0;
  --tx2:     #8080A0;
  --tx3:     #45455A;
  --accent:  #5B5FEF;
  --accent2: #7B7FFF;
  --green:   #22D47A;
  --red:     #FF4060;

  --panel-w: 216px;
  --topbar-h: 40px;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;

  --radius-sm: 3px;
  --radius:    5px;
  --radius-lg: 8px;
}

/* ── RESET ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--tx);
  font-size: 12px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── TOPBAR ────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 10px; gap: 3px;
  flex-shrink: 0; z-index: 100;
  user-select: none;
}

.brand {
  font-family: var(--mono);
  font-size: 13px; font-weight: 500;
  color: var(--tx); letter-spacing: -0.01em;
  margin-right: 6px; flex-shrink: 0;
}
.brand span { color: var(--accent2); }

.topbar-mid { display: flex; align-items: center; gap: 3px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.tb-sep { width: 1px; height: 16px; background: var(--line2); margin: 0 4px; flex-shrink: 0; }

.tb-btn {
  height: 26px; padding: 0 9px;
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; color: var(--tx2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 11px; font-family: var(--sans); font-weight: 500;
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.tb-btn:hover { background: var(--bg3); color: var(--tx); border-color: var(--line); }
.tb-btn--primary { background: var(--accent) !important; color: #fff !important; border-color: transparent !important; }
.tb-btn--primary:hover { background: var(--accent2) !important; }

.zoom-label {
  font-family: var(--mono); font-size: 10px; color: var(--tx3);
  min-width: 38px; text-align: center; flex-shrink: 0;
}
.canvas-info {
  font-family: var(--mono); font-size: 10px; color: var(--tx3);
  white-space: nowrap;
}

/* ── WORKSPACE ─────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr var(--panel-w);
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ── PANEL ─────────────────────────────────────── */
.panel {
  background: var(--bg2);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.panel--right { border-right: none; border-left: 1px solid var(--line); }
.panel::-webkit-scrollbar { width: 3px; }
.panel::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }
.panel::-webkit-scrollbar-track { background: transparent; }

.pblock {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.plabel {
  display: block;
  font-family: var(--mono); font-size: 9px; font-weight: 500;
  color: var(--tx3); letter-spacing: 0.10em; text-transform: uppercase;
  margin-bottom: 8px;
}

/* ── TOOL GRID ─────────────────────────────────── */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.tool-btn {
  height: 30px; display: flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--bg3); color: var(--tx2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 11px; font-family: var(--sans); font-weight: 500;
  cursor: pointer; transition: all 0.12s;
}
.tool-btn:hover { background: var(--bg4); color: var(--tx); border-color: var(--line2); }
.tool-btn.active {
  background: rgba(91,95,239,0.14);
  color: var(--accent2); border-color: rgba(91,95,239,0.35);
}

/* ── SLIDERS ───────────────────────────────────── */
.slider-row {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 7px;
}
.slider-row:last-of-type { margin-bottom: 0; }
.slider-row label {
  font-size: 10px; color: var(--tx2); width: 66px;
  flex-shrink: 0; font-family: var(--mono); white-space: nowrap;
}
.slider-row input[type=range] {
  flex: 1; height: 2px;
  -webkit-appearance: none; appearance: none;
  background: var(--bg4); border-radius: 1px;
  outline: none; cursor: pointer;
}
.slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(91,95,239,0.3);
  cursor: grab; transition: transform 0.1s;
}
.slider-row input[type=range]::-webkit-slider-thumb:active {
  transform: scale(1.25); cursor: grabbing;
}
.slider-val {
  font-family: var(--mono); font-size: 9px; color: var(--tx3);
  min-width: 24px; text-align: right; flex-shrink: 0;
}

/* ── COLOR ROW ─────────────────────────────────── */
.color-row {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
}
.color-row label { font-size: 10px; color: var(--tx2); font-family: var(--mono); }
.color-row input[type=color] {
  width: 28px; height: 22px; padding: 1px;
  border: 1px solid var(--line2); border-radius: var(--radius-sm);
  background: var(--bg3); cursor: pointer;
}

/* ── ACTION BUTTONS ────────────────────────────── */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.action-btn {
  height: 28px; display: flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--bg3); color: var(--tx2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 10px; font-family: var(--sans); font-weight: 500;
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
.action-btn:hover { background: var(--bg4); color: var(--tx); border-color: var(--line2); }
.action-btn--wide { grid-column: 1 / -1; width: 100%; }
.action-btn--accent {
  background: rgba(91,95,239,0.12); color: var(--accent2);
  border-color: rgba(91,95,239,0.28);
}
.action-btn--accent:hover { background: rgba(91,95,239,0.22); }

/* ── FILTER GRID ───────────────────────────────── */
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.filter-btn {
  padding: 5px 4px; font-size: 10px; font-weight: 500;
  background: var(--bg3); color: var(--tx2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.12s; font-family: var(--mono);
  text-align: center;
}
.filter-btn:hover { color: var(--tx); border-color: var(--line2); }
.filter-btn.active {
  background: rgba(91,95,239,0.14);
  color: var(--accent2); border-color: rgba(91,95,239,0.35);
}

/* ── TEXT INPUTS ───────────────────────────────── */
.text-inp {
  width: 100%; padding: 6px 8px; margin-bottom: 6px;
  background: var(--bg3); color: var(--tx);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 11px; font-family: var(--sans); outline: none;
  transition: border-color 0.12s;
}
.text-inp:focus { border-color: var(--accent); }

.mini-row { display: flex; gap: 4px; margin-bottom: 5px; }
.mini-sel {
  flex: 1; padding: 5px 5px;
  background: var(--bg3); color: var(--tx);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 10px; font-family: var(--sans); outline: none; cursor: pointer;
}
.mini-num {
  width: 46px; padding: 5px 4px; text-align: center;
  background: var(--bg3); color: var(--tx);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 10px; outline: none;
}
.color-mini {
  width: 28px; height: 28px; padding: 2px;
  border: 1px solid var(--line2); border-radius: var(--radius-sm);
  background: var(--bg3); cursor: pointer; flex-shrink: 0;
}
.hint {
  font-size: 9px; color: var(--tx3); font-family: var(--mono);
  margin-top: 4px; line-height: 1.4;
}

/* ── LAYERS ────────────────────────────────────── */
.layers-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.icon-btn {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--tx2); font-size: 12px; transition: all 0.12s;
}
.icon-btn:hover { color: var(--tx); border-color: var(--line2); }
.icon-btn--danger:hover { color: var(--red) !important; border-color: var(--red) !important; }

.blend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }

#layers-list {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 36px;
}
.layers-empty {
  font-size: 10px; color: var(--tx3); font-family: var(--mono);
  text-align: center; padding: 12px 0;
}
.layer-item {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 6px; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.12s;
}
.layer-item:hover { background: var(--bg3); }
.layer-item.active {
  background: rgba(91,95,239,0.10);
  border-color: rgba(91,95,239,0.28);
}
.layer-thumb {
  width: 32px; height: 22px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 2px;
  background: var(--bg4); overflow: hidden;
  background-size: cover; background-position: center;
  /* checkerboard for transparency */
  background-image:
    linear-gradient(45deg, #333 25%, transparent 25%),
    linear-gradient(-45deg, #333 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #333 75%),
    linear-gradient(-45deg, transparent 75%, #333 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
}
.layer-info { flex: 1; min-width: 0; }
.layer-name {
  font-size: 10px; font-weight: 500; color: var(--tx);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.layer-meta { font-size: 9px; color: var(--tx3); font-family: var(--mono); }
.vis-btn {
  width: 18px; height: 18px; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: var(--tx3); display: flex; align-items: center; justify-content: center;
  transition: color 0.12s; border-radius: 2px;
}
.vis-btn:hover { color: var(--tx); }
.vis-btn.off { opacity: 0.3; }

/* ── AI CARD ───────────────────────────────────── */
.ai-card {
  background: rgba(91,95,239,0.05);
  border: 1px solid rgba(91,95,239,0.14);
  border-radius: var(--radius);
  padding: 8px; margin-bottom: 8px;
}
.ai-card-inner { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ai-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  background: rgba(91,95,239,0.12); color: var(--accent2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.ai-card-title { font-size: 11px; font-weight: 600; color: var(--tx); }
.ai-card-sub { font-size: 9px; color: var(--tx3); font-family: var(--mono); }

.ai-progress {
  height: 2px; background: var(--bg4); border-radius: 1px;
  overflow: hidden; margin-top: 6px;
}
.ai-progress-fill {
  height: 100%; width: 0; background: var(--accent);
  border-radius: 1px; transition: width 0.4s ease;
}

/* ── CANVAS AREA ───────────────────────────────── */
.canvas-area {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(91,95,239,0.04) 0%, transparent 55%),
    repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(255,255,255,0.018) 24px),
    repeating-linear-gradient(90deg, transparent, transparent 23px, rgba(255,255,255,0.018) 24px),
    var(--bg);
  cursor: default;
}

.canvas-stack {
  position: relative;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.07), 0 12px 50px rgba(0,0,0,0.7);
  /* Checkerboard para mostrar transparencia */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0px;
}
.canvas-stack canvas {
  display: block;
  position: absolute; top: 0; left: 0;
}
.canvas-stack canvas:first-child {
  position: relative; /* main canvas sets the dimensions */
}
#draw-canvas { pointer-events: none; z-index: 2; }

/* ── DROPZONE ──────────────────────────────────── */
.dropzone {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; cursor: pointer;
  color: var(--tx3);
  transition: background 0.15s;
}
.dropzone.drag-over { background: rgba(91,95,239,0.05); }
.dz-title { font-size: 16px; font-weight: 600; color: var(--tx); margin-top: 4px; }
.dz-sub   { font-size: 11px; color: var(--tx2); }
.dz-btn {
  margin-top: 4px; padding: 8px 20px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 12px; font-weight: 600; font-family: var(--sans);
  cursor: pointer; transition: background 0.15s;
}
.dz-btn:hover { background: var(--accent2); }
.dz-fmts { font-size: 10px; color: var(--tx3); font-family: var(--mono); }

/* ── CROP MODAL ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fadein 0.15s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg2); border: 1px solid var(--line2);
  border-radius: var(--radius-lg); padding: 20px; width: 320px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  animation: slideup 0.18s ease;
}
@keyframes slideup { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.modal-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; }

.aspect-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 5px; margin-bottom: 10px; }
.asp-btn {
  padding: 5px; text-align: center;
  font-size: 10px; font-weight: 600; font-family: var(--mono);
  background: var(--bg3); color: var(--tx2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.12s;
}
.asp-btn:hover { color: var(--tx); border-color: var(--line2); }
.asp-btn.active { background: rgba(91,95,239,0.14); color: var(--accent2); border-color: rgba(91,95,239,0.35); }

.modal-dims { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.modal-dims input {
  flex: 1; padding: 6px; text-align: center;
  background: var(--bg3); color: var(--tx);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 11px; outline: none;
}
.modal-dims input:focus { border-color: var(--accent); }
.modal-dims span { color: var(--tx3); font-family: var(--mono); }

.modal-footer { display: flex; gap: 6px; justify-content: flex-end; }
.modal-btn {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; font-family: var(--sans);
  cursor: pointer; transition: all 0.12s;
  background: var(--bg3); color: var(--tx2);
  border: 1px solid var(--line);
}
.modal-btn:hover { color: var(--tx); border-color: var(--line2); }
.modal-btn--primary { background: var(--accent); color: #fff; border-color: transparent; }
.modal-btn--primary:hover { background: var(--accent2); }

/* ── AI OVERLAY ────────────────────────────────── */
.ai-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
}
.ai-ring {
  width: 46px; height: 46px;
  border: 3px solid rgba(91,95,239,0.2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ai-title { font-size: 15px; font-weight: 600; }
.ai-sub   { font-size: 11px; color: var(--tx2); font-family: var(--mono); }

/* ── TOASTS ────────────────────────────────────── */
#toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 9999;
  display: flex; flex-direction: column; gap: 5px; pointer-events: none;
}
.toast {
  padding: 8px 13px; border-radius: var(--radius);
  font-size: 11px; font-weight: 500;
  color: #fff; box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: tin 0.2s ease; pointer-events: auto; max-width: 270px; line-height: 1.4;
}
.toast-s { background: #18A354; }
.toast-e { background: var(--red); }
.toast-i { background: var(--accent); }
.toast-w { background: #D97706; }
.toast.out { animation: tout 0.2s ease forwards; }
@keyframes tin  { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
@keyframes tout { from { opacity:1; } to { opacity:0; transform:translateY(4px); } }

/* ── HELIX ─────────────────────────────────────── */
.helix-powered {
  position: fixed; bottom: 5px; left: 50%;
  transform: translateX(-50%); z-index: 10;
}
.helix-powered a {
  font-size: 9px; color: var(--tx3); opacity: 0.25;
  text-decoration: none; font-family: var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  transition: opacity 0.2s;
}
.helix-powered a:hover { opacity: 0.55; }

/* ── UTILS ─────────────────────────────────────── */
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }