/* =====================================================
   GARANTIAS — modulo vendedor (aba Garantia/Rastreios)
   Paleta RDF: verde #2d7a4f (alinhada com cupons.css),
   amarelo #b8860b (logistica/warn), vermelho #c00 (erro/financeira),
   texto secundario #555. Mobile-first.
   ===================================================== */

/* -------- Aba: containers principais -------- */
.garantias-section {
  margin-bottom: 16px;
}

.garantias-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.garantias-header #btn-nova-garantia {
  flex: 0 0 auto;
}

.garantias-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.garantias-filtros button {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #555;
  font-family: inherit;
  transition: all 0.15s;
}
.garantias-filtros button:hover {
  border-color: #2d7a4f;
  color: #2d7a4f;
}
.garantias-filtros button.filter-active {
  background: #2d7a4f;
  border-color: #2d7a4f;
  color: #fff;
}

.garantias-rastreio-divider {
  border: 0;
  border-top: 1px solid #eee;
  margin: 24px 0 16px;
}
.rastreio-section .section-title {
  font-size: 16px;
  color: #555;
  margin: 0 0 12px;
}

.garantias-lista {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* -------- Cards de garantia (lista do vendedor) -------- */
.garantia-card {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.garantia-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #323232;
}
.garantia-card-meta {
  font-size: 12px;
  color: #777;
  margin-bottom: 8px;
  line-height: 1.4;
}

.cupom-box {
  background: #f0fff4;
  border-left: 3px solid #2d7a4f;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #1a5d3a;
  margin: 4px 0;
  line-height: 1.4;
}
.cupom-box code {
  background: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: #2d7a4f;
}

.desfecho-box {
  background: #f8f9fa;
  border-left: 3px solid #888;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #444;
  margin: 4px 0;
  line-height: 1.4;
}
.desfecho-box strong {
  color: #2d7a4f;
}

.justif-box {
  background: #fde8e8;
  border-left: 3px solid #c00;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #700;
  margin: 4px 0;
  line-height: 1.4;
}
.justif-box strong {
  color: #c00;
}

.garantia-card-acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.garantia-card-acoes button {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 12px;
}

/* -------- Badges de status (escopado pra nao quebrar .badge global) -------- */
.garantia-card .badge,
.modal-garantia .badge,
.garantias-lista .badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: #eee;
  color: #555;
}
.badge-ok {
  background: #e8f5ee !important;
  color: #2d7a4f !important;
}
.badge-warn {
  background: #fff8dc !important;
  color: #7a5a00 !important;
}
.badge-err {
  background: #fde8e8 !important;
  color: #c00 !important;
}

/* -------- Modal nova garantia -------- */
.modal-garantia {
  max-width: 540px;
  width: 96%;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-garantia h3 {
  margin: 0 0 14px;
  color: #2d7a4f;
  font-size: 18px;
  font-weight: 700;
}

.garantia-step {
  margin-bottom: 14px;
}
.step-label {
  display: block;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  font-weight: 600;
}

.cpf-row {
  display: flex;
  gap: 8px;
}
.cpf-row input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
.cpf-row input:focus {
  outline: none;
  border-color: #2d7a4f;
  box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.12);
}
.cpf-row button {
  flex: 0 0 auto;
  padding: 10px 16px;
  font-family: inherit;
}

.cliente-card {
  background: #f0fff4;
  border: 1px solid #b8e0c5;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: #1a5d3a;
  margin-top: 10px;
  line-height: 1.4;
}
.cliente-card strong {
  color: #2d7a4f;
}

