/* =========================================================================
   Guidelyze · Editor de Imagem · editor.css v2
   ========================================================================= */

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

:root {
  --ed-bg:     #0e0e0e;
  --ed-surface:#1a1a1a;
  --ed-border: rgba(255,255,255,.1);
  --ed-text:   #f0f0f0;
  --ed-muted:  #888;
  --ed-accent: #5C8F7A;
  --ed-red:    rgba(239,68,68,.55);
}

html, body {
  height: 100%; width: 100%;
  background: var(--ed-bg);
  color: var(--ed-text);
  font-family: 'DM Sans', system-ui, sans-serif;
  overflow: hidden;
}

.ed-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

/* ---- Top bar ---- */
.ed-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ed-border);
  flex-shrink: 0;
  background: var(--ed-surface);
  z-index: 2;
}
.ed-back {
  background: none; border: none; color: var(--ed-accent); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 5px 8px; border-radius: 6px;
  white-space: nowrap; font-family: inherit;
}
.ed-back:hover { background: rgba(92,143,122,.15); }
.ed-topbar__title {
  flex: 1; font-size: 13px; font-weight: 600; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ed-text);
}
.ed-clear-btn {
  background: none; border: none; color: var(--ed-muted); cursor: pointer;
  font-size: 12px; padding: 5px 8px; border-radius: 6px; white-space: nowrap;
  font-family: inherit;
}
.ed-clear-btn:hover { color: var(--ed-text); background: rgba(255,255,255,.07); }

/* ---- Canvas area ---- */
.ed-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
.ed-canvas-wrap {
  position: relative;
  user-select: none;
}
.ed-canvas-wrap canvas { display: block; }
#canvas-image { /* base layer — drawn image */ }
#canvas-mask {
  position: absolute;
  top: 0; left: 0;
  cursor: crosshair;
  touch-action: none;
}

.ed-empty {
  text-align: center; color: var(--ed-muted); padding: 24px;
}
.ed-empty__icon { font-size: 36px; margin-bottom: 10px; }
.ed-empty__title { font-size: 16px; font-weight: 600; color: var(--ed-text); margin-bottom: 6px; }
.ed-empty__sub { font-size: 13px; }

/* ---- Tools bar ---- */
.ed-tools {
  display: flex;
  justify-content: space-around;
  padding: 6px 4px;
  border-top: 1px solid var(--ed-border);
  background: var(--ed-surface);
  flex-shrink: 0;
}
.ed-tool {
  background: none; border: none; color: var(--ed-muted); cursor: pointer;
  font-size: 10px; font-weight: 500; padding: 6px 10px; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  line-height: 1; transition: all .15s; font-family: inherit;
}
.ed-tool:first-child { font-size: 18px; }
.ed-tool span { font-size: 10px; }
.ed-tool:disabled { opacity: .3; cursor: not-allowed; }
.ed-tool.is-active { color: var(--ed-accent); background: rgba(92,143,122,.15); }
.ed-tool:not(:disabled):hover { color: var(--ed-text); background: rgba(255,255,255,.06); }

/* ---- Brush row ---- */
.ed-brush-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 14px;
  background: var(--ed-surface); border-top: 1px solid var(--ed-border);
  flex-shrink: 0;
}
.ed-brush-label { font-size: 11px; color: var(--ed-muted); white-space: nowrap; }
.ed-brush-slider {
  flex: 1; accent-color: var(--ed-accent); height: 4px;
}
.ed-brush-val { font-size: 11px; color: var(--ed-muted); width: 22px; text-align: right; }

/* ---- Prompt panel ---- */
.ed-panel {
  padding: 10px 14px 16px;
  background: var(--ed-surface);
  border-top: 1px solid var(--ed-border);
  flex-shrink: 0;
}
.ed-prompt {
  width: 100%; resize: none;
  background: rgba(255,255,255,.06); border: 1px solid var(--ed-border);
  border-radius: 10px; color: var(--ed-text); font-family: inherit;
  font-size: 14px; padding: 10px 12px; line-height: 1.4; margin-bottom: 8px;
}
.ed-prompt::placeholder { color: var(--ed-muted); }
.ed-prompt:focus { outline: none; border-color: var(--ed-accent); }
.ed-panel__row { display: flex; align-items: center; gap: 8px; }
.ed-model-chips {
  flex: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.ed-model-chips::-webkit-scrollbar { display: none; }
.ed-model-chip {
  flex-shrink: 0; background: rgba(255,255,255,.07); border: 1px solid var(--ed-border);
  border-radius: 20px; color: var(--ed-muted); font-size: 11px; padding: 4px 10px;
  cursor: pointer; white-space: nowrap; transition: all .15s; font-family: inherit;
}
.ed-model-chip.is-active {
  background: rgba(92,143,122,.2); border-color: var(--ed-accent); color: var(--ed-accent);
}
.ed-generate {
  flex-shrink: 0; background: var(--ed-accent); color: #fff; border: none;
  border-radius: 20px; font-size: 13px; font-weight: 700; padding: 8px 18px;
  cursor: pointer; white-space: nowrap; font-family: inherit; transition: filter .15s;
}
.ed-generate:hover { filter: brightness(1.1); }
.ed-generate:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* ---- Result overlay ---- */
.ed-result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 16px;
}
.ed-result-overlay[hidden] { display: none !important; }
.ed-result-canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; width: 100%;
}
#canvas-result {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 8px;
}
.ed-result-actions {
  display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center;
  flex-shrink: 0;
}

