html {
  font-size: 16px;
}

@media (max-width:1366px) {
  html {
    font-size: 12px;
  }
}

@media (max-width:768px) {
  html {
    font-size: 9px;
  }
}

body {
  margin: 0;
  height: 100%;
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
}

hr {
  /* Remove a borda 3D padrão feia do navegador */
  border: none;
  
  /* Define a altura da linha */
  height: 1px;
  
  /* Define a cor da linha (usei um cinza claro para combinar com o design) */
  background-color: #e0e0e0; 
  
  /* Garante que ocupe a largura total disponível */
  width: 100%;
  
  /* Adiciona um espaço em cima e embaixo para não colar no texto */
  margin-top: 20px;
}

* {
  box-sizing: border-box;
}

/* ===== LAYOUT ===== */

.app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ===== SIDEBAR (EDITOR) - BASE DESKTOP ===== */

.editor {
  width: 31.25rem;
  padding-top: 20px;
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 20px;
  background: #fff;
  box-shadow: 0.25rem 0 1.25rem rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: relative;
  z-index: 5;
}

.editor-content {
  display: flex;
  flex-direction: column;
}

.editor h3 {
  margin: 1.375rem 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.editor p {
  margin: 0.4375rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== RODAPÉ DA SIDEBAR (LINKS E LOGO) ===== */

/* 1. Container dos Links - AJUSTADO PARA DESKTOP */
.footer-links {
  display: flex;
  /* ALTERAÇÃO AQUI: space-between joga um para a esq e outro para a dir */
  justify-content: space-between; 
  align-items: center;
  width: 100%;
  
  margin-top: auto; 
  padding-bottom: 50px;
  padding-left: 50px; 
  padding-right: 50px;
  flex-shrink: 0;
}

/* 2. Container do Logo */
.logo-footer {
  display: flex;
  justify-content: center;
  text-align: center;
  width: 100%;
  flex-shrink: 0;
  padding-top: 40px; 
}

.logo-footer img {
  width: 80%;
  max-width: 180px;
}

/* ===== VIEWER ===== */

.viewer-area {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #f2f2f2, #bdbdbd);
  overflow: hidden;
}

.viewer-container {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  height: 100%;
  background-image: url(textures/ditalia-logo-bg.jpg);
  background-size: cover;
  background-position: center;
  background-color: transparent;
}

model-viewer {
  width: 100%;
  height: 100%;
}

/* ===== ESTILO DOS BOTÕES (LINKS) ===== */

.return-ditalia, 
.credit-logo {
  text-decoration: none;
  font-weight: bold;
  display: inline-block;
  cursor: pointer;
}

.return-ditalia p,
.credit-logo p {
  margin: 0;
  font-size: 1.2rem; 
  color: #000;
  background: #ffffffc8;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ===== LOADING OVERLAYS ===== */

#modelLoadingOverlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
}

#loadingOverlay {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 9999;
}

#loadingOverlay p {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.05em;
}

