/* RUNA Admin — layout e componentes do painel (tema escuro RUNA) */

.adm-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.adm-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.5);
  position: sticky;
  top: 0;
  height: 100vh;
}

.adm-sidebar-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.adm-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  gap: 0.125rem;
  flex: 1;
}

.adm-nav a {
  padding: 0.5rem 0.75rem;
  font-size: 0.6875rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-radius: calc(var(--radius) - 4px);
  transition: color 0.2s, background-color 0.2s;
}

.adm-nav a:hover {
  color: hsl(var(--foreground));
}

.adm-nav a.active {
  color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
}

.adm-sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
}

.adm-main {
  padding: 2rem 2.5rem 4rem;
  max-width: 1100px;
  width: 100%;
}

@media (max-width: 860px) {
  .adm-layout { grid-template-columns: 1fr; }
  .adm-sidebar { position: static; height: auto; }
  .adm-nav { flex-direction: row; flex-wrap: wrap; }
  .adm-main { padding: 1.25rem 1rem 3rem; }
}

/* ---------- componentes ---------- */

.adm-title {
  font-family: Cinzel, serif;
  font-size: 1.375rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.adm-subtitle {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 1.75rem;
}

.adm-card {
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--card));
  padding: 1.25rem;
}

.adm-stats {
  display: grid;
  /* auto-fit estica os cards para ocupar toda a largura (sem colunas vazias) */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.adm-stat .label {
  font-size: 0.625rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  display: block;
  margin-bottom: 0.375rem;
}

.adm-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--primary));
}

.adm-table {
  width: 100%;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  font-size: 0.8125rem;
}

.adm-table th {
  text-align: left;
  font-size: 0.625rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--secondary) / 0.6);
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid hsl(var(--border));
}

.adm-table td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

.adm-table tr:last-child td { border-bottom: 0; }

.adm-table tbody tr { transition: background-color 0.15s; }
.adm-table tbody tr:hover { background: hsl(var(--secondary) / 0.3); }
.adm-table tbody tr.clickable { cursor: pointer; }

.adm-badge {
  display: inline-block;
  padding: 0.1875rem 0.5rem;
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.adm-badge.green  { color: #4ade80; background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.3); }
.adm-badge.yellow { color: #facc15; background: rgba(250, 204, 21, 0.08); border-color: rgba(250, 204, 21, 0.3); }
.adm-badge.red    { color: #f87171; background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.3); }
.adm-badge.gray   { color: hsl(var(--muted-foreground)); background: hsl(var(--secondary) / 0.5); border-color: hsl(var(--border)); }
.adm-badge.gold   { color: hsl(var(--primary)); background: hsl(var(--primary) / 0.08); border-color: hsl(var(--primary) / 0.3); }

.adm-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  transition: opacity 0.2s;
  cursor: pointer;
}

.adm-btn:hover { opacity: 0.9; }
.adm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.adm-btn.ghost {
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  font-weight: 500;
}

.adm-btn.ghost:hover { border-color: hsl(var(--primary)); color: hsl(var(--primary)); opacity: 1; }

.adm-btn.danger {
  background: transparent;
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
  font-weight: 500;
}

.adm-btn.danger:hover { background: rgba(248, 113, 113, 0.1); opacity: 1; }

/* botão-ícone (ex.: lixeira) — discreto, fica vermelho no hover */
.adm-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  vertical-align: middle;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  color: hsl(var(--muted-foreground));
  background: transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

.adm-icon-btn.danger:hover {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
  background: rgba(248, 113, 113, 0.08);
}

/* chips de mídia na listagem de produtos */
.adm-media-tags { display: inline-flex; gap: 0.3125rem; align-items: center; }

.adm-media-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.adm-media-tag.gold { color: hsl(var(--primary)); border-color: hsl(var(--primary) / 0.4); }

.adm-input, .adm-select, .adm-textarea {
  width: 100%;
  background: hsl(var(--secondary) / 0.6);
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.adm-input:focus, .adm-select:focus, .adm-textarea:focus {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 1px hsl(var(--primary));
}

.adm-select option { background: hsl(var(--card)); color: hsl(var(--foreground)); }

.adm-textarea { min-height: 110px; resize: vertical; }

.adm-label {
  display: block;
  font-size: 0.625rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.375rem;
}

.adm-field { margin-bottom: 1rem; }

.adm-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.adm-toolbar .spacer { flex: 1; }

/* modal */
.adm-modal-overlay {
  position: fixed;
  inset: 0;
  background: hsl(var(--background) / 0.7);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1rem;
  overflow-y: auto;
}

.adm-modal {
  width: 100%;
  max-width: 640px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 1.5rem;
  animation: fade-in 0.25s ease-out;
}

.adm-modal h3 {
  font-family: Cinzel, serif;
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

/* toast */
.adm-toast {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--primary) / 0.4);
  color: hsl(var(--foreground));
  border-radius: calc(var(--radius) - 4px);
  padding: 0.75rem 0.875rem 0.75rem 1rem;
  font-size: 0.9375rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: fade-in 0.2s ease-out;
  max-width: 420px;
}

.adm-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.15);
  color: hsl(var(--primary));
  font-weight: 700;
  font-size: 0.8125rem;
  flex: none;
}

.adm-toast-msg { flex: 1; }

.adm-toast-close {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 1.125rem;
  line-height: 1;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: 4px;
}
.adm-toast-close:hover { color: hsl(var(--foreground)); }

.adm-toast.error { border-color: rgba(248, 113, 113, 0.5); }
.adm-toast.error .adm-toast-icon { background: rgba(248, 113, 113, 0.15); color: #f87171; }

/* miniaturas de imagens do produto */
.adm-thumbs { display: flex; flex-wrap: wrap; gap: 0.625rem; }

.adm-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
}

.adm-thumb img, .adm-thumb video { width: 100%; height: 100%; object-fit: cover; }

.adm-thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--primary));
  font-size: 14px;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.adm-thumb-spin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: hsl(var(--secondary) / 0.6);
  color: hsl(var(--primary));
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ---------- galeria de mídia do produto (dropzone + reordenar) ---------- */
.adm-media-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.adm-thumb-drag { cursor: grab; transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s; }
.adm-thumb-drag:hover { box-shadow: 0 0 0 1px hsl(var(--primary) / 0.5); }
.adm-thumb-dragging { opacity: 0.4; cursor: grabbing; }

