/*
 * ============================================================
 * SIMULADOR DE TATUAGENS — CSS COM FIX iOS Safari Viewport
 * ============================================================
 *
 * PROBLEMA RESOLVIDO:
 *   Safari iOS exibe uma toolbar inferior que reduz a viewport.
 *   O valor `vh` é calculado SEM a toolbar, então quando ela
 *   aparece o layout é espremido.
 *
 * FIXES APLICADOS:
 *   1. Variável CSS --vh atualizada via JavaScript (veja snippet abaixo)
 *   2. dvh como valor moderno (iOS 16+), com fallback para --vh
 *   3. translateY removido no mobile (desalinhava no iOS)
 *   4. Chave `}` de @media faltando foi corrigida
 *   5. overflow:hidden removido de html/body (causava bloqueio global de scroll)
 *
 * ============================================================
 * ADICIONE ESTE JAVASCRIPT NA PÁGINA (functions.php ou plugin):
 * ============================================================
 *
 *   function setRealViewportHeight() {
 *     var vh = window.innerHeight * 0.01;
 *     document.documentElement.style.setProperty('--vh', vh + 'px');
 *   }
 *   setRealViewportHeight();
 *   window.addEventListener('resize', setRealViewportHeight);
 *   window.addEventListener('orientationchange', setRealViewportHeight);
 *
 * ============================================================
 */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Roboto:wght@300;400&family=Oswald:wght@400;700&display=swap');
:root {
  --bg: #050505;
  --panel-bg: linear-gradient(180deg, #07070a 0%, rgba(7, 7, 10, 0.6) 100%);
  --card: rgba(10, 10, 12, 0.5);
  --dashed: rgba(255, 255, 255, 0.12);
  --muted: rgba(255, 255, 255, 0.9);
  --muted-2: rgba(255, 255, 255, 0.45);
  --accent-from: #b16bff;
  --accent-to: #ff6ec9;
  --btn-bg: rgba(255, 255, 255, 0.02);
  --btn-border: rgba(255, 255, 255, 0.08);
  --max-width: 100%;
  --font: "Oswald", "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  --cyan-gray: #a0c6a0;
  --cyan-bright: #00ffff;
  --active-tool: #00ffff;
  /* FIX iOS: valor inicial de --vh; será sobrescrito pelo JavaScript */
  --vh: 1vh;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  height: 100%;
  width: 100%;
  /* overflow, overscroll-behavior e touch-action removidos daqui
     para não bloquear o scroll global do site.
     Essas propriedades são aplicadas apenas dentro do simulador. */
}
.tattoo-simulator-container {
  overscroll-behavior: none; /* Previne bounce no container do simulador */
  touch-action: pan-y;       /* Permite scroll vertical mas previne zoom */
}
.simulador-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: auto;
  overflow: visible;
  padding: 0;
}
.upload-card {
  width: 100%;
  height: auto;
  max-height: calc(var(--vh, 1vh) * 92);   /* fallback iOS antigo */
  max-height: 92dvh;                        /* iOS 16+ (sobrescreve) */
  border-radius: 14px;
  padding: 6px;
  background: rgba(20, 10, 30, 0.5);
  box-shadow: 0 0 20px rgba(138, 43, 226, 0.4), 0 0 40px rgba(255, 0, 255, 0.2);
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  position: relative;
  z-index: 2;
  margin: 0;
  overflow: hidden; /* impede filhos de estourar o card */
}
.upload-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  border-radius: 16px;
  border: 2px dashed var(--dashed) !important;
  background: rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 12px;
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  box-sizing: border-box;
}
#editorArea {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.canvas-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
#canvas {
  width: 100% !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  display: block;
}
.upload-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-bottom: 0;
}
.upload-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.photo-options-clean {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 0;
}
.btn-clean-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--cyan-gray);
  transition: color 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
