/* =============================================
   modal.css — v5.0
   Todos os seletores prefixados: .modal, .modal__,
   .mp- (sem conflito com outros componentes).
   Ripple removido. Feedback visual via ::after overlay.
============================================= */

/* ── Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
}

/* ── Caixa principal ── */
.modal {
  background: var(--branco);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 94dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 48px rgba(0, 0, 0, 0.18);
  animation: mp-slide-up 280ms cubic-bezier(0.32, 1.1, 0.6, 1);
}

@media (min-width: 600px) {
  .modal {
    border-radius: 20px;
    max-height: 90dvh;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    animation: mp-fade-scale 240ms cubic-bezier(0.32, 1.1, 0.6, 1);
  }
}

@keyframes mp-slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes mp-fade-scale {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── Header ── */
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem 0.9rem;
  border-bottom: 1px solid var(--azul-suave);
  flex-shrink: 0;
  gap: 0.75rem;
}

.modal__header-esq {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.modal__header-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--azul-ultraclaro);
  color: var(--azul-medio);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.modal__header h3 {
  font-family: var(--fonte-titulo);
  font-weight: 800;
  color: var(--texto);
  font-size: 1rem;
  margin: 0 0 0.1rem;
  line-height: 1.2;
}

.modal__header-sub {
  font-size: 0.72rem;
  color: var(--texto-suave);
  margin: 0;
}

/* Botão fechar — feedback via scale, sem ripple */
.modal__fechar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--azul-ultraclaro);
  color: var(--texto-suave);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
}

.modal__fechar:hover {
  background: var(--azul-suave);
}
.modal__fechar:active {
  transform: scale(0.9);
}

/* ── Abas ── */
.modal__abas {
  display: flex;
  gap: 0.3rem;
  padding: 0.7rem 1.25rem 0.5rem;
  border-bottom: 1px solid var(--azul-suave);
  flex-shrink: 0;
}

.modal__aba {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--texto-suave);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
  font-family: inherit;
}

.modal__aba:active {
  transform: scale(0.97);
}

.modal__aba--ativa {
  background: var(--azul-ultraclaro);
  color: var(--azul-medio);
  border-color: var(--azul-suave);
}

.modal__aba:hover:not(.modal__aba--ativa) {
  background: var(--azul-ultraclaro);
  color: var(--texto);
}

.modal__aba .ti {
  font-size: 0.9rem;
}

/* ── Body scrollável ── */
.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--azul-suave) transparent;
}

.modal__body::-webkit-scrollbar {
  width: 6px;
}
.modal__body::-webkit-scrollbar-thumb {
  background: var(--azul-suave);
  border-radius: 3px;
}
.modal__body::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Foto upload ── */
.mp-foto-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.1rem;
}

.mp-foto-btn {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 16px;
  border: 2px dashed var(--azul-suave);
  background: var(--azul-ultraclaro);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  overflow: hidden;
}
@media (hover: hover) {
  .mp-foto-btn:hover {
    background: var(--azul-suave);
  }
}

.mp-foto-btn.tem-foto {
  border-style: solid;
  border-color: var(--azul-medio);
}

.mp-foto-btn__icon {
  font-size: 1.5rem;
  color: var(--texto-suave);
}

.mp-foto-btn__label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--texto-suave);
}

.mp-foto-btn img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mp-foto-btn__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.mp-foto-btn.tem-foto:hover .mp-foto-btn__overlay {
  opacity: 1;
}

.mp-foto-apagar {
  background: none;
  border: none;
  color: var(--erro, #ef4444);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-top: 0.35rem;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: background 0.15s;
}

.mp-foto-apagar:hover {
  background: #fef2f2;
}

/* ── Grid de campos ── */
.mp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.mp-grid--full {
  grid-column: 1 / -1;
}

@media (max-width: 420px) {
  .modal__header {
    padding: 0.8rem 1rem;
  }
  .mp-grid {
    grid-template-columns: 1fr;
  }
  .mp-grid--full {
    grid-column: 1;
  }
  .modal__footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }
  .mp-btn {
    width: 100%;
  }
}

/* ── Grupos e labels ── */
.mp-grupo {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.mp-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--texto);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.mp-label .ti {
  color: var(--azul-medio);
  font-size: 0.82rem;
}
.mp-req {
  color: #ef4444;
}
.mp-opc {
  color: var(--texto-suave);
  font-weight: 400;
  font-size: 0.7rem;
}

/* ── Inputs ── */
.mp-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--azul-suave);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--texto);
  background: var(--branco);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
}

.mp-input:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mp-input.mp-input--erro {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.08);
}

.mp-input--prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.mp-input--prefix-wrap .mp-prefix {
  position: absolute;
  left: 0.85rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--azul-medio);
  pointer-events: none;
  user-select: none;
}

.mp-input--prefix-wrap .mp-input {
  padding-left: 2.5rem;
}

select.mp-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
}

textarea.mp-input {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* ── Mensagens de erro ── */
.mp-erro {
  font-size: 0.72rem;
  color: #ef4444;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  min-height: 1rem;
}

/* ── Footer ── */
.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem 1.1rem;
  border-top: 1px solid var(--azul-suave);
  flex-shrink: 0;
}

/* ── Botões do footer ── */
.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: filter 0.15s, transform 0.12s, box-shadow 0.15s;
}

.mp-btn:active {
  transform: scale(0.97);
}

.mp-btn--cancel {
  background: var(--azul-ultraclaro);
  color: var(--texto-suave);
  border: 1.5px solid var(--azul-suave);
}

