/* ============================================
   Fotooh — Estilos v2.0.4
   As fontes (--font-display, --font-body) sao
   carregadas dinamicamente pelo bootstrap do
   index.html com base no config.json. Defaults:
   Caveat (display) e Sentient (body), carregadas
   automaticamente se o config nao especificar.
   ============================================ */

:root {
  --azul-claro:    #daeaf5;
  --azul:          #7fb3cc;
  --azul-escuro:   #2e6f96;
  --azul2-claro:   #f0f7fc;
  --azul2:         #c8e2f0;
  --azul2-escuro:  #7aaec8;
  --verde-claro:   #d8edd8;
  --verde:         #88bb88;
  --verde-escuro:  #3a7a3a;
  --dark:          #2d2a25;
  --mid:           #5a5650;
  --muted:         #8a8680;
  --subtle:        #b8b4b0;
  --light:         #f7f5f2;
  --white:         #ffffff;
  --border:        rgba(45,42,37,0.09);
  --border-mid:    rgba(45,42,37,0.16);
  --font-display:  'Caveat', cursive;
  --font-body:     'Sentient', Georgia, serif;
  --font-mono:     'SFMono-Regular', Consolas, monospace;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-btn:  10px;
  --radius-card: 16px;
  --radius-lg:   20px;
  --radius-pill: 999px;
  --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:  0 2px 6px rgba(0,0,0,.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,.09);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.11);
  --shadow-xl:  0 16px 56px rgba(0,0,0,.14);
  --z-sticky: 200;
  --z-toast:  600;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font-body); background: #faf8f5; color: var(--dark); line-height: 1.7; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--azul2); border-radius: 3px; }

/* ============================================
   BOTÕES BASE
   ============================================ */
.btn {
  font-family: var(--font-body); font-size: 0.78rem;
  padding: 9px 18px; border-radius: var(--radius-btn);
  border: 1.5px solid transparent; cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }
.btn-primary { background: var(--azul); color: var(--white); border-color: var(--azul); }
.btn-primary:hover { background: var(--azul-escuro); border-color: var(--azul-escuro); }
.btn-outline { background: transparent; color: var(--azul-escuro); border-color: var(--azul); }
.btn-outline:hover { background: var(--azul-claro); }

/* ============================================
   TOAST
   ============================================ */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 0.4rem;
  pointer-events: none;
}
.toast {
  background: var(--dark); color: var(--white);
  padding: 10px 16px; border-radius: var(--radius-btn);
  font-size: 0.8rem; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ============================================
   TOPBAR (desktop e mobile)
   ============================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  z-index: var(--z-sticky);
}
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; line-height: 0;
}
.topbar-logo-campanha,
.topbar-logo-fallback {
  height: 36px; width: auto; display: block;
}
.topbar-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  background: var(--azul); color: var(--white);
  border-radius: var(--radius-btn);
  font-family: var(--font-body); font-size: 0.82rem;
  text-decoration: none;
  transition: background 0.15s;
}
.topbar-cta:hover { background: var(--azul-escuro); }
.topbar-cta svg   { width: 14px; height: 14px; }

.header-powered {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--muted);
  letter-spacing: normal; text-transform: none;
}
.logo-fotooh-footer {
  height: 16px; width: auto; display: block;
  opacity: 0.72;
}
.powered-by {
  font-size: 0.7rem;
  color: var(--subtle);
  font-style: italic;
}
.fotooh-veronikas {
  display: inline-block; text-decoration: none; line-height: 0;
}
.fotooh-veronikas img {
  height: 14px; width: auto; display: block;
  opacity: 0.6; transition: opacity 0.15s;
}
.fotooh-veronikas:hover img { opacity: 0.9; }

