/* =============================================================
   PAINEL.CSS — Sistema visual das páginas internas
   MarketPlace Rural (Início, Meus Produtos, Pedidos,
   Negociações, Estoque, Favoritos, Configurações).

   Mesma linguagem da apresentação, do login e do cadastro:
   paleta de tokens.css, Lora + Inter, raios orgânicos,
   sombras suaves e animações discretas.

   Ordem de carregamento: tokens.css → painel.css → <página>.css
   O tema escuro continua controlado por body.dark (JS de cada página).
   ============================================================= */

/* ── Variáveis ───────────────────────────────────────────── */
:root {
  --mp-fundo:        var(--off-white);
  --mp-fundo-alt:    var(--bege);
  --mp-superficie:   #ffffff;
  --mp-superficie-2: #fbf8f2;
  --mp-texto:        #1d261c;
  --mp-suave:        #5b6657;
  --mp-titulo:       var(--verde-escuro);
  --mp-destaque:     var(--verde-medio);
  --mp-terra:        var(--terra);
  --mp-linha:        #e8dfcf;
  --mp-linha-forte:  #cfc1a8;
  --mp-nevoa:        var(--verde-nevoa);
  --mp-trigo-suave:  #f3e8d2;
  --mp-campo:        #fffdf9;
  --mp-erro:         #b3261e;
  --mp-erro-fundo:   rgba(179, 38, 30, .08);
  --mp-alerta:       #9a5b00;
  --mp-alerta-fundo: rgba(214, 137, 16, .14);
  --mp-info:         #2f5f8a;
  --mp-info-fundo:   rgba(47, 95, 138, .1);

  --mp-menu-fundo:   var(--verde-escuro);
  --mp-menu-texto:   rgba(243, 236, 224, .78);

  --mp-sombra:       0 30px 60px -30px rgba(31, 58, 29, .35);
  --mp-sombra-sm:    0 14px 30px -18px rgba(31, 58, 29, .3);
  --mp-sombra-card:  0 1px 2px rgba(31, 58, 29, .05), 0 10px 28px -20px rgba(31, 58, 29, .28);

  --topo-h:          72px;
  --menu-w:          256px;
  --ease:            cubic-bezier(.2, .7, .2, 1);

  --grao: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32  0 0 0 0 .24  0 0 0 0 .14  0 0 0 .08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --curvas-claras: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='400' viewBox='0 0 600 400' fill='none' stroke='white' stroke-opacity='.06' stroke-width='1.2'><path d='M-20 80 C 120 20, 220 140, 360 90 S 560 30, 640 80'/><path d='M-20 130 C 120 70, 220 190, 360 140 S 560 80, 640 130'/><path d='M-20 180 C 120 120, 220 240, 360 190 S 560 130, 640 180'/><path d='M-20 230 C 120 170, 220 290, 360 240 S 560 180, 640 230'/><path d='M-20 280 C 120 220, 220 340, 360 290 S 560 230, 640 280'/><path d='M-20 330 C 120 270, 220 390, 360 340 S 560 280, 640 330'/></svg>");
  --curvas-verdes: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='400' viewBox='0 0 600 400' fill='none' stroke='%234f772d' stroke-opacity='.12' stroke-width='1.2'><path d='M-20 80 C 120 20, 220 140, 360 90 S 560 30, 640 80'/><path d='M-20 130 C 120 70, 220 190, 360 140 S 560 80, 640 130'/><path d='M-20 180 C 120 120, 220 240, 360 190 S 560 130, 640 180'/><path d='M-20 230 C 120 170, 220 290, 360 240 S 560 180, 640 230'/><path d='M-20 280 C 120 220, 220 340, 360 290 S 560 230, 640 280'/></svg>");
}

/* Tema escuro: body.dark (scripts das páginas) ou html.tema-escuro-pre
   (aplicado pelo painel.js antes da primeira pintura, para não piscar) */