.loader {
  width: 42px;
  height: 42px;
  border: 4px solid #ddd;
  border-top: 4px solid #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.texture-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.texture-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.9);
  padding: 18px 26px;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.texture-loading-box p {
  margin: 0;
  font-weight: 600;
  color: #333;
  letter-spacing: 0.05em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* ===== UI ELEMENTS ===== */

.viewer-hint {
  position: absolute;
  padding: 1.875rem 1.875rem 0;
  bottom: 1.25rem;
  left: 50%;
  margin-bottom: 7rem;
  pointer-events: none;
  z-index: 5;
  font-size: 1rem;
}

.print-btn {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffffc8;
  border: none;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.print-btn img {
  width: 34px;
  height: 34px;
  pointer-events: none;
}

.color-palette {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  gap: 0.1875rem;
}

.color-swatch {
  width: 1.5625rem;
  aspect-ratio: 1/1;
  border-radius: 50%;
  cursor: pointer;
  border: 0.125rem solid #000;
  transition: .15s;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.selected {
  outline: 0.1875rem solid #000;
  outline-offset: 0.125rem;
}

.picker-wrapper {
  display: flex;
  justify-content: center;
  margin: 0.625rem 0 1.25rem;
}

.iro__colorPicker {
  border-radius: 1rem;
  border: 1.25rem 0;
  pointer-events: auto;
}

.color-picker {
  width: 60px !important;
}

.iro__wheel, .iro__slider, .iro__marker {
  pointer-events: auto !important;
}

.color-preview {
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  flex-direction: center;
  border-radius: 50%;
  border: 0.125rem solid #333;
  background: #222;
}

.selected-color {
  justify-content: center;
  align-self: center;
  margin: 2rem;
}

.texture-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.625rem;
}

.texture-grid img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: contain;
  border-radius: 0.625rem;
  cursor: pointer;
  background: #453a3a;
  padding: 0.375rem;
  border: 0.125rem solid #444;
  transition: .15s;
}

.texture-grid img:hover {
  transform: scale(1.05);
  border-color: #fff;
}

.texture-grid img.selected {
  border-color: #000;
  box-shadow: 0 0 0 0.125rem #000 inset;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin: 1.125rem 0;
}

.tab-btn {
  padding: 0.625rem;
  border: none;
  background: #11406F;
  cursor: pointer;
  font-weight: 700;
  border-radius: 0.5rem;
  font-size: 1.125rem;
  color: #fff;
}

.tab-btn.active {
  background: #0054b1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.toggle-panel-btn {
  position: fixed;
  top: 2rem;
  left: 2rem;
  z-index: 25;
  background: #11406F;
  color: #fff;
  border: none;
  padding: 0.625rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 2rem;
  cursor: pointer;
  display: none;
}

.hint-panel {
  display: block;
  position: fixed;
  top: 2rem;
  left: calc(2rem + 52px);
  z-index: 20;
  pointer-events: none;
  justify-content: center;
  color: #11406F;
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  padding: 0.35rem 0.6rem;
  border-radius: 0.4rem;
}

@media (min-width:601px) {
  .hint-panel p {
    display: none;
  }
}

/* =========================================================
   MEDIA QUERIES 
   ========================================================= */

/* --- TABLET (Até 1024px) --- */
@media (max-width: 1024px) {
  
  .editor {
    width: 38%;
    min-width: 260px;
    padding-top: 20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
  }
  .viewer-hint {
  position: absolute;
  padding: 1.875rem 1.875rem 0;
  bottom: 1.25rem;
  margin-bottom: 7rem;
  pointer-events: none;
  z-index: 5;
  font-size: 1.5rem;
}

  /* REVERTE PARA COLUNA NO TABLET (Empilhado) */
  .footer-links {
    display: flex;
    flex-direction: column; /* Sobrescreve o row do Desktop */
    justify-content: center; /* Sobrescreve o space-between do Desktop */
    align-items: center;    
    gap: 10px;              
    margin-top: auto;       
    padding-bottom: 20px;
    width: 100%;
  }

  /* Logo no Bottom com 120px de respiro */
  .logo-footer {
    width: 100%;
    margin: 0;
    padding-top: 80px !important; 
    padding-bottom: 20px !important; 
  }
  
  .logo-footer img {
    max-width: 140px; 
    margin-bottom: 0;
  }

  .return-ditalia, 
  .credit-logo {
    position: relative !important;
    left: auto !important; right: auto !important;
    bottom: auto !important; top: auto !important;
    text-align: center !important;
    display: block;
    width: auto;
  }

  .return-ditalia p,
  .credit-logo p {
    font-size: 1.4rem; 
    line-height: 1.2;
    padding: 6px 10px;
    background: transparent;
    color: #000;
  }
}

/* --- MOBILE (Até 600px) --- */
@media (max-width: 600px) {

  .editor {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    width: 85%;
    max-width: 21.25rem;
    transform: translateX(-100%);
    transition: .3s;
    z-index: 30;
  }

  .editor.open {
    transform: translateX(0);
  }

  .toggle-panel-btn {
    display: block;
  }

  .viewer-hint {
    bottom: 8rem;
    transform: translateX(-50%);
    font-size: 1.2rem;
    padding: 0.1rem 0.1rem 0;
    left: 50%;

  }

  .hint-panel p {
    display: block;
    margin-left: -20px;
  }

  /* --- RODAPÉ MOBILE --- */

  /* REVERTE PARA COLUNA NO MOBILE (Empilhado) */
  .footer-links {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Remove o espaçamento lateral do desktop */
    align-items: center;
    gap: 5px; 
    
    padding-bottom: 100px; 
    width: 100%;
  }

  .credit-logo, .return-ditalia {
    display: block !important;
    position: relative !important;
    left: auto !important; right: auto !important;
    bottom: auto !important; top: auto !important;
    text-align: center;
    opacity: 1;
  }

  .return-ditalia p,
  .credit-logo p {
    font-size: 1.4rem;
    background: transparent;
  }

  .logo-footer img {
    width: 80%;
    max-width: 200px;
  }
}