/* Footer do painel — visível em todas as abas */
.painel-footer {
  margin-top: 2rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.3rem;
}
.painel-footer-copy {
  font-size: 0.62rem;
  color: var(--subtle);
  line-height: 1.4;
  margin: 0;
  letter-spacing: 0.02em;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.criar-wrap {
  margin-top: 64px;
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 0;
}

.criar-painel {
  border-right: 1px solid var(--border);
  background: var(--white);
  padding: 2rem 1.5rem;
  overflow-y: auto;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
}
.criar-painel h1 {
  font-family: var(--font-display); font-size: 1.6rem;
  font-weight: 600; color: var(--dark); margin-bottom: 0.3rem;
}
.criar-painel-sub { font-size: 0.8rem; color: var(--muted); margin-bottom: 1.8rem; display: block; }

.step { margin-bottom: 1.8rem; padding-bottom: 1.8rem; border-bottom: 1px solid var(--border); }
.step:last-of-type { border-bottom: none; }

.step-label {
  font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--azul); margin-bottom: 0.5rem;
  display: flex; align-items: center; gap: 6px;
}
.step-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--azul-claro); color: var(--azul-escuro);
  font-size: 0.6rem; display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
}
.step-sublabel {
  font-size: 0.6rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); margin-top: 1.2rem; margin-bottom: 0.5rem; display: block;
}

/* ============================================
   UPLOAD
   ============================================ */
.upload-zone {
  border: 2px dashed var(--border-mid); border-radius: var(--radius-card);
  padding: 1.5rem; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--light);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--azul); background: var(--azul-claro); }
.upload-zone p { font-size: 0.82rem; color: var(--muted); margin: 0; max-width: none; }
.upload-zone.has-image { border-style: solid; border-color: var(--verde); background: var(--verde-claro); }
.upload-zone.has-image p { color: var(--verde-escuro); }
#foto-input { display: none; }

/* ============================================
   FORMATO
   ============================================ */
.format-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.format-btn {
  flex: 1; padding: 0.6rem;
  border: 1px solid var(--border-mid); border-radius: var(--radius-md);
  background: var(--white); cursor: pointer; text-align: center;
  transition: all 0.12s; font-family: var(--font-body);
}
.format-btn.active { border-color: var(--azul); background: var(--azul-claro); color: var(--azul-escuro); }
.format-btn-title { font-size: 0.82rem; font-weight: 500; display: block; color: var(--dark); }
.format-btn-sub   { font-size: 0.68rem; color: var(--muted); display: block; }

/* ============================================
   FILTRO FOTO
   ============================================ */
.filtro-grid { display: flex; gap: 0.4rem; }
.filtro-btn {
  flex: 1; padding: 0.6rem;
  border: 1px solid var(--border-mid); border-radius: var(--radius-md);
  background: var(--white); cursor: pointer; text-align: center;
  transition: all 0.12s; font-family: var(--font-body);
}
.filtro-btn.active { border-color: var(--azul); background: var(--azul-claro); color: var(--azul-escuro); }
.filtro-btn-title { font-size: 0.82rem; font-weight: 500; display: block; color: var(--dark); }
.filtro-btn-sub   { font-size: 0.68rem; color: var(--muted); display: block; }

/* ============================================
   GRAFISMOS
   ============================================ */
.grafismos-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem; margin-top: 0.5rem;
}
.grafismo-opt {
  border: 2px solid var(--border); border-radius: var(--radius-md);
  overflow: hidden; cursor: pointer; aspect-ratio: 4/5;
  background: var(--light); transition: border-color 0.12s; position: relative;
}
.grafismo-opt:hover  { border-color: var(--azul2); }
.grafismo-opt.active { border-color: var(--azul); }
.grafismo-opt.none-opt { display: flex; align-items: center; justify-content: center; font-size: 0.7rem; color: var(--muted); }
.grafismo-opt canvas { width: 100%; height: 100%; display: block; }

/* ============================================
   CORES
   ============================================ */
.cores-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.5rem; }
.cor-opt {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  outline: 2px solid transparent; outline-offset: 2px;
}
.cor-opt:hover { transform: scale(1.15); }
.cor-opt.active { outline-color: var(--dark); border-color: white; }
.cores-grid.paleta-desativada { opacity: 0.4; pointer-events: none; }
.paleta-desativada-msg { font-size: 0.72rem; color: var(--muted); margin-top: 0.4rem; font-style: italic; }

/* ============================================
   POSIÇÃO LOGO
   ============================================ */
.posicao-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; margin-top: 0.5rem; max-width: 160px;
}
.pos-btn {
  height: 36px; border: 1px solid var(--border-mid); border-radius: var(--radius-sm);
  background: var(--white); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s; font-size: 0.6rem; color: var(--muted);
}
.pos-btn:hover  { background: var(--azul-claro); border-color: var(--azul); }
.pos-btn.active { background: var(--azul); border-color: var(--azul); color: white; }
.pos-btn svg { width: 14px; height: 14px; fill: currentColor; }
.logo-cor-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 0.5rem; }