body.dark,
html.tema-escuro-pre body {
  --mp-fundo:        #0f150e;
  --mp-fundo-alt:    #151d13;
  --mp-superficie:   #1a2318;
  --mp-superficie-2: #1f2a1c;
  --mp-texto:        #e6eadc;
  --mp-suave:        #a6b09c;
  --mp-titulo:       #f4efe3;
  --mp-destaque:     #a7c777;
  --mp-terra:        #d8ae80;
  --mp-linha:        #2a3626;
  --mp-linha-forte:  #3c4a37;
  --mp-nevoa:        rgba(144, 169, 85, .14);
  --mp-trigo-suave:  rgba(196, 154, 108, .14);
  --mp-campo:        #141c12;
  --mp-erro:         #f08a80;
  --mp-erro-fundo:   rgba(240, 138, 128, .1);
  --mp-alerta:       #f0c26b;
  --mp-alerta-fundo: rgba(240, 194, 107, .12);
  --mp-info:         #8fbbe3;
  --mp-info-fundo:   rgba(143, 187, 227, .12);

  --mp-menu-fundo:   #0b110a;
  --mp-menu-texto:   rgba(230, 234, 220, .72);

  --mp-sombra:       0 30px 60px -30px rgba(0, 0, 0, .75);
  --mp-sombra-sm:    0 14px 30px -18px rgba(0, 0, 0, .65);
  --mp-sombra-card:  0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -20px rgba(0, 0, 0, .7);

  color-scheme: dark;
}

/* ── Base ────────────────────────────────────────────────── */
[hidden],
.hidden {
  display: none !important;
}

html {
  scroll-padding-top: calc(var(--topo-h) + 16px);
}

body {
  min-height: 100vh;
  background:
    var(--grao),
    radial-gradient(45% 35% at 100% 0%, rgba(144, 169, 85, .12), transparent 70%),
    radial-gradient(40% 35% at 30% 100%, rgba(196, 154, 108, .1), transparent 70%),
    var(--mp-fundo);
  background-attachment: fixed;
  color: var(--mp-texto);
  font-family: var(--fonte-corpo);
  font-size: 15px;
  line-height: 1.55;
}

body.menu-travado {
  overflow: hidden;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
}

h1, h2, h3, h4 {
  color: var(--mp-titulo);
  line-height: 1.2;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--mp-destaque);
  outline-offset: 3px;
}

/* ── Topo (cabeçalho) ────────────────────────────────────── */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 900;
  height: var(--topo-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding-right: clamp(16px, 2.5vw, 32px);
  background: color-mix(in srgb, var(--mp-fundo) 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--mp-linha);
}

/* A marca ocupa a largura do menu e forma um "L" verde com ele */
.topbar > .logo,
.topbar-esquerda {
  flex: 0 0 var(--menu-w);
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  background:
    var(--curvas-claras),
    var(--mp-menu-fundo);
  background-size: 600px 400px, auto;
}

.topbar-esquerda .logo {
  display: flex;
}

.logo {
  align-items: center;
  gap: 10px;
  color: var(--off-white);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
  white-space: nowrap;
}

.logo i {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 13px 4px 13px 4px;
  background: rgba(250, 247, 241, .12);
  border: 1px solid rgba(250, 247, 241, .2);
  color: var(--trigo);
  font-size: 19px;
  transition: border-radius .4s var(--ease), transform .4s var(--ease);
}

.logo:hover i {
  border-radius: 4px 13px 4px 13px;
  transform: rotate(-6deg);
}

.topbar > .logo {
  display: flex;
}

.search-form {
  flex: 1;
  max-width: 560px;
  margin-left: clamp(4px, 1.5vw, 16px);
}

.search-box {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 1.5px solid var(--mp-linha);
  border-radius: var(--radius-pill);
  background: var(--mp-superficie);
  transition: border-color .25s, box-shadow .25s;
}

.search-box:hover {
  border-color: var(--mp-linha-forte);
}

.search-box:focus-within {
  border-color: var(--mp-destaque);
  box-shadow: 0 0 0 4px rgba(79, 119, 45, .14);
}

.search-box i {
  color: var(--mp-suave);
  font-size: 16px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--mp-texto);
  font-size: 14.5px;
}

.search-box input::placeholder {
  color: var(--mp-suave);
  opacity: .8;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--mp-linha);
  border-radius: 14px;
  background: var(--mp-superficie);
  color: var(--mp-titulo);
  font-size: 18px;
  transition: border-color .25s, background-color .25s, transform .25s var(--ease);
}

.icon-btn:hover {
  border-color: var(--mp-destaque);
  background: var(--mp-nevoa);
}

.icon-btn:active {
  transform: scale(.94);
}

.icon-btn i {
  transition: transform .35s var(--ease);
}

.icon-btn:hover i {
  transform: rotate(-10deg);
}

.contador {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--terra);
  border: 2px solid var(--mp-fundo);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.menu-toggle {
  display: none;
}