/* ---- Buttons ---- */
.ed-btn {
  border: none; border-radius: 20px; font-size: 13px; font-weight: 600;
  padding: 9px 20px; cursor: pointer; font-family: inherit; transition: filter .15s;
}
.ed-btn--primary { background: var(--ed-accent); color: #fff; }
.ed-btn--primary:hover { filter: brightness(1.1); }
.ed-btn--ghost { background: rgba(255,255,255,.12); color: var(--ed-text); }
.ed-btn--ghost:hover { background: rgba(255,255,255,.2); }
.ed-btn--text { background: none; color: var(--ed-muted); }
.ed-btn--text:hover { color: var(--ed-text); }

/* ---- Loading overlay ---- */
.ed-loading {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 20; gap: 14px;
}
.ed-loading[hidden] { display: none !important; }
.ed-loading__spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--ed-accent);
  border-radius: 50%;
  animation: ed-spin .8s linear infinite;
}
@keyframes ed-spin { to { transform: rotate(360deg); } }
.ed-loading p { color: var(--ed-muted); font-size: 13px; }

/* ---- Tab switcher ---- */
.ed-tabs {
  display: flex; background: var(--ed-surface);
  border-bottom: 1px solid var(--ed-border); flex-shrink: 0;
}
.ed-tab {
  flex: 1; background: none; border: none; color: var(--ed-muted);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 9px 0; cursor: pointer; transition: all .15s;
  border-bottom: 2px solid transparent;
}
.ed-tab.is-active { color: var(--ed-accent); border-bottom-color: var(--ed-accent); }
.ed-tab:hover:not(.is-active) { color: var(--ed-text); }

/* ---- Tab panels ---- */
.ed-tab-panel { display: flex; flex-direction: column; flex-shrink: 0; }
.ed-tab-panel[hidden] { display: none !important; }

/* ---- Compose layer (overlays over canvas) ---- */
.ed-compose-layer {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.ed-compose-layer.is-active { pointer-events: auto; }

/* ---- Compose overlay elements ---- */
.ed-overlay-el {
  position: absolute; cursor: move; user-select: none;
  touch-action: none;
  outline: 1px dashed rgba(255,255,255,.5);
}
.ed-overlay-el.is-selected { outline: 2px solid var(--ed-accent); }
.ed-overlay-el img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* ---- Compose sections ---- */
.ed-compose-section {
  border-top: 1px solid var(--ed-border);
  background: var(--ed-surface);
}
.ed-compose-section__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--ed-text);
}
.ed-compose-section__actions { display: flex; gap: 6px; }
.ed-compose-controls { padding: 0 14px 10px; display: flex; flex-direction: column; gap: 8px; }
.ed-compose-controls[hidden] { display: none !important; }

.ed-compose-btn {
  background: rgba(255,255,255,.08); border: 1px solid var(--ed-border);
  border-radius: 6px; color: var(--ed-text); font-size: 11px; font-weight: 600;
  padding: 4px 10px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.ed-compose-btn:hover { background: rgba(255,255,255,.14); }
.ed-compose-btn--danger { color: #f87171; border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.08); }
.ed-compose-btn--danger:hover { background: rgba(248,113,113,.18); }

.ed-ctrl-row {
  display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ed-muted);
}
.ed-ctrl-row span:first-child { width: 60px; flex-shrink: 0; }
.ed-ctrl-row .ed-brush-slider { flex: 1; }

.ed-text-input {
  width: 100%; background: rgba(255,255,255,.07); border: 1px solid var(--ed-border);
  border-radius: 8px; color: var(--ed-text); font-family: inherit; font-size: 14px;
  padding: 8px 10px;
}
.ed-text-input:focus { outline: none; border-color: var(--ed-accent); }

.ed-font-select {
  flex: 1; background: rgba(255,255,255,.07); border: 1px solid var(--ed-border);
  border-radius: 6px; color: var(--ed-text); font-size: 12px; padding: 4px 6px;
}

.ed-color-pick {
  width: 32px; height: 24px; border: none; border-radius: 4px;
  cursor: pointer; padding: 0; background: none;
}
.ed-align-group { display: flex; gap: 2px; }
.ed-align-btn { padding: 4px 7px; font-size: 9px; letter-spacing: 0; }
.ed-align-btn.is-active { background: rgba(92,143,122,.3); border-color: var(--ed-accent); color: var(--ed-accent); }

.ed-compose-apply {
  padding: 10px 14px 16px;
  background: var(--ed-surface);
  border-top: 1px solid var(--ed-border);
}