/* ============================================
   DOWNLOAD / COMPARTILHAR
   ============================================ */
.dl-group { display: flex; gap: 0.5rem; margin-bottom: 0.4rem; }
.btn-dl {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: var(--radius-btn);
  font-size: 0.82rem; font-family: var(--font-body);
  border: 1px solid var(--border-mid); background: var(--white);
  cursor: pointer; transition: all 0.15s; color: var(--mid);
}
.btn-dl:hover { background: var(--azul-claro); border-color: var(--azul); color: var(--azul-escuro); }
.btn-dl svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-dl.btn-share svg { fill: currentColor !important; stroke: none !important; }

/* ============================================
   RESET ACTIONS
   ============================================ */
.reset-actions { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--border); }
.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: none; padding: 4px 0;
  font-family: var(--font-body); font-size: 0.74rem; color: var(--muted);
  cursor: pointer; text-align: left; align-self: flex-start; transition: color 0.12s;
}
.link-btn:hover { color: var(--dark); }
.link-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn-danger:hover { color: #b94343; }

/* ============================================
   BANNER RESTAURAÇÃO
   ============================================ */
.restore-banner {
  background: var(--azul-claro); border: 1px solid var(--azul);
  border-radius: var(--radius-md); padding: 0.8rem 1rem;
  margin-bottom: 1rem; animation: restore-slide-in 0.25s ease;
}
@keyframes restore-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.restore-banner-text { font-size: 0.82rem; color: var(--azul-escuro); margin-bottom: 0.6rem; line-height: 1.4; }
.restore-banner-actions { display: flex; gap: 0.4rem; }
.restore-btn { flex: 1; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 0.76rem; font-family: var(--font-body); cursor: pointer; border: 1px solid transparent; transition: all 0.12s; }
.restore-yes { background: var(--azul); color: white; }
.restore-yes:hover { background: var(--azul-escuro); }
.restore-no { background: transparent; color: var(--azul-escuro); border-color: var(--azul); }
.restore-no:hover { background: rgba(255,255,255,0.4); }

/* ============================================
   JÁ BAIXOU
   ============================================ */
.ja-baixou {
  display: flex; align-items: center; gap: 6px;
  background: #e8f5e8; color: #2d6a2d; border: 1px solid #4a9d4a;
  border-radius: var(--radius-md); padding: 8px 12px;
  font-size: 0.78rem; margin-bottom: 0.8rem;
}
.ja-baixou svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ============================================
   PREVIEW
   ============================================ */
.criar-preview {
  background: #e8e4de; display: flex;
  align-items: center; justify-content: center;
  padding: 2.5rem; min-height: calc(100vh - 64px);
}
.preview-frame {
  position: relative; box-shadow: var(--shadow-xl);
  border-radius: 4px; overflow: hidden; user-select: none;
}
.preview-frame.locked   { cursor: default; }
.preview-frame.unlocked { cursor: grab; }
.preview-frame.unlocked:active { cursor: grabbing; }

.reposicionar-pill {
  display: none; position: absolute; top: 10px; right: 10px;
  padding: 7px 12px; background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px); border: 1px solid var(--border);
  border-radius: 999px; font-size: 0.74rem; font-family: var(--font-body);
  color: var(--dark); cursor: pointer; box-shadow: var(--shadow-md);
  z-index: 10; align-items: center; gap: 5px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.reposicionar-pill.visible { display: inline-flex; }
.reposicionar-pill.active  { background: var(--azul); color: white; border-color: var(--azul); }
.reposicionar-pill svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.foto-loading {
  display: none; position: absolute; inset: 0;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(4px);
  z-index: 20; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--mid); font-family: var(--font-body); font-size: 0.85rem;
}
.foto-loading.visible { display: flex; }
.foto-loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--azul);
  border-radius: 50%; animation: foto-spin 0.8s linear infinite;
}
@keyframes foto-spin { to { transform: rotate(360deg); } }

#canvas-preview { display: block; max-width: 100%; max-height: calc(100vh - 5rem); }

.preview-hint { text-align: center; font-size: 0.72rem; color: var(--muted); margin-top: 0.8rem; }
.hint-mobile  { display: none; }
.hint-desktop { display: block; }