.topbar-esquerda .menu-toggle {
  background: rgba(250, 247, 241, .12);
  border-color: rgba(250, 247, 241, .2);
  color: var(--off-white);
}

.perfil button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--mp-linha);
  border-radius: var(--radius-pill);
  background: var(--mp-superficie);
  text-align: left;
  transition: border-color .25s, background-color .25s;
}

.perfil button:hover {
  border-color: var(--mp-destaque);
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--verde-medio), var(--verde-escuro));
  color: var(--off-white);
  font-size: 14px;
  font-weight: 700;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.perfil button span {
  display: block;
  max-width: 140px;
  overflow: hidden;
  color: var(--mp-titulo);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.perfil button small {
  display: block;
  color: var(--mp-suave);
  font-size: 12px;
  line-height: 1.2;
}

/* ── Menu lateral ────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topo-h);
  bottom: 0;
  left: 0;
  z-index: 800;
  width: var(--menu-w);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 20px;
  overflow-y: auto;
  background:
    var(--curvas-claras),
    radial-gradient(80% 50% at 0% 100%, rgba(122, 82, 48, .38), transparent 70%),
    var(--mp-menu-fundo);
  background-size: 600px 400px, auto, auto;
  background-position: 0 -72px, 0 0, 0 0;
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--mp-menu-texto);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .25s ease, color .25s ease;
}

.sidebar nav a i {
  width: 22px;
  font-size: 18px;
  text-align: center;
  transition: transform .35s var(--ease), color .25s;
}

.sidebar nav a:hover {
  background: rgba(250, 247, 241, .08);
  color: #fff;
}

.sidebar nav a:hover i {
  transform: translateX(2px) scale(1.08);
}

.sidebar nav a.ativo {
  background: rgba(250, 247, 241, .12);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(250, 247, 241, .1);
}

.sidebar nav a.ativo i {
  color: var(--trigo);
}

.sidebar nav a.ativo::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--trigo);
}

/* "Sair" fica separado, no fim do menu */
.sidebar nav a:last-child {
  margin-top: auto;
  border-top: 1px solid rgba(250, 247, 241, .1);
  border-radius: 0 0 14px 14px;
  padding-top: 6px;
}

.sidebar nav a:last-child:hover {
  background: rgba(240, 138, 128, .12);
  color: #ffd9d4;
}

.sidebar :focus-visible {
  outline-color: var(--trigo);
}

.sidebar-overlay,
.painel-overlay {
  position: fixed;
  inset: 0;
  z-index: 790;
  background: rgba(15, 21, 14, .45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: aparecer .25s ease both;
}

/* ── Conteúdo ────────────────────────────────────────────── */
.conteudo {
  min-height: 100vh;
  margin-left: var(--menu-w);
  padding: calc(var(--topo-h) + 28px) clamp(16px, 3vw, 40px) 64px;
}

.conteudo > * {
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
}

.conteudo > * + * {
  margin-top: 28px;
}

/* Entrada suave das seções */
.conteudo > * {
  animation: subir .7s var(--ease) both;
}

.conteudo > *:nth-child(2) { animation-delay: .06s; }
.conteudo > *:nth-child(3) { animation-delay: .12s; }
.conteudo > *:nth-child(4) { animation-delay: .18s; }
.conteudo > *:nth-child(5) { animation-delay: .24s; }
.conteudo > *:nth-child(n + 6) { animation-delay: .3s; }

/* ── Cabeçalho da página ─────────────────────────────────── */
.page-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px 24px;
  padding: clamp(22px, 3vw, 32px) clamp(22px, 3vw, 36px);
  overflow: hidden;
  border-radius: 28px 28px 28px 90px;
  background:
    var(--curvas-verdes),
    radial-gradient(60% 120% at 100% 0%, rgba(144, 169, 85, .2), transparent 70%),
    linear-gradient(135deg, var(--mp-superficie-2), var(--mp-fundo-alt));
  background-size: 600px 400px, auto, auto;
  background-position: right -80px top -40px, 0 0, 0 0;
  background-repeat: no-repeat;
  border: 1px solid var(--mp-linha);
}

.page-header::before {
  content: "MarketPlace Rural";
  display: block;
  position: absolute;
  top: clamp(22px, 3vw, 32px);
  left: clamp(22px, 3vw, 36px);
  color: var(--mp-terra);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.page-header > div:first-child {
  padding-top: 22px;
}

.page-header h1 {
  font-family: var(--fonte-display);
  font-size: clamp(1.75rem, 1.3rem + 1.3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-header p {
  margin-top: 6px;
  max-width: 60ch;
  color: var(--mp-suave);
  font-size: 15px;
}

/* ── Botões ──────────────────────────────────────────────── */
.page-header > button,
.btn-principal,
.btn-explorar,
.btn-voltar,
.modal-actions button:last-child,
.danger-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--verde);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color .25s ease,
    border-color .25s ease,
    box-shadow .3s ease,
    transform .25s var(--ease);
}

.page-header > button i,
.btn-principal i {
  font-size: 16px;
  transition: transform .35s var(--ease);
}

.page-header > button:hover,
.btn-principal:hover,
.btn-explorar:hover,
.btn-voltar:hover,
.modal-actions button:last-child:hover {
  background: var(--verde-escuro);
  box-shadow: 0 14px 26px -14px rgba(31, 58, 29, .65);
  transform: translateY(-2px);
}

.page-header > button:hover i {
  transform: rotate(90deg);
}

.page-header > button:active,
.btn-principal:active,
.modal-actions button:active {
  transform: scale(.97);
}

body.dark .page-header > button,
body.dark .btn-principal,
body.dark .btn-explorar,
body.dark .btn-voltar,
body.dark .modal-actions button:last-child {
  background: var(--verde-medio);
}

body.dark .page-header > button:hover,
body.dark .btn-principal:hover,
body.dark .btn-explorar:hover,
body.dark .btn-voltar:hover,
body.dark .modal-actions button:last-child:hover {
  background: #5d8a35;
}

.btn-danger,
.danger-box.excluir button {
  background: #a3322a !important;
}

.btn-danger:hover,
.danger-box.excluir button:hover {
  background: #86241d !important;
  box-shadow: 0 14px 26px -14px rgba(134, 36, 29, .6) !important;
}

/* ── Cards de resumo ─────────────────────────────────────── */
.cards-resumo {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.resumo-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 14px;
  padding: 20px;
  overflow: hidden;
  border-radius: 22px;
  background: var(--mp-superficie);
  border: 1px solid var(--mp-linha);
  box-shadow: var(--mp-sombra-card);
  transition: transform .35s var(--ease), box-shadow .35s ease, border-color .3s;
}

.resumo-card:hover {
  transform: translateY(-4px);
  border-color: var(--mp-linha-forte);
  box-shadow: var(--mp-sombra-sm);
}

.resumo-card > i {
  grid-row: 1 / span 2;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 16px 5px 16px 5px;
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  font-size: 22px;
  transition: border-radius .4s var(--ease), transform .4s var(--ease);
}

.resumo-card:hover > i {
  border-radius: 5px 16px 5px 16px;
  transform: rotate(-4deg);
}

.resumo-card:nth-child(2) > i { background: var(--mp-trigo-suave); color: var(--mp-terra); }
.resumo-card:nth-child(3) > i { background: var(--mp-alerta-fundo); color: var(--mp-alerta); }
.resumo-card:nth-child(4) > i { background: var(--mp-info-fundo); color: var(--mp-info); }

.resumo-card strong {
  color: var(--mp-titulo);
  font-family: var(--fonte-display);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.05;
}

.resumo-card span {
  color: var(--mp-suave);
  font-size: 13.5px;
  font-weight: 500;
}

/* ── Filtros ─────────────────────────────────────────────── */
.filtros {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filtros::before {
  content: "\f3e1";
  font-family: "bootstrap-icons";
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  font-size: 18px;
}

.filtros select,
.campo select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' fill='none' stroke='%234f772d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.filtros select {
  min-width: 200px;
  height: 46px;
  padding: 0 44px 0 16px;
  border: 1.5px solid var(--mp-linha);
  border-radius: var(--radius-pill);
  background-color: var(--mp-superficie);
  color: var(--mp-texto);
  font-size: 14px;
  font-weight: 500;
  transition: border-color .25s, box-shadow .25s;
}

.filtros select:hover {
  border-color: var(--mp-linha-forte);
}

.filtros select:focus {
  outline: 0;
  border-color: var(--mp-destaque);
  box-shadow: 0 0 0 4px rgba(79, 119, 45, .14);
}

/* ── Tabelas ─────────────────────────────────────────────── */
.tabela-wrapper {
  position: relative;
  overflow-x: auto;
  border-radius: 22px;
  background: var(--mp-superficie);
  border: 1px solid var(--mp-linha);
  box-shadow: var(--mp-sombra-card);
}

.tabela-wrapper table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.tabela-wrapper thead th {
  position: sticky;
  top: 0;
  padding: 14px 18px;
  background: var(--mp-fundo-alt);
  color: var(--mp-suave);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.tabela-wrapper tbody td {
  padding: 15px 18px;
  border-top: 1px solid var(--mp-linha);
  color: var(--mp-texto);
  font-size: 14.5px;
  vertical-align: middle;
}

.tabela-wrapper tbody td:first-child {
  color: var(--mp-titulo);
  font-weight: 600;
}

.tabela-wrapper tbody tr {
  transition: background-color .2s ease;
}

.tabela-wrapper tbody tr:hover {
  background: var(--mp-nevoa);
}

.tabela-wrapper tbody:empty + * {
  border-top: 0;
}

/* Botões de ação nas linhas e nos cards */
.tabela-wrapper td button,
.produto-acoes button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--mp-linha);
  border-radius: 12px;
  background: var(--mp-superficie);
  color: var(--mp-titulo);
  font-size: 16px;
  transition: background-color .2s, border-color .2s, color .2s, transform .25s var(--ease);
}

.tabela-wrapper td button:hover,
.produto-acoes button:hover {
  border-color: var(--mp-destaque);
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  transform: translateY(-2px);
}

.produto-acoes button.btn-excluir:hover,
.produto-acoes button.btn-remover:hover {
  border-color: var(--mp-erro);
  background: var(--mp-erro-fundo);
  color: var(--mp-erro);
}

/* ── Badges de status ────────────────────────────────────── */
.badge,
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.badge::before,
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge.normal,
.badge.entregue,
.status.disponivel {
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
}

.badge.baixo,
.badge.negociacao,
.status.baixo {
  background: var(--mp-alerta-fundo);
  color: var(--mp-alerta);
}

.badge.esgotado,
.badge.cancelado,
.status.esgotado,
.status.indisponivel {
  background: var(--mp-erro-fundo);
  color: var(--mp-erro);
}

.badge.recebido {
  background: var(--mp-info-fundo);
  color: var(--mp-info);
}

.badge.preparo {
  background: var(--mp-trigo-suave);
  color: var(--mp-terra);
}

/* ── Cards de produto (Meus Produtos e Favoritos) ────────── */
.grid-produtos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.produto-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 22px;
  background: var(--mp-superficie);
  border: 1px solid var(--mp-linha);
  box-shadow: var(--mp-sombra-card);
  transition: transform .4s var(--ease), box-shadow .4s ease, border-color .3s;
}

.produto-card:hover {
  transform: translateY(-5px);
  border-color: var(--mp-linha-forte);
  box-shadow: var(--mp-sombra);
}

.produto-card > img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background:
    linear-gradient(135deg, var(--mp-nevoa), var(--mp-trigo-suave));
  transition: transform .9s var(--ease);
}

