/* ============================================================
   PADARIA PERDAS — Estilos principais
   ============================================================ */

:root {
  --cor-primaria:   #c8622a;
  --cor-primaria-d: #a34e20;
  --cor-fundo:      #f5f5f5;
  --cor-card:       #ffffff;
  --cor-texto:      #1a1a1a;
  --cor-texto-sub:  #666666;
  --cor-borda:      #e0e0e0;
  --cor-erro:       #d32f2f;
  --cor-sucesso:    #2e7d32;
  --cor-aviso:      #f57c00;
  --sidebar-w:      240px;
  --raio:           10px;
  --sombra:         0 2px 8px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--cor-fundo);
  color: var(--cor-texto);
  font-size: 15px;
}

/* ── LOGIN ───────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #c8622a 0%, #7b3a18 100%);
}
.login-card {
  background: white;
  border-radius: var(--raio);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.login-logo   { font-size: 3rem; text-align: center; display: block; }
.login-titulo { text-align: center; font-size: 1.5rem; margin: .4rem 0 .2rem; }
.login-sub    { text-align: center; color: var(--cor-texto-sub); margin-bottom: 1.5rem; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #1e1e1e;
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid #333;
}
.sidebar-logo   { font-size: 1.6rem; }
.sidebar-titulo { font-size: 1rem; font-weight: 700; flex: 1; }
.sidebar-fechar { display: none; background: none; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }

.sidebar-menu {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}
.menu-item {
  display: block;
  padding: .75rem 1.2rem;
  color: #ccc;
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 8px;
  transition: background .15s, color .15s;
}
.menu-item:hover, .menu-item.ativo {
  background: var(--cor-primaria);
  color: #fff;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #333;
  font-size: .85rem;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-logout {
  background: none;
  border: 1px solid #555;
  color: #aaa;
  border-radius: 6px;
  padding: .3rem .7rem;
  cursor: pointer;
  font-size: .8rem;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--cor-primaria); color: var(--cor-primaria); }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}
.overlay.visivel { display: block; }

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: white;
  border-bottom: 1px solid var(--cor-borda);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.btn-menu {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--cor-texto);
}
.topbar-titulo { font-size: 1.15rem; font-weight: 600; }

.conteudo {
  padding: 1.5rem;
  flex: 1;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--cor-card);
  border-radius: var(--raio);
  padding: 1.25rem;
  box-shadow: var(--sombra);
  border: 1px solid var(--cor-borda);
}

.grid-resumo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card-resumo {
  background: white;
  border-radius: var(--raio);
  padding: 1.2rem;
  box-shadow: var(--sombra);
  border-left: 4px solid var(--cor-primaria);
}
.card-resumo .label { font-size: .8rem; color: var(--cor-texto-sub); text-transform: uppercase; letter-spacing: .04em; }
.card-resumo .valor { font-size: 1.6rem; font-weight: 700; color: var(--cor-primaria); margin-top: .2rem; }
.card-resumo .sub   { font-size: .8rem; color: var(--cor-texto-sub); margin-top: .1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }

/* ── FORMULÁRIOS ─────────────────────────────────────────── */
.campo       { margin-bottom: 1rem; }
.campo label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; }
.campo input,
.campo select,
.campo textarea {
  width: 100%;
  border: 1px solid var(--cor-borda);
  border-radius: 6px;
  padding: .6rem .8rem;
  font-size: .95rem;
  font-family: inherit;
  background: white;
  color: var(--cor-texto);
  transition: border-color .15s;
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: none;
  border-color: var(--cor-primaria);
  box-shadow: 0 0 0 3px rgba(200,98,42,.15);
}
.campo textarea { min-height: 80px; resize: vertical; }

