/* =====================================================
   VTi CELL — PAINEL ADMINISTRATIVO
   Arquivo: admin.css
   ===================================================== */

/* ---------- VARIÁVEIS ---------- */

:root {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;

  --navy: #031735;
  --navy-light: #102b50;
  --gold: #d5ad55;
  --gold-hover: #c49a3e;

  --text: #172033;
  --muted: #697386;
  --line: #e2e7ef;

  --success: #217a4b;
  --danger: #b42318;
  --warning: #9a6700;

  --radius: 14px;
  --radius-small: 9px;

  --shadow:
    0 8px 28px rgba(3, 23, 53, 0.07);

  --transition: 180ms ease;
}

/* ---------- RESET ---------- */

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Figtree", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid rgba(213, 173, 85, 0.65);
  outline-offset: 3px;
}

/* ---------- LAYOUT PRINCIPAL ---------- */

.wrap {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 32px 24px 56px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.brand-area {
  min-width: 0;
}

.brand {
  width: auto;
  height: 54px;
  max-width: 180px;
  margin-bottom: 16px;
  object-fit: contain;
  object-position: left center;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  color: var(--navy);
  font-family: "Young Serif", serif;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 400;
  line-height: 1.15;
}

h3 {
  margin-bottom: 22px;
  color: var(--navy);
  font-family: "Young Serif", serif;
  font-size: 25px;
  font-weight: 400;
}

.sub {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

main {
  min-width: 0;
}

/* ---------- BOTÕES ---------- */

button {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--navy);
  font-weight: 600;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
}

button:hover:not(:disabled) {
  border-color: #b8c2d1;
  background: #f0f3f8;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button.primary {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(3, 23, 53, 0.12);
}

button.primary:hover:not(:disabled) {
  border-color: var(--navy-light);
  background: var(--navy-light);
}

button.chip {
  white-space: nowrap;
}

/* ---------- BUSCA E FILTROS ---------- */

.bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #d7deea;
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

input,
select {
  min-height: 44px;
  padding: 10px 12px;
}

textarea {
  min-height: 90px;
  padding: 12px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #929bad;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b5c0d1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold-hover);
  outline: none;
  box-shadow: 0 0 0 3px rgba(213, 173, 85, 0.16);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chips button {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.chips button.active,
.chips button[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.count {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- GRADE DE PRODUTOS ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.grid:empty::before {
  content: "Nenhum produto para exibir.";
  grid-column: 1 / -1;
  display: block;
  padding: 40px 20px;
  border: 1px dashed #cbd4e2;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

/* Cartões criados pelo JavaScript */

.grid > * {
  min-width: 0;
}

.card,
.product-card,
.produto-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(3, 23, 53, 0.025);
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
}

.card:hover,
.product-card:hover,
.produto-card:hover {
  border-color: #d2b66f;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card img,
.product-card img,
.produto-card img {
  width: 100%;
  height: 190px;
  background: var(--surface-soft);
  object-fit: contain;
}

.card-body,
.product-info,
.produto-info {
  padding: 14px;
}

.card h3,
.product-card h3,
.produto-card h3 {
  margin: 0 0 8px;
  font-family: "Figtree", sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card p,
.product-card p,
.produto-card p {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.price {
  color: var(--navy);
  font-size: 19px;
  font-weight: 700;
}

/* ---------- JANELAS DE DIÁLOGO ---------- */

dialog {
  width: min(500px, calc(100% - 28px));
  max-width: 100%;
  max-height: min(88vh, 850px);
  padding: 26px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(3, 23, 53, 0.22);
}

dialog::backdrop {
  background: rgba(3, 16, 36, 0.62);
  backdrop-filter: blur(3px);
}

dialog form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

dialog label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}

dialog label input,
dialog label select,
dialog label textarea {
  color: var(--text);
  font-weight: 400;
}

dialog .sub {
  margin-top: -8px;
  font-size: 12px;
}

.dlgacts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.dlgacts button {
  min-width: 100px;
}

.err {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.err:empty {
  display: none;
}

/* ---------- PRÉ-VISUALIZAÇÃO DE FOTOS ---------- */

.thumbs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.thumbs img {
  width: 100%;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  object-fit: contain;
}

/* ---------- LISTA DE CATEGORIAS ---------- */

.catlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.catlist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface-soft);
  overflow-wrap: anywhere;
}

.catlist li button {
  flex-shrink: 0;
  min-height: 32px;
  padding: 5px 9px;
  color: var(--danger);
  font-size: 12px;
}

/* ---------- ESTADOS DE CARREGAMENTO ---------- */

.loading,
.empty,
.error {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.error {
  color: var(--danger);
}

/* ---------- TABLETS ---------- */

@media (max-width: 850px) {
  .wrap {
    padding: 24px 18px 40px;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .card img,
  .product-card img,
  .produto-card img {
    height: 160px;
  }

  .bar {
    grid-template-columns: minmax(0, 1fr) 150px;
  }

  .bar .chip {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

/* ---------- CELULARES ---------- */

@media (max-width: 560px) {
  .wrap {
    padding: 18px 12px 32px;
  }

  header {
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 22px;
  }

  .brand {
    height: 42px;
    max-width: 130px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 29px;
  }

  .sub {
    font-size: 12px;
  }

  header > button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .bar {
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 8px;
  }

  .bar input,
  .bar select {
    min-height: 41px;
    padding: 8px;
    font-size: 13px;
  }

  .bar .chip {
    min-height: 35px;
  }

  .chips {
    gap: 6px;
  }

  .chips button {
    min-height: 31px;
    padding: 5px 10px;
    font-size: 12px;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .card,
  .product-card,
  .produto-card {
    border-radius: 10px;
  }

  .card img,
  .product-card img,
  .produto-card img {
    height: 112px;
  }

  .card-body,
  .product-info,
  .produto-info {
    padding: 8px;
  }

  .card h3,
  .product-card h3,
  .produto-card h3 {
    font-size: 12px;
  }

  .card p,
  .product-card p,
  .produto-card p {
    font-size: 11px;
  }

  .price {
    font-size: 14px;
  }

  dialog {
    padding: 20px 16px;
    border-radius: 15px;
  }

  h3 {
    font-size: 22px;
  }

  .thumbs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .thumbs img {
    height: 55px;
  }

  .dlgacts {
    gap: 8px;
  }

  .dlgacts button {
    min-width: 0;
    flex: 1;
  }
}

/* ---------- CELULARES MUITO PEQUENOS ---------- */

@media (max-width: 360px) {
  .wrap {
    padding-right: 8px;
    padding-left: 8px;
  }

  .grid {
    gap: 6px;
  }

  .card img,
  .product-card img,
  .produto-card img {
    height: 90px;
  }

  .card h3,
  .product-card h3,
  .produto-card h3 {
    font-size: 11px;
  }
}

/* ---------- ACESSIBILIDADE ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =====================================================
   VTi CELL — LAYOUT DOS PRODUTOS
   Compatível com as classes geradas pelo admin.js
   ===================================================== */

/* Cartão completo */
.grid > .card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Área das fotos */
.card .media {
  position: relative;
  width: 100%;
  height: 220px;
  overflow: hidden;
  background: var(--surface-soft);
}

.card .media > img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 12px;
  object-fit: contain;
}

/* Botões para trocar as fotos */
.card .media .nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  width: 36px;
  min-height: 36px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(3, 23, 53, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--navy);
  font-size: 23px;
  line-height: 1;
  transform: translateY(-50%);
  box-shadow: 0 2px 8px rgba(3, 23, 53, 0.10);
}

.card .media .nav:hover {
  background: var(--navy);
  color: #fff;
}

.card .media .prev {
  left: 10px;
}

.card .media .next {
  right: 10px;
}

/* Contador de fotos */
.card .media .pcount {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 9px;
  border: 1px solid rgba(3, 23, 53, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
}

/* Produto sem foto */
.card .media .ph {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--gold);
  font-family: "Young Serif", serif;
  font-size: 48px;
}

/* Informações do produto */
.card .body {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  padding: 16px;
}

.card .body .cat {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.card .body .name {
  margin: 0;
  color: var(--navy);
  font-family: "Figtree", sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card .body .desc {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.card .body .price {
  margin-top: 3px;
  color: var(--navy);
  font-size: 20px;
  font-weight: 700;
}

/* ---------- BOTÕES EDITAR E EXCLUIR (LADO A LADO) ---------- */

/* Container que coloca Editar e Excluir na mesma linha */
.card .body .card-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
  padding: 0;
}

/* Cada botão ocupa metade da largura do card */
.card .body .card-actions button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}

/* Botão Excluir em vermelho suave */
.card .body .card-actions button.del {
  border-color: #f0c9c6;
  background: #fff;
  color: var(--danger);
}

.card .body .card-actions button.del:hover:not(:disabled) {
  border-color: var(--danger);
  background: #fff3f2;
}

/* Estado vazio da grade */
.grid > .empty {
  grid-column: 1 / -1;
  padding: 32px 20px;
  border: 1px dashed #cbd4e2;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

/* Ajustes para tablets */
@media (max-width: 850px) {
  .card .media {
    height: 180px;
  }

  .card .body {
    padding: 12px;
  }
}

/* Ajustes para celulares */
@media (max-width: 560px) {
  .card .media {
    height: 145px;
  }

  .card .media > img {
    padding: 6px;
  }

  .card .media .nav {
    width: 28px;
    min-height: 28px;
    font-size: 19px;
  }

  .card .media .prev {
    left: 5px;
  }

  .card .media .next {
    right: 5px;
  }

  .card .media .pcount {
    right: 5px;
    bottom: 5px;
    padding: 3px 6px;
    font-size: 10px;
  }

  .card .body {
    gap: 7px;
    padding: 9px;
  }

  .card .body .cat {
    padding: 3px 6px;
    font-size: 10px;
  }

  .card .body .name {
    font-size: 13px;
  }

  .card .body .desc {
    font-size: 11px;
  }

  .card .body .price {
    font-size: 15px;
  }

  .card .body .card-actions {
    gap: 5px;
  }

  .card .body .card-actions button {
    min-height: 34px;
    padding: 6px 4px;
    font-size: 11px;
  }
}

/* Celulares muito pequenos */
@media (max-width: 360px) {
  .card .media {
    height: 110px;
  }

  .card .body {
    padding: 7px;
  }

  .card .body .name {
    font-size: 12px;
  }

  .card .body .card-actions button {
    min-height: 32px;
    font-size: 10px;
  }
}