.mp-btn--cancel:hover {
  background: var(--azul-suave);
  color: var(--texto);
}

.mp-btn--save {
  background: var(--azul-medio);
  color: #fff;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.22);
}

.mp-btn--save:hover {
  filter: brightness(1.07);
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.32);
}

.mp-btn--save:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.mp-btn .ti {
  font-size: 1rem;
}

/* ── Spinner inline no botão ── */
.mp-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mp-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes mp-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ══════════════════════════════════════════
   PAINEL LOTE — CARDS DE PRODUTO
══════════════════════════════════════════ */

.mp-lote-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.mp-lote-info {
  font-size: 0.8rem;
  color: var(--texto-suave);
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  flex: 1;
  line-height: 1.5;
}

.mp-lote-info .ti {
  color: var(--azul-medio);
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.mp-lote-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  border: 1.5px solid var(--azul-medio);
  background: var(--azul-ultraclaro);
  color: var(--azul-medio);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.12s;
  flex-shrink: 0;
  font-family: inherit;
}

.mp-lote-add-btn:hover {
  background: var(--azul-suave);
}
.mp-lote-add-btn:active {
  transform: scale(0.96);
}

/* Lista de cards do lote */
.mp-lote-lista {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mp-lote-item {
  border: 1.5px solid var(--azul-suave);
  border-radius: 14px;
  overflow: hidden;
  background: var(--branco);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mp-lote-item:focus-within {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.mp-lote-item--erro {
  border-color: #ef4444;
}
.mp-lote-item--ok {
  border-color: #22c55e;
}

.mp-lote-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background: var(--azul-ultraclaro);
  border-bottom: 1px solid var(--azul-suave);
  cursor: pointer;
  user-select: none;
}

.mp-lote-item__num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--azul-medio);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mp-lote-item__status {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.mp-lote-item__status--ok {
  color: #16a34a;
}
.mp-lote-item__status--erro {
  color: #ef4444;
}
.mp-lote-item__status--vazio {
  color: var(--texto-suave);
}

.mp-lote-item__del {
  background: none;
  border: none;
  color: var(--texto-suave);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}

.mp-lote-item__del:hover {
  background: #fef2f2;
  color: #ef4444;
}
.mp-lote-item__del:active {
  transform: scale(0.88);
}

.mp-lote-item__corpo {
  padding: 0.85rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.mp-lote-item__corpo .mp-lote-nome {
  grid-column: 1 / -1;
}

@media (max-width: 380px) {
  .mp-lote-item__corpo {
    grid-template-columns: 1fr;
  }
  .mp-lote-item__corpo .mp-lote-nome {
    grid-column: 1;
  }
}

/* Input compacto do lote */
.mp-lote-input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--azul-suave);
  border-radius: 9px;
  font-size: 0.85rem;
  color: var(--texto);
  background: var(--branco);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  font-family: inherit;
}

.mp-lote-input:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.mp-lote-input.mp-lote-input--erro {
  border-color: #ef4444;
}

.mp-lote-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--texto-suave);
  margin-bottom: 0.2rem;
}

.mp-lote-label span {
  color: #ef4444;
}

/* Barra de progresso do lote */
.mp-lote-progresso {
  margin-top: 1rem;
  padding: 0.75rem 0;
}

.mp-lote-progresso__barra {
  height: 6px;
  background: var(--azul-ultraclaro);
  border-radius: 50px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.mp-lote-progresso__fill {
  height: 100%;
  background: var(--azul-medio);
  border-radius: 50px;
  transition: width 0.35s ease;
  width: 0%;
}

.mp-lote-progresso__texto {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--azul-medio);
  text-align: center;
  display: block;
}

/* ══════════════════════════════════════════
   DARK MODE
══════════════════════════════════════════ */

html.dark .modal {
  background: #1e293b;
}

html.dark .modal__header,
html.dark .modal__footer,
html.dark .modal__abas,
html.dark .mp-lote-item__header {
  border-color: #334155;
}

html.dark .modal__header-icon {
  background: #172033;
  color: #60a5fa;
}
html.dark .modal__header-sub {
  color: #94a3b8;
}

html.dark .modal__fechar {
  background: #172033;
  color: #94a3b8;
}
html.dark .modal__fechar:hover {
  background: #1e2d45;
}

html.dark .modal__aba--ativa {
  background: #172033;
  color: #93c5fd;
  border-color: #334155;
}

html.dark .mp-input {
  background: #172033;
  border-color: #334155;
  color: #f1f5f9;
}

html.dark .mp-input:focus {
  border-color: #3b82f6;
}

html.dark .mp-foto-btn {
  background: #172033;
  border-color: #334155;
}

html.dark .mp-btn--cancel {
  background: #1e293b;
  border-color: #475569;
  color: #cbd5e1;
}

html.dark .mp-btn--cancel:hover {
  background: #1e2d45;
}

html.dark .mp-lote-item {
  background: #1e293b;
  border-color: #334155;
}

html.dark .mp-lote-item__header {
  background: #172033;
}

html.dark .mp-lote-input {
  background: #172033;
  border-color: #334155;
  color: #f1f5f9;
}

html.dark .mp-lote-progresso__barra {
  background: #172033;
}

html.dark .mp-lote-add-btn {
  background: #172033;
  border-color: #334155;
  color: #93c5fd;
}

html.dark .mp-lote-add-btn:hover {
  background: #1e2d45;
}
