/* FIGArtStudio — estilo do app (painel de terminal + controles). */
:root {
  /* Tema Windows PowerShell clássico: fundo azul #012456 + texto claro #EEEDF0. */
  --bg: #001233;
  --panel: #012456;
  --panel-2: #01327a;
  --line: #0f4090;
  --text: #eeedf0;
  --muted: #9fb2d6;
  --accent: #4f9cff;
  --accent-2: #9dc3ff;
  --radius: 12px;
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", Consolas, ui-monospace, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #013a86 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100%;
  overflow-x: hidden; /* guarda: nada gera scroll horizontal na página */
}

.app {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  /* padding horizontal fluido: encolhe em telas estreitas */
  padding: clamp(14px, 4vw, 22px) clamp(12px, 4vw, 20px) 40px;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.5vw, 16px);
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo {
  width: clamp(38px, 9vw, 44px);
  height: clamp(38px, 9vw, 44px);
  flex: none;
  display: block;
  border-radius: 10px;
  filter: drop-shadow(0 0 14px rgba(255, 122, 26, .35));
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: clamp(20px, 5vw, 26px);
  letter-spacing: .5px;
  background: linear-gradient(180deg, #eaf2ff, #6fa8ff 70%, #2b5cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.lang { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

/* ---- Controls ---- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 130px; }
.field-grow { flex: 1 1 260px; min-width: 0; }
.field-size { flex: 1 1 170px; min-width: 150px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* ---- Palette (color swatches + custom picker) ---- */
.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px 5px 6px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .05s, background .15s;
}
.swatch:hover { border-color: var(--accent); background: #013a86; }
.swatch:active { transform: translateY(1px); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(79, 156, 255, .4); }
.swatch-chip {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 1px solid rgba(255, 255, 255, .3);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, .45);
}
.swatch-name { white-space: nowrap; }
.swatch-chip-rainbow {
  background: conic-gradient(from 0deg, #ff004c, #ffb800, #2bff88, #00d0ff, #7a5cff, #ff004c);
}
.swatch-custom input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; padding: 0; border: none; opacity: 0; cursor: pointer;
}

input[type="text"], select {
  font-family: var(--sans);
  font-size: 16px; /* >=16px evita zoom automático de foco no iOS */
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  outline: none;
  max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 92, 255, .22);
}
input[type="text"] { font-family: var(--mono); }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.field label output { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Terminal ---- */
.terminal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .45);
  background: var(--term-bg, #05070d);
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #013a86, #012456);
  border-bottom: 1px solid var(--line);
}
.term-title {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.term-body {
  padding: 18px 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* rolagem suave em mobile p/ arte larga */
  min-height: 220px;
  max-height: 62vh;
  max-height: 62dvh; /* respeita barras dinâmicas do browser mobile */
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 3px),
    var(--term-bg, #05070d);
}
#output {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--art-size, 12px);
  line-height: 1.02;
  white-space: pre;
  /* cor definida via JS por tema (solid) ou gradient (background-clip) */
}
#output.empty { color: var(--muted); font-family: var(--sans); font-size: 14px; white-space: normal; }

/* ---- Actions ---- */
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); background: #013a86; }
.btn:active { transform: translateY(1px); }
.toast { color: var(--accent-2); font-size: 13px; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }

/* Tablet / telas médias: campos em duas colunas ficam mais confortáveis */
@media (max-width: 760px) {
  .term-body { padding: 14px 12px; max-height: 56vh; max-height: 56dvh; }
}

/* Mobile: uma coluna, controles em largura total */
@media (max-width: 560px) {
  .field { min-width: 100%; }
  .field-size { flex-basis: 100%; }
  .topbar { gap: 10px; }
  .lang { width: 100%; justify-content: flex-end; }
  .actions { gap: 8px; }
  .actions .btn { flex: 1 1 auto; justify-content: center; text-align: center; }
  .term-body { min-height: 180px; }
}

/* Telas muito estreitas (<380px): aperta ainda mais sem quebrar layout */
@media (max-width: 380px) {
  .app { padding-bottom: 28px; }
  .brand { gap: 10px; }
  .actions .btn { width: 100%; flex-basis: 100%; }
}

/* Respeita preferência de menos movimento */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