.produto-card:hover > img {
  transform: scale(1.04);
}

.produto-card .produto-info {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px 18px;
  background: var(--mp-superficie);
}

.produto-card .categoria {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--mp-trigo-suave);
  color: var(--mp-terra);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.produto-card h3 {
  font-size: 1.08rem;
  font-weight: 700;
}

.produto-card .produto-info > p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--mp-suave);
  font-size: 13.5px;
}

.produto-card .produto-info > strong {
  color: var(--mp-titulo);
  font-family: var(--fonte-display);
  font-size: 1.3rem;
  font-weight: 700;
}

.produto-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--mp-suave);
  font-size: 13px;
}

.produto-acoes {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

/* Placeholder de imagem ausente */
.img-vazia {
  width: 100%;
  height: 100%;
  min-height: 160px;
  display: grid;
  place-items: center;
  background:
    var(--curvas-verdes),
    linear-gradient(135deg, var(--mp-nevoa), var(--mp-trigo-suave));
  background-size: 400px 260px, auto;
  color: var(--mp-destaque);
  font-size: 40px;
}

/* Imagem que não carregou (classe aplicada pelo painel.js) */
img.img-quebrada {
  content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1' height='1'/>");
  color: transparent !important;
  font-size: 0 !important;
  font-size: 0;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 16 16' fill='%234f772d'><path d='M5.757 1.071a.5.5 0 0 1 .172.686L3.383 6h9.234L10.07 1.757a.5.5 0 1 1 .858-.514L13.783 6H15.5a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5H.5a.5.5 0 0 1-.5-.5v-1A.5.5 0 0 1 .5 6h1.717L5.07 1.243a.5.5 0 0 1 .686-.172zM2.163 10H13.837l-.892 4.454a1 1 0 0 1-.98.796H4.035a1 1 0 0 1-.98-.796L2.163 10z'/></svg>") center / 44px no-repeat,
    var(--curvas-verdes),
    linear-gradient(135deg, var(--mp-nevoa), var(--mp-trigo-suave));
  background-size: 44px, 400px 260px, auto;
}

/* ── Estado vazio ────────────────────────────────────────── */
.empty-state,
.empty-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
  color: var(--mp-suave);
}