/* ── BOTÕES ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.1rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario  { background: var(--cor-primaria);  color: white; }
.btn-primario:hover:not(:disabled)  { background: var(--cor-primaria-d); }
.btn-secundario{ background: #eee; color: var(--cor-texto); }
.btn-secundario:hover:not(:disabled){ background: #ddd; }
.btn-perigo    { background: var(--cor-erro); color: white; }
.btn-perigo:hover:not(:disabled)    { background: #b71c1c; }
.btn-sm        { padding: .35rem .7rem; font-size: .8rem; }
.btn-block     { width: 100%; justify-content: center; margin-top: .5rem; }

/* ── TABELAS ─────────────────────────────────────────────── */
.tabela-wrapper { overflow-x: auto; }
table  { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--cor-borda); font-size: .9rem; }
th     { font-weight: 600; background: #fafafa; color: var(--cor-texto-sub); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ── ALERTAS ─────────────────────────────────────────────── */
.alerta {
  padding: .7rem 1rem;
  border-radius: 6px;
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alerta-erro    { background: #ffebee; color: var(--cor-erro);    border: 1px solid #ffcdd2; }
.alerta-sucesso { background: #e8f5e9; color: var(--cor-sucesso); border: 1px solid #c8e6c9; }
.alerta-aviso   { background: #fff3e0; color: var(--cor-aviso);   border: 1px solid #ffe0b2; }

/* ── MISC ────────────────────────────────────────────────── */
.secao-titulo {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--cor-primaria);
  color: var(--cor-primaria);
}
.carregando { text-align: center; color: var(--cor-texto-sub); padding: 3rem; }
.vazio      { text-align: center; color: var(--cor-texto-sub); padding: 2rem; font-size: .9rem; }

.produto-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: #eee;
  display: inline-block;
  vertical-align: middle;
}

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-verde    { background: #e8f5e9; color: var(--cor-sucesso); }
.badge-vermelho { background: #ffebee; color: var(--cor-erro); }
.badge-cinza    { background: #eee;    color: #666; }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.filtros .campo { margin-bottom: 0; }

/* ── TELA REGISTRAR PERDA ────────────────────────────────── */
.perda-layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap: 1.5rem;
  align-items: start;
  max-width: 960px;
}

.perda-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  text-align: center;
  gap: .75rem;
}

.perda-preview-vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  color: var(--cor-texto-sub);
  font-size: .9rem;
  line-height: 1.5;
}

.perda-preview-icon { font-size: 3rem; }

.perda-preview-img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--cor-borda);
}

.perda-preview-nome {
  font-weight: 600;
  font-size: 1rem;
  color: var(--cor-texto);
  margin-top: .25rem;
}

.perda-preview-unidade {
  font-size: .8rem;
  color: var(--cor-texto-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── DIALOG CUSTOMIZADO ──────────────────────────────────── */
.dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.dialog-overlay.aberto { display: flex; }

.dialog-box {
  background: white;
  border-radius: var(--raio);
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  text-align: center;
  animation: dialog-entrar .18s ease;
}

@keyframes dialog-entrar {
  from { opacity: 0; transform: scale(.94) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.dialog-icone   { font-size: 2.5rem; margin-bottom: .75rem; }
.dialog-mensagem {
  font-size: .95rem;
  color: var(--cor-texto);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}
.dialog-botoes {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── SELETOR DE IMAGENS ──────────────────────────────────── */
.img-picker-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.img-picker-modal.aberto { display: flex; }

.img-picker-box {
  background: white;
  border-radius: var(--raio);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.img-picker-titulo {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--cor-primaria);
}
.img-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
.img-picker-opcao {
  border: 3px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  aspect-ratio: 4/3;
  background: #f0f0f0;
}
.img-picker-opcao img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.img-picker-opcao:hover  { border-color: var(--cor-primaria); transform: scale(1.02); }
.img-picker-opcao.selecionada { border-color: var(--cor-primaria); }
.img-picker-vazio { text-align: center; color: #999; padding: 2rem; font-size: .9rem; }

/* ── MOBILE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.aberto {
    transform: translateX(0);
  }
  .sidebar-fechar { display: block; }
  .main-wrapper   { margin-left: 0; }
  .btn-menu       { display: block; }
  .grid-2         { grid-template-columns: 1fr; }
  .conteudo       { padding: 1rem; }
  .filtros        { flex-direction: column; }
  .filtros .campo,
  .filtros .btn   { width: 100%; }
  .perda-layout   { grid-template-columns: 1fr; }
}