/* -------- Lista de pedidos no passo 2 (escopada pra nao herdar .pedido-card global) -------- */
.pedidos-lista {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fff;
}
.pedidos-lista .pedido-card {
  /* override do .pedido-card global da aba Pedidos */
  background: #fff;
  padding: 10px 12px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid #f0f0f0;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  margin-bottom: 0;
}
.pedidos-lista .pedido-card:last-child {
  border-bottom: 0;
}
.pedidos-lista .pedido-card:hover {
  background: #fafafa;
}
.pedidos-lista .pedido-card.selecionado {
  background: #e8f5ee;
  border-left: 3px solid #2d7a4f;
}
.pedidos-lista .pedido-card-head {
  font-size: 13px;
  font-weight: 600;
  color: #323232;
}
.pedidos-lista .pedido-card-meta {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

/* -------- Pedidos vinculados (multi-order passo 3) -------- */
.ng-pedidos-vinculados-wrapper {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 14px;
}
.ng-pedidos-vinculados {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.pedido-vinculado-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #e8f5ee;
  border: 1px solid #b8e0c5;
  border-radius: 6px;
  font-size: 12px;
  color: #1a5d3a;
}
.pedido-vinculado-item strong {
  color: #2d7a4f;
}
.btn-remover-pedido {
  background: none;
  border: 0;
  color: #c00;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  font-family: inherit;
  font-weight: 700;
}
.btn-remover-pedido:hover {
  color: #900;
}
.btn-add-pedido {
  background: #fff;
  border: 1px dashed #2d7a4f;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: #2d7a4f;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s;
  width: 100%;
  text-align: center;
}
.btn-add-pedido:hover {
  background: #f0fff4;
  border-style: solid;
}

/* -------- Motivo pills -------- */
.motivo-pills {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.motivo-grupo {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 8px 10px;
}
.motivo-grupo-label {
  display: block;
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  font-weight: 700;
}
.motivo-grupo button {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 5px 11px;
  margin: 2px 4px 2px 0;
  font-size: 12px;
  cursor: pointer;
  color: #555;
  font-family: inherit;
  transition: all 0.15s;
}
.motivo-grupo button:hover {
  border-color: #999;
  background: #fafafa;
}

/* Cores diferentes por categoria quando selecionado */
.motivo-grupo[data-categoria="produto"] button.selected {
  background: #2d7a4f;
  border-color: #2d7a4f;
  color: #fff;
  font-weight: 600;
}
.motivo-grupo[data-categoria="logistica"] button.selected {
  background: #b8860b;
  border-color: #b8860b;
  color: #fff;
  font-weight: 600;
}
.motivo-grupo[data-categoria="financeira"] button.selected {
  background: #c00;
  border-color: #c00;
  color: #fff;
  font-weight: 600;
}

/* -------- Itens afetados (passo 3 condicional) -------- */
.ng-itens-row {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
}
.ng-itens-lista {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.item-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s;
}
.item-check:hover {
  border-color: #2d7a4f;
}
.item-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
}
.item-nome {
  flex: 1;
  color: #323232;
  line-height: 1.3;
  word-break: break-word;
}
.item-valor {
  color: #2d7a4f;
  font-weight: 600;
  flex: 0 0 auto;
  white-space: nowrap;
}

/* -------- Form rows -------- */
.ng-textarea-label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: #555;
  font-weight: 600;
}
.ng-textarea-label textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 64px;
  color: #323232;
  background: #fff;
}
.ng-textarea-label textarea:focus {
  outline: none;
  border-color: #2d7a4f;
  box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.12);
}

.ng-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.ng-row label {
  flex: 1;
  font-size: 12px;
  color: #555;
  font-weight: 600;
  display: flex;
  flex-direction: column;
}
.ng-row input,
.ng-row select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #323232;
}
.ng-row input:focus,
.ng-row select:focus {
  outline: none;
  border-color: #2d7a4f;
  box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.12);
}

/* -------- Upload zone -------- */
.upload-dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 14px;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
}
.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: #2d7a4f;
  background: #f0fff4;
}
.upload-icon {
  font-size: 28px;
  margin-bottom: 4px;
  line-height: 1;
}
.upload-text {
  font-size: 12px;
  color: #555;
  line-height: 1.4;
}
.upload-text small {
  display: block;
  font-size: 10px;
  color: #888;
  margin-top: 4px;
}