.grid-produtos > .empty-state,
section.empty-state,
#areaComprador .empty-state {
  grid-column: 1 / -1;
  border: 1.5px dashed var(--mp-linha-forte);
  border-radius: 24px;
  background: var(--mp-superficie-2);
}

.empty-state > i,
.empty-chat > i {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  border-radius: 24px 8px 24px 8px;
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  font-size: 30px;
}

.empty-state h2,
.empty-chat h2 {
  font-family: var(--fonte-display);
  font-size: 1.35rem;
}

.empty-state p,
.empty-chat p {
  max-width: 42ch;
  font-size: 14.5px;
}

.empty-state .btn-explorar,
.empty-state .btn-voltar {
  margin-top: 12px;
}

/* ── Modais ──────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 21, 14, .5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal.ativo {
  display: flex;
  animation: aparecer .25s ease both;
}

.modal-box {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 26px;
  border-radius: 26px;
  background: var(--mp-superficie);
  border: 1px solid var(--mp-linha);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .45);
}

.modal.ativo .modal-box {
  animation: modal-entrar .4s var(--ease) both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-family: var(--fonte-display);
  font-size: 1.45rem;
  font-weight: 700;
}

.modal-header button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--mp-linha);
  border-radius: 12px;
  background: transparent;
  color: var(--mp-suave);
  transition: background-color .2s, color .2s, transform .3s var(--ease);
}

.modal-header button:hover {
  background: var(--mp-erro-fundo);
  color: var(--mp-erro);
  transform: rotate(90deg);
}

.modal-box form {
  display: grid;
  gap: 16px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--mp-linha);
}

.modal-actions button {
  min-height: 46px;
  padding: 0 20px;
  border: 1.5px solid var(--mp-linha-forte);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--mp-titulo);
  font-size: 14.5px;
  font-weight: 600;
  transition: background-color .25s, border-color .25s, transform .25s var(--ease);
}

.modal-actions button:hover {
  border-color: var(--mp-destaque);
  background: var(--mp-nevoa);
}

/* ── Campos de formulário ────────────────────────────────── */
.campo {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.campo label {
  color: var(--mp-titulo);
  font-size: 13.5px;
  font-weight: 600;
}

.campo input,
.campo select,
.campo textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid var(--mp-linha);
  border-radius: 14px;
  background-color: var(--mp-campo);
  color: var(--mp-texto);
  font-size: 15px;
  transition: border-color .25s, box-shadow .25s, background-color .25s;
}