/* ============================================
   CROP CONTROLS
   ============================================ */
.crop-controls { display: flex; align-items: center; gap: 8px; margin-top: 0.6rem; }
.crop-slider {
  flex: 1; appearance: none; height: 4px;
  border-radius: 2px; background: var(--azul2); outline: none; cursor: pointer;
}
.crop-slider::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--azul);
  border: 2px solid white; box-shadow: var(--shadow-sm); cursor: pointer;
}
.crop-label { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }

/* ============================================
   MOBILE HEADER
   ============================================ */
.m-tabbar { display: none; }

/* ============================================
   MOBILE — MEDIA QUERY
   ============================================ */
@media (max-width: 900px) {
  html, body { overscroll-behavior-y: contain; }

  body { padding-bottom: 64px; }

  /* Topbar: logo centralizada no mobile, CTA menor */
  .topbar {
    height: 56px;
    padding: 0 12px;
    justify-content: center;
    position: relative;
  }
  .topbar-logo {
    position: absolute; left: 50%; transform: translateX(-50%);
  }
  .topbar-logo-campanha,
  .topbar-logo-fallback { height: 30px; }
  .topbar-cta {
    position: absolute; right: 12px;
    padding: 7px 12px; font-size: 0.74rem;
  }
  .topbar-cta svg { width: 12px; height: 12px; }

  .criar-wrap {
    margin-top: 56px;
    min-height: calc(100vh - 56px);
    grid-template-columns: 1fr;
    display: flex; flex-direction: column;
  }
  .criar-preview { order: 1; }
  .criar-painel  { order: 2; }

  .criar-preview {
    padding: 14px 12px; min-height: 0;
    background: #e8e4de; align-items: center;
  }
  .criar-preview > div { width: 100%; display: flex; flex-direction: column; align-items: center; }
  .preview-frame { max-width: 100%; }
  #canvas-preview { max-width: 100%; max-height: 42vh; }
  .preview-hint   { font-size: 0.68rem; margin-top: 0.4rem; }
  .hint-desktop   { display: none; }
  .hint-mobile    { display: block; }

  .criar-painel {
    position: static; height: auto; border-right: none;
    border-top: 1px solid var(--border);
    padding: 1.25rem 1.25rem 90px;
    overflow: visible; background: var(--white);
  }
  .criar-painel h1, .criar-painel-sub { display: none; }

  .step         { display: none; margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
  .step.active  { display: block; }
  .step .step-label { font-size: 0.7rem; margin-bottom: 0.8rem; }

  .grafismos-grid {
    display: flex; grid-template-columns: none;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    gap: 8px; padding-bottom: 6px;
    margin-left: -1.25rem; margin-right: -1.25rem;
    padding-left: 1.25rem; padding-right: 1.25rem;
    scrollbar-width: none;
  }
  .grafismos-grid::-webkit-scrollbar { display: none; }
  .grafismo-opt { flex: 0 0 auto; width: 90px; scroll-snap-align: start; }
  .grafismo-opt.none-opt { font-size: 0.68rem; padding: 0 6px; text-align: center; }

  .format-btn { padding: 0.9rem 0.5rem; }
  .pos-btn    { height: 44px; }
  .cor-opt    { width: 36px; height: 36px; }
  .btn-dl     { padding: 14px; font-size: 0.9rem; }
  .upload-zone { padding: 1.5rem 1rem; }

  .m-tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0;
    height: 64px; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--white); border-top: 1px solid var(--border);
    z-index: var(--z-sticky); gap: 2px;
  }
  .m-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; border: none; background: transparent; padding: 4px 2px;
    cursor: pointer; border-radius: var(--radius-sm);
    font-family: var(--font-body); color: var(--muted);
    transition: color 0.12s, background 0.12s; min-width: 0;
  }
  .m-tab:active { background: var(--light); }
  .m-tab-num {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--light); color: var(--muted);
    font-size: 0.7rem; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, color 0.12s;
  }
  .m-tab-label {
    font-size: 0.6rem; font-weight: 500; letter-spacing: 0.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  }
  .m-tab.active      { color: var(--azul-escuro); }
  .m-tab.active .m-tab-num { background: var(--azul); color: white; }
  .m-tab.done   .m-tab-num { background: var(--verde); color: white; }

  .toast-container { bottom: 80px !important; }
}