.ng-anexos-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.anexo-preview-item {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #444;
  max-width: 100%;
}
.anexo-nome {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-anexo-remover {
  background: none;
  border: 0;
  color: #c00;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  font-family: inherit;
  font-weight: 700;
}
.btn-anexo-remover:hover {
  color: #900;
}

/* -------- Botoes auxiliares -------- */
.btn-block {
  width: 100%;
}
.btn-link-warn {
  background: none;
  border: 0;
  color: #c00;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0;
  font-family: inherit;
}
.btn-link-warn:hover {
  color: #900;
}

/* -------- Empty state (quando nenhuma garantia) -------- */
.garantias-lista .empty-msg,
.rastreio-section .empty-msg {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 13px;
  background: #f8f9fa;
  border-radius: 8px;
}

/* -------- Responsivo -------- */
@media (max-width: 640px) {
  .garantias-header {
    flex-direction: column;
    align-items: stretch;
  }
  .garantias-filtros {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .garantias-filtros button {
    white-space: nowrap;
    flex: 0 0 auto;
  }
  .ng-row {
    flex-direction: column;
    gap: 8px;
  }
  .modal-garantia {
    padding: 12px;
  }
  .cpf-row {
    flex-direction: column;
  }
  .cpf-row button {
    width: 100%;
  }
  .anexo-nome {
    max-width: 120px;
  }
}

/* ===========================================================
   Panorama Garantias (admin) — J1
   Reusa .admin-resumo-cards / .admin-card / .admin-tabela
   Override: 4 colunas em vez de 3
   =========================================================== */
#admin-garantias-panorama .admin-resumo-cards.admin-garantias-cards {
  grid-template-columns: repeat(4, 1fr);
}
#admin-garantias-panorama .admin-tabela {
  font-size: 12px;
}
#admin-garantias-panorama .admin-tabela th {
  font-size: 11px;
}
.admin-garantias-parados {
  margin-top: 4px;
}
@media (max-width: 640px) {
  #admin-garantias-panorama .admin-resumo-cards.admin-garantias-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Feature: Transferir entre categorias — grupo ativo fica destacado */
.motivo-grupo[data-categoria=produto].ativo {
  border: 2px solid #2d7a4f;
  background: #f0f8f4;
}
.motivo-grupo[data-categoria=logistica].ativo {
  border: 2px solid #b8860b;
  background: #fdf8f0;
}
.motivo-grupo[data-categoria=financeira].ativo {
  border: 2px solid #c00;
  background: #fff5f5;
}

/* ========================================================
   Sub-tabs garantias/devoluções/rastreio
   ======================================================== */
.gr-sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e0d5f0;
  margin-bottom: 14px;
  background: #f8f5fc;
}
.gr-sub-tab-btn {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  color: #88529d;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}
.gr-sub-tab-btn.active {
  border-bottom-color: #88529d;
  background: #fff;
  color: #5a2d82;
}
.gr-painel { display: none; }
.gr-painel.ativo { display: block; }

/* Toggle Minhas / Todas */
.garantias-modo-wrap {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.garantia-modo-btn {
  flex: 1;
  padding: 7px;
  border: 1.5px solid #88529d;
  border-radius: 8px;
  background: #fff;
  color: #88529d;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.garantia-modo-btn.active {
  background: #88529d;
  color: #fff;
}

/* Busca garantias */
.garantias-busca-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.garantias-busca-input {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  font-size: .9rem;
}
.garantias-busca-input:focus { outline: none; border-color: #88529d; }

/* Expansão inline para admin */
.ga-inline-detalhe {
  border-top: 1px solid #e0d5f0;
  margin-top: 10px;
  padding-top: 10px;
  display: none;
}
.ga-inline-detalhe.aberto { display: block; }
.ga-expandir-btn {
  width: 100%;
  margin-top: 8px;
  padding: 7px;
  border: 1.5px solid #e0d5f0;
  border-radius: 8px;
  background: #f8f5fc;
  color: #88529d;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