.adm-cover-badge {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  text-align: center;
  background: hsl(var(--primary) / 0.9);
  color: hsl(var(--primary-foreground));
  font-size: 0.5625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0.125rem 0;
  pointer-events: none;
}

.adm-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  padding: 1.75rem 1rem;
  border: 1.5px dashed hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--secondary) / 0.25);
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
  text-align: center;
}

.adm-dropzone:hover { border-color: hsl(var(--primary) / 0.6); color: hsl(var(--foreground)); }

.adm-dropzone.adm-dropzone-over {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
}

.adm-dropzone-title { font-size: 0.875rem; font-weight: 500; }
.adm-dropzone-sub { font-size: 0.75rem; opacity: 0.8; }

.adm-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  line-height: 1;
  font-size: 11px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #f87171;
  cursor: pointer;
}

.adm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.adm-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.adm-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }

@media (max-width: 640px) {
  .adm-grid-2, .adm-grid-3, .adm-grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Configurações: sub-abas + layout mais largo ---------- */
.adm-subtabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  margin-bottom: 1.75rem;
}

.adm-subtabs button {
  padding: 0.75rem 1.5rem;
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.adm-subtabs button:hover { color: hsl(var(--foreground)); }
.adm-subtabs button.active { color: hsl(var(--primary)); border-bottom-color: hsl(var(--primary)); }

.adm-settings-wrap { max-width: 920px; }

.adm-mini-label {
  display: block;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.25rem;
}

.adm-img-cell {
  width: 44px;
  min-width: 44px; /* impede a tabela de comprimir e distorcer a miniatura */
  height: 44px;
  object-fit: cover;
  flex: none;
  display: block;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid hsl(var(--border));
}

.adm-empty {
  text-align: center;
  padding: 3rem 1rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  background: hsl(var(--secondary) / 0.2);
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.adm-section-title {
  font-size: 0.8125rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin: 1.75rem 0 0.875rem;
}

code.adm-pix {
  display: block;
  font-size: 0.6875rem;
  word-break: break-all;
  background: hsl(var(--secondary) / 0.3);
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 4px);
  padding: 0.75rem;
  color: hsl(var(--foreground) / 0.7);
}

/* ---------- Ajustes de legibilidade (fontes maiores + conteúdo mais largo) ---------- */

.adm-layout { grid-template-columns: 260px 1fr; }

.adm-main {
  max-width: none;
  padding: 2.25rem 3rem 4rem;
}

.adm-nav a {
  font-size: 0.875rem;
  padding: 0.6875rem 0.875rem;
}

.adm-sidebar-foot { font-size: 1rem; }
.adm-sidebar-foot a, .adm-sidebar-foot button { font-size: 0.9375rem; }

.adm-title { font-size: 1.75rem; }
.adm-subtitle { font-size: 1rem; }

.adm-stats { gap: 1.25rem; }
.adm-card.adm-stat { padding: 1.5rem 1.75rem; min-height: 130px; display: flex; flex-direction: column; justify-content: center; }
.adm-stat .label { font-size: 0.8125rem; margin-bottom: 0.625rem; }
.adm-stat .value { font-size: 2.25rem; }

.adm-table { font-size: 1rem; }
.adm-table th { font-size: 0.78125rem; padding: 0.8125rem 1rem; }
.adm-table td { padding: 0.8125rem 1rem; }

.adm-badge { font-size: 0.75rem; padding: 0.28125rem 0.6875rem; }

.adm-btn { font-size: 0.84375rem; padding: 0.6875rem 1.5rem; }

.adm-input, .adm-select, .adm-textarea { font-size: 1rem; padding: 0.6875rem 0.9375rem; }

.adm-label { font-size: 0.78125rem; margin-bottom: 0.5rem; }

.adm-modal { max-width: 800px; padding: 1.875rem; }
.adm-modal h3 { font-size: 1.4375rem; }

.adm-toast { font-size: 1rem; }
.adm-empty { font-size: 1rem; }
.adm-section-title { font-size: 1rem; }
.adm-img-cell { width: 56px; min-width: 56px; height: 56px; }
/* a célula da miniatura não estica mesmo com título em 2 linhas */
.adm-table td.adm-img-td { width: 56px; padding-right: 0; }
.adm-thumb { width: 92px; height: 92px; }

@media (max-width: 860px) {
  .adm-main { padding: 1.25rem 1rem 3rem; }
}

/* ===================== Correções visuais + mobile ===================== */

/* Toast escondido realmente some. Antes .adm-toast{display:flex} (admin.css, carregado
   depois) vencia .hidden{display:none} (runa.css) no cascade → um quadro cinza de borda
   dourada vazio ficava fixo no canto inferior direito de todas as telas. */
.adm-toast.hidden { display: none; }

/* Topo mobile e overlay só existem no mobile — escondidos no desktop (não entram no grid). */
.adm-topbar { display: none; }
.adm-overlay { display: none; }

@media (max-width: 860px) {
  /* desfaz o grid de 2 colunas (a regra de legibilidade .adm-layout{260px 1fr} vinha
     sobrescrevendo o breakpoint antigo); com display:block tudo empilha */
  .adm-layout { display: block; }

  /* barra superior fixa com o botão de menu (hambúrguer) */
  .adm-topbar {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0.6875rem 1rem;
    background: hsl(var(--card) / 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid hsl(var(--border));
  }
  .adm-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.375rem;
    height: 2.375rem;
    flex: none;
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 4px);
    color: hsl(var(--foreground));
    background: transparent;
    cursor: pointer;
  }
  .adm-menu-btn:hover { border-color: hsl(var(--primary) / 0.6); color: hsl(var(--primary)); }

  /* menu lateral vira gaveta deslizante a partir da esquerda */
  .adm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: min(82vw, 300px);
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    background: hsl(var(--card));
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  .adm-drawer-open .adm-sidebar { transform: translateX(0); }

  /* navegação vertical dentro da gaveta (desfaz o row-wrap do breakpoint antigo) */
  .adm-nav { flex-direction: column; flex-wrap: nowrap; padding: 1rem 0.75rem; }

  /* fundo escuro clicável quando a gaveta está aberta */
  .adm-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .adm-drawer-open .adm-overlay { opacity: 1; pointer-events: auto; }

  /* conteúdo ocupa a largura toda */
  .adm-main { max-width: none; padding: 1.25rem 1rem 3rem; }

  /* tabelas largas rolam na horizontal em vez de estourar a tela */
  .adm-table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .adm-table { min-width: 560px; }

  /* sub-abas de Configurações rolam se não couberem */
  .adm-subtabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .adm-subtabs button { white-space: nowrap; padding: 0.75rem 1rem; }

  .adm-title { font-size: 1.5rem; }
}