.btn-clean-icon svg,
.btn-clean-icon img {
  width: 28px;
  height: 28px;
  opacity: 0.75;
  transition: opacity 0.2s;
}
.btn-clean-icon svg,
.btn-clean-icon path {
  fill: currentColor !important;
}
.btn-clean-icon:active,
.btn-clean-icon:focus,
.btn-clean-icon:hover {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
  color: var(--cyan-gray) !important;
}
.btn-clean-icon:active svg,
.btn-clean-icon:focus svg,
.btn-clean-icon:hover svg {
  opacity: 1;
  background: transparent !important;
  outline: none !important;
  fill: var(--cyan-gray) !important;
  color: var(--cyan-gray) !important;
  filter: brightness(1.6);
}
/* BOTÕES EMPILHADOS */
.stacked-buttons {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.btn-triangle.stacked,
.btn-square-tool.stacked {
  width: 40px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(26, 26, 26);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  overflow: visible;
}
.btn-square-tool.stacked img {
  width: 14px;
  height: 14px;
  filter: brightness(0) invert(1);
}
.tool-active {
  background: rgba(0, 255, 255, 0.2) !important;
  border-color: var(--active-tool) !important;
}
.btn-triangle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.triangle {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  transition: border-color 0.2s;
}
.triangle.up {
  border-bottom: 7.5px solid var(--cyan-gray);
}
.triangle.down {
  border-top: 7.5px solid var(--cyan-gray);
}
.btn-triangle:active .triangle.up,
.btn-triangle:focus .triangle.up {
  border-bottom-color: #00ffff !important;
}
.btn-triangle:active .triangle.down,
.btn-triangle:focus .triangle.down {
  border-top-color: #00ffff !important;
}
/* BARRA DE BOTÕES - CORREÇÃO DEFINITIVA DE ALINHAMENTO */
.button-bar {
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  margin: 4px auto 0 auto;
  padding: 4px 0;
  position: relative;
  z-index: 100;
  min-height: 45px;
}
.btn-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.btn-group .buttons {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 3px;
}
.btn-label {
  font-family: 'Oswald', sans-serif !important;
  font-size: 0.65rem;
  color: #ffffff;
  text-transform: uppercase;
  text-align: center;
  width: 100%;
  font-weight: 400 !important;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
@media (min-width: 768px) {
  .button-bar {
    gap: 8px;
    padding: 2px 8px;
  }
  .btn.ghost, .btn.primary {
    padding: 3px 6px;
    font-size: 0.65rem;
    min-width: 45px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Oswald', sans-serif !important;
    font-weight: 400 !important;
  }
  #btn-redo, #btn-flip, #savePhotoBtn, #saveDesenhoBtn {
    margin: 0 !important;
  }
}
.btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'Oswald', sans-serif !important;
  font-weight: 400 !important;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.btn.primary {
  background: #1a1a1a;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
  z-index: 1;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--cyan-gray);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.btn.ghost:active,
.btn.ghost:focus {
  background: rgba(0, 255, 255, 0.1);
  color: #00ffff;
  border-color: rgba(0, 255, 255, 0.3);
}
/* BOTÃO ADICIONAR COM BORDA MULTICOLORIDA */
#btn-adicionar {
  position: relative;
  background: #1a1a1a;
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  color: #fff;
  font-family: 'Oswald', sans-serif !important;
  font-weight: 400 !important;
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 1;
  overflow: hidden;
  width: 60px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
}
#btn-adicionar::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(#ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff, #ff0000);
  animation: rotate-border 4s linear infinite;
  z-index: -2;
  filter: blur(8px);
}
#btn-adicionar::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: #1a1a1a;
  border-radius: 4px;
  z-index: -1;
}
@keyframes rotate-border {
  100% { transform: rotate(360deg); }
}
.btn.primary:active,
.btn.primary:focus {
  transform: scale(0.95);
  outline: none !important;
  box-shadow: none !important;
}
#btnClearEditor {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: #fff;
  width: auto;
  height: auto;
  padding: 5px;
  cursor: pointer;
  font-size: 32px;
  font-weight: bold;
  line-height: 1;
  z-index: 100;
  text-shadow: 0 0 5px rgba(0,0,0,0.8);
  transition: color 0.2s;
}
#btnClearEditor:hover {
  color: #ff7b7b;
}
.carousel-wrapper {
  position: absolute;
  top: 40px;
  height: 500px;
  width: 105px;
  z-index: 10;
  display: none;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  align-items: flex-start;
  padding: 10px 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
}
.carousel-wrapper.left { left: 5px; align-items: flex-start; }
.carousel-wrapper.right { right: 5px; align-items: flex-start; }
.btn-close-carousel {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  background: rgba(255, 68, 68, 0.8);
  border: none;
  border-radius: 50%;
  color: white;
  font-weight: bold;
  cursor: pointer;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  font-size: 14px;
  line-height: 1;
}
.btn-close-carousel:hover {
  background: #ff4444;
}
.folder-navigation-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 29px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}
.nav-arrow {
  background: transparent;
  border: none;
  color: #fff;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
}
.nav-arrow:hover {
  color: #aaa;
}
.carousel-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #fff;
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 4px;
  min-height: 29px;
}
#folder-name-display {
  color: #fff;
  font-family: 'Oswald', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  text-align: center;
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tattoo-carousel {
  position: relative;
  width: 100%;
  flex-grow: 1;
  overflow: hidden;
  pointer-events: auto;
  height: calc((92px * 5) + (8px * 4));
  max-height: calc((92px * 5) + (8px * 4));
}
@media (max-width: 767px) {
  .tattoo-carousel {
    height: calc((70px * 5) + (8px * 4));
    max-height: calc((70px * 5) + (8px * 4));
  }
  .carousel-wrapper {
    height: 400px;
  }
}
.carousel-track {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  cursor: grab;
  align-items: flex-start;
}
.carousel-item {
  width: 92px;
  height: 92px;
  margin: 0;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.8;
}
@media (max-width: 767px) {
  .carousel-item {
    width: 70px;
    height: 70px;
  }
}
.carousel-item:active {
  cursor: grabbing;
}
.carousel-item.active {
  opacity: 1;
  transform: scale(1.2);
  z-index: 2;
}
.carousel-item img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  transition: opacity 0.3s;
  pointer-events: none;
}
/* SLIDER DE OPACIDADE */
.opacity-slider-container {
  width: 100%;
  max-width: 342px;
  margin: -4px auto 4px auto;
  padding: 0 8px;
  position: relative;
  z-index: 10;
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  background: transparent;
}
.opacity-slider-container.visible {
  display: flex;
}
.opacity-slider-label {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  font-family: 'Oswald', sans-serif;
  font-weight: 400;
}
.opacity-slider-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}
#opacitySlider {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.3));
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
#opacitySlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.8);
}
#opacitySlider::-webkit-slider-thumb:hover {
  background: rgba(255, 255, 255, 0.8);
}
#opacitySlider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid rgba(255, 255, 255, 0.8);
}
#opacitySlider::-moz-range-thumb:hover {
  background: rgba(255, 255, 255, 0.8);
}
.opacity-value {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.6);
  min-width: 28px;
  text-align: right;
  font-family: 'Oswald', sans-serif;
  font-weight: 400;
}
/* PINTEREST FOOTER - ALONGADO EM TODA EXTENSÃO */
.pinterest-fixed-footer {
  width: 100% !important;
  max-width: 100% !important;
  margin-top: 8px;
  padding: 0 4px;
}
.pinterest-fixed-footer > div {
  width: 100% !important;
  display: flex !important;
  background: #141414;
  border-radius: 12px;
  padding: 0 10px;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  height: 32px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
#pinterestSearch {
  flex: 1 !important;
  width: 100% !important;
  border: none;
  background: transparent;
  outline: none;
  padding: 4px;
  font-size: 12px;
  color: #fff;
  font-family: 'Oswald', sans-serif !important;
}
/* ============================================================
   MOBILE — FIX iOS Safari Viewport
   ============================================================ */