.campo select {
  padding-right: 42px;
}

.campo textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}

.campo input:hover,
.campo select:hover,
.campo textarea:hover {
  border-color: var(--mp-linha-forte);
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: 0;
  border-color: var(--mp-destaque);
  background-color: var(--mp-superficie);
  box-shadow: 0 0 0 4px rgba(79, 119, 45, .14);
}

.campo input[readonly] {
  background: var(--mp-fundo-alt);
  color: var(--mp-suave);
}

.campo input[type="file"] {
  padding: 10px;
  border-style: dashed;
  cursor: pointer;
}

.campo input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--mp-nevoa);
  color: var(--mp-destaque);
  font-weight: 600;
  cursor: pointer;
}

.campo input::placeholder,
.campo textarea::placeholder {
  color: var(--mp-suave);
  opacity: .7;
}

/* ── Aviso flutuante (toast) ─────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 1200;
  max-width: calc(100vw - 32px);
  padding: 13px 20px;
  border-radius: var(--radius-pill);
  background: var(--verde-escuro);
  color: var(--off-white);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--mp-sombra);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .3s ease, transform .35s var(--ease);
}

.toast.visivel {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Botão de tema ───────────────────────────────────────── */
#temaBtn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 950;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--mp-linha);
  border-radius: 18px 6px 18px 6px;
  background: var(--mp-superficie);
  color: var(--mp-titulo);
  font-size: 20px;
  box-shadow: var(--mp-sombra-sm);
  transition: border-color .25s, border-radius .4s var(--ease), transform .3s var(--ease);
}