@media (max-width: 767px) {
  .simulador-container { transform: none; }
  .upload-card {
    height: auto;
    max-height: calc(var(--vh, 1vh) * 92);
    max-height: 92dvh;
    gap: 0;
    padding: 4px;
  }
  .upload-area { min-height: 0; flex: 1; flex-grow: 4; }
  .btn-clean-icon svg { width: 34px; height: 34px; }
  .carousel-wrapper { width: 80px; }
  .tattoo-carousel { height: 226px; }
  .carousel-item { width: 70px; height: 70px; }
  #btn-adicionar {
    width: 100px;
    height: 40px;
  }
  .button-bar {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    gap: 4px !important;
    align-items: center !important;
    margin-top: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
  }
  .btn-group {
    gap: 0;
  }
  .btn-label {
    margin-bottom: 0;
    font-size: 0.55rem;
  }
  .btn-group.generate .buttons {
    flex-direction: row;
  }
  .btn-group.edit .buttons,
  .btn-group.process .buttons {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
  }
  .btn-group.edit .btn,
  .btn-group.process .btn {
    width: auto;
    min-width: 60px;
    max-width: 95px;
    text-align: center;
    padding: 2px 6px;
    font-family: 'Oswald', sans-serif !important;
    font-weight: 400 !important;
    background: rgb(26, 26, 26);
    border: 1px solid rgba(255,255,255,0.12);
    color: #ffffff !important;
  }
  #btn-redo, #savePhotoBtn {
    margin-top: 0;
    align-self: center;
  }
  .opacity-slider-container {
    margin: 0 auto;
    padding: 0 8px;
  }
  .pinterest-fixed-footer {
    margin-top: 1px;
    padding: 0 2px;
  }
  .pinterest-fixed-footer > div {
    height: 26px;
  }
  #pinterestSearch {
    font-size: 16px !important;
    font-family: 'Oswald', 'Arial Narrow', sans-serif-condensed, sans-serif !important;
    letter-spacing: -0.2px;
    padding-left: 6px;
    padding-right: 6px;
  }
}