#temaBtn:hover {
  border-color: var(--mp-destaque);
  border-radius: 6px 18px 6px 18px;
  transform: translateY(-2px);
}

/* ── Animações ───────────────────────────────────────────── */
@keyframes subir {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes aparecer {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-entrar {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ── Responsivo ──────────────────────────────────────────── */
@media (max-width: 1200px) {
  .cards-resumo {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Menu vira gaveta lateral */
@media (max-width: 1024px) {
  :root {
    --menu-w: 272px;
  }

  .menu-toggle {
    display: grid;
  }

  .topbar {
    gap: 12px;
    padding-left: clamp(12px, 2.5vw, 24px);
  }

  .topbar > .logo,
  .topbar-esquerda {
    flex: 0 0 auto;
    align-self: center;
    padding: 0;
    background: none;
  }

  .topbar .logo {
    color: var(--mp-titulo);
  }

  .topbar .logo i {
    background: var(--verde-escuro);
    border-color: transparent;
  }

  .topbar-esquerda .menu-toggle {
    background: var(--mp-superficie);
    border-color: var(--mp-linha);
    color: var(--mp-titulo);
  }

  .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: none;
    transition: transform .35s var(--ease), visibility 0s linear .35s, box-shadow .35s;
  }

  .sidebar.aberta {
    transform: none;
    visibility: visible;
    box-shadow: 30px 0 60px -20px rgba(0, 0, 0, .45);
    transition: transform .35s var(--ease), visibility 0s, box-shadow .35s;
  }

  .conteudo {
    margin-left: 0;
  }
}

@media (max-width: 820px) {
  .perfil button > div:last-child,
  .perfil-info {
    display: none;
  }

  .perfil button {
    padding: 4px;
  }
}

/* Celular: busca vai para uma segunda linha do topo */
@media (max-width: 680px) {
  :root {
    --topo-h: 124px;
  }

  .topbar {
    flex-wrap: wrap;
    align-content: center;
    row-gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .search-form {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
    margin: 0;
  }

  .search-box {
    height: 44px;
  }

  .topbar .logo span {
    font-size: 16px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .top-actions {
    gap: 6px;
  }

  .conteudo {
    padding-top: calc(var(--topo-h) + 18px);
    padding-bottom: 96px;
  }

  .conteudo > * + * {
    margin-top: 20px;
  }

  .page-header {
    border-radius: 22px 22px 22px 56px;
  }

  .page-header > button {
    width: 100%;
  }

  .cards-resumo {
    gap: 12px;
  }

  .resumo-card {
    grid-template-columns: 1fr;
    row-gap: 10px;
    padding: 16px;
  }

  .resumo-card > i {
    grid-row: auto;
    width: 42px;
    height: 42px;
    font-size: 19px;
  }

  .resumo-card strong {
    font-size: 1.6rem;
  }

  .filtros::before {
    display: none;
  }

  .filtros select {
    flex: 1 1 160px;
    min-width: 0;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    width: 100%;
    max-height: 92vh;
    border-radius: 26px 26px 0 0;
    padding: 22px 18px 26px;
  }

  .modal-actions button {
    flex: 1;
  }

  #temaBtn {
    right: 16px;
    bottom: 16px;
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 400px) {
  .topbar .logo span {
    display: none;
  }
}

@media (max-width: 340px) {
  .cards-resumo {
    grid-template-columns: 1fr;
  }
}

/* ── Movimento reduzido ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}

/* ── Foto de perfil no avatar (menu.js: window.aplicarFotoPerfil) ── */
.avatar.com-foto {
  background-size: cover;
  background-position: center;
  color: transparent !important;
  font-size: 0 !important;
}

/* Desempenho no celular: desfoque de fundo (backdrop-filter) é o efeito que mais trava
   a rolagem em aparelhos simples. Abaixo de 900px ele sai e o fundo fica sólido. */
@media (max-width: 900px), (hover: none) {
  *, *::before, *::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}
