/* =====================================================
   PAINEL ADMINISTRATIVO  Alpha UltraPress
   Drawer lateral com gestáo de produtos
   ===================================================== */

/* -- Overlay escuro de fundo ---------------------- */
.ap-overlay {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(10, 12, 18, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.ap-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* -- Painel (drawer da direita) ------------------- */
.ap-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(92vw, 980px);
  background: #f4f5f8;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.ap-overlay.is-open .ap-panel {
  transform: translateX(0);
}

/* -- Header do painel ----------------------------- */
.ap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: linear-gradient(120deg, #16181d 0%, #2a2f3a 100%);
  border-bottom: 2px solid rgba(227, 27, 35, 0.4);
  flex-shrink: 0;
}

.ap-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ap-header-left > i {
  font-size: 1.5rem;
  color: #e31b23;
  flex-shrink: 0;
}

.ap-header-title {
  margin: 0 0 2px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  font-family: 'Inter', 'Poppins', sans-serif;
  letter-spacing: -0.01em;
}

.ap-header-sub {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Inter', sans-serif;
}

.ap-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s, transform 0.18s;
}

.ap-close:hover {
  background: rgba(227, 27, 35, 0.2);
  color: #fff;
  transform: rotate(90deg);
}

/* -- Mtricas (stats bar) ------------------------- */
.ap-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #dde0e8;
  border-bottom: 1px solid #dde0e8;
  flex-shrink: 0;
}

.ap-stat {
  background: #fff;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ap-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6f7786;
  font-family: 'Inter', sans-serif;
}

.ap-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: #1a1d24;
  font-family: 'Inter', 'Poppins', sans-serif;
}

.ap-stat-value.is-active  { color: #1a7a38; }
.ap-stat-value.is-inactive { color: #b11d24; }

/* -- Toolbar (busca + filtros) -------------------- */
.ap-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: #fff;
  border-bottom: 1px solid #e4e7ee;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.ap-search {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f2f6;
  border: 1px solid #dde0e8;
  border-radius: 10px;
  padding: 0 12px;
  height: 40px;
}

.ap-search i {
  color: #9aa0ab;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.ap-search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  color: #1a1d24;
}

.ap-search input::placeholder {
  color: #9aa0ab;
}

.ap-filters {
  display: flex;
  gap: 6px;
}

.ap-filter-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid #dde0e8;
  background: #f0f2f6;
  font-size: 0.8rem;
  font-weight: 600;
  color: #5f6775;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.16s;
}

.ap-filter-btn:hover {
  background: #e4e7ee;
  color: #1a1d24;
}

.ap-filter-btn.is-active {
  background: #1a1d24;
  color: #fff;
  border-color: #1a1d24;
}

/* -- Lista de produtos (scrollvel) --------------- */
.ap-products {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ap-products::-webkit-scrollbar {
  width: 6px;
}

.ap-products::-webkit-scrollbar-track {
  background: #f0f2f6;
}

.ap-products::-webkit-scrollbar-thumb {
  background: #c8cdd8;
  border-radius: 3px;
}

/* -- Card de produto ------------------------------- */
.ap-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e4e7ee;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0;
  overflow: hidden;
  transition: box-shadow 0.18s;
}

.ap-card:hover {
  box-shadow: 0 4px 18px rgba(16, 20, 30, 0.08);
}

.ap-card.is-dirty {
  border-color: rgba(227, 27, 35, 0.35);
  box-shadow: 0 0 0 2px rgba(227, 27, 35, 0.08);
}

/* Thumbnail */
.ap-card-img {
  width: 88px;
  background: #f8f9fb;
  border-right: 1px solid #e4e7ee;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 10px;
}

.ap-card-img img {
  width: 100%;
  height: 80px;
  object-fit: contain;
  border-radius: 6px;
}

/* Corpo do card */
.ap-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Topo: nome + status toggle */
.ap-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ap-card-meta {
  flex: 1;
  min-width: 0;
}

.ap-card-category {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #e31b23;
  margin-bottom: 3px;
  font-family: 'Inter', sans-serif;
}

.ap-card-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: #1a1d24;
  font-family: 'Inter', 'Poppins', sans-serif;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -- Toggle de status Ativo / Inativo ------------- */
.ap-status-toggle {
  display: flex;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dde0e8;
}

.ap-status-btn {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  border: none;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
  background: #f0f2f6;
  color: #9aa0ab;
  letter-spacing: 0.02em;
}

.ap-status-btn:first-child {
  border-right: 1px solid #dde0e8;
}

/* Estado ATIVO selecionado */
.ap-status-btn[data-status="active"].is-selected {
  background: #1a7a38;
  color: #fff;
}

/* Estado INATIVO selecionado */
.ap-status-btn[data-status="inactive"].is-selected {
  background: #b11d24;
  color: #fff;
}

/* Hover */
.ap-status-btn[data-status="active"]:not(.is-selected):hover {
  background: #d4edda;
  color: #1a7a38;
}

.ap-status-btn[data-status="inactive"]:not(.is-selected):hover {
  background: #fde8e8;
  color: #b11d24;
}

/* -- Campos editveis ----------------------------- */
.ap-fields {
  display: grid;
  grid-template-columns: 1fr 100px 100px;
  gap: 10px;
  align-items: start;
}

.ap-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ap-field label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6f7786;
  font-family: 'Inter', sans-serif;
}

.ap-input {
  width: 100%;
  border: 1px solid #dde0e8;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.86rem;
  font-family: 'Inter', sans-serif;
  color: #1a1d24;
  background: #f8f9fb;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  box-sizing: border-box;
}

.ap-input:focus {
  border-color: rgba(227, 27, 35, 0.6);
  box-shadow: 0 0 0 3px rgba(227, 27, 35, 0.08);
  background: #fff;
}

textarea.ap-input {
  resize: vertical;
  min-height: 48px;
  line-height: 1.5;
}

/* -- Rodapé com botão salvar --------------------- */
.ap-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: #fff;
  border-top: 1px solid #e4e7ee;
  flex-shrink: 0;
  gap: 14px;
}

.ap-save-status {
  font-size: 0.82rem;
  color: #6f7786;
  font-family: 'Inter', sans-serif;
  flex: 1;
}

.ap-save-status.is-saved {
  color: #1a7a38;
  font-weight: 600;
}

.ap-save-status.is-dirty {
  color: #b11d24;
  font-weight: 600;
}

.ap-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: 'Inter', 'Poppins', sans-serif;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(120deg, #8f1117, #e31b23);
  box-shadow: 0 6px 18px rgba(227, 27, 35, 0.28);
  transition: transform 0.16s, box-shadow 0.16s, filter 0.16s;
}

.ap-btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(227, 27, 35, 0.34);
  filter: brightness(1.06);
}

.ap-btn-save:active {
  transform: translateY(0);
}

.ap-btn-save:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* -- Empty state ---------------------------------- */
.ap-empty {
  text-align: center;
  padding: 48px 24px;
  color: #9aa0ab;
  font-family: 'Inter', sans-serif;
}

.ap-empty i {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* -- Responsivo ----------------------------------- */
@media (max-width: 680px) {
  .ap-panel {
    width: 100vw;
  }

  .ap-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .ap-card {
    grid-template-columns: 72px 1fr;
  }

  .ap-card-img {
    width: 72px;
  }

  .ap-fields {
    grid-template-columns: 1fr 1fr;
  }

  .ap-fields .ap-field:first-child {
    grid-column: 1 / -1;
  }

  .ap-card-top {
    flex-wrap: wrap;
  }

  .ap-header {
    padding: 14px 16px;
  }

  .ap-toolbar,
  .ap-products {
    padding-left: 16px;
    padding-right: 16px;
  }

  .ap-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
}

/* --------------------------------------------------
   SISTEMA DE ABAS
-------------------------------------------------- */
.ap-tabs {
  display: flex;
  gap: 0;
  background: #1e2130;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 24px;
  flex-shrink: 0;
}

.ap-tab-btn {
  padding: 13px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter','Poppins',sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: color 0.18s, border-color 0.18s;
  margin-bottom: -1px;
}

.ap-tab-btn i { font-size: 12px; }

.ap-tab-btn:hover { color: rgba(255,255,255,0.75); }

.ap-tab-btn.is-active {
  color: #fff;
  border-bottom-color: #ED1C24;
}

.ap-tab-pane {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.ap-tab-pane.is-active {
  display: flex;
}

/* --------------------------------------------------
   ABA OFERTAS  Formulário
-------------------------------------------------- */
.ap-offer-form-wrap {
  background: #fff;
  border-bottom: 1px solid #e8eaf0;
  padding: 20px 24px;
  flex-shrink: 0;
}

.ap-offer-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ap-offer-form-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.ap-offer-form-header h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: #ED1C24;
  border-radius: 2px;
}

.ap-offer-form-cancel {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}
.ap-offer-form-cancel:hover { background: #f0f0f0; }

.ap-offer-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.ap-ofield--wide { grid-column: 1 / 3; }

.ap-ofield label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #666;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ap-ofield input,
.ap-ofield select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #dde1e9;
  border-radius: 7px;
  font-size: 13px;
  color: #1a1a1a;
  background: #fafbfd;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  box-sizing: border-box;
  font-family: inherit;
}

.ap-ofield input:focus,
.ap-ofield select:focus {
  border-color: #ED1C24;
  box-shadow: 0 0 0 3px rgba(237,28,36,0.08);
  background: #fff;
}

.ap-offer-form-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #fff8f8;
  border: 1px solid #ffd0d0;
  border-radius: 7px;
  font-size: 13px;
  color: #444;
  flex-wrap: wrap;
}

.ap-offer-arrow { color: #ED1C24; font-weight: 700; }

.ap-offer-savings {
  background: #ED1C24;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.ap-offer-form-actions {
  margin-top: 14px;
}

.ap-offer-submit {
  padding: 10px 22px;
  background: #ED1C24;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  transition: background 0.18s;
}
.ap-offer-submit:hover { background: #c41019; }

/* --------------------------------------------------
   ABA OFERTAS  Listas
-------------------------------------------------- */
.ap-offers-lists {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
}

.ap-offers-section {
  margin-bottom: 28px;
}

.ap-offers-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #888;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ap-offers-section-title .badge {
  background: #f0f2f6;
  color: #555;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
}

.ap-offers-section-title .badge.ativa   { background: #dcfce7; color: #166534; }
.ap-offers-section-title .badge.agendada { background: #fef9c3; color: #854d0e; }
.ap-offers-section-title .badge.encerrada { background: #f3f4f6; color: #6b7280; }

.ap-offer-empty {
  font-size: 13px;
  color: #bbb;
  padding: 10px 0 4px;
}

/* Linha de oferta */
.ap-offer-row {
  background: #fff;
  border: 1px solid #e8eaf0;
  border-radius: 10px;
  padding: 13px 16px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 56px 1fr auto auto auto;
  gap: 12px;
  align-items: center;
}

.ap-offer-img {
  width: 56px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: #f0f2f6;
}

.ap-offer-info { min-width: 0; }

.ap-offer-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-offer-meta {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
}

.ap-offer-prices {
  text-align: right;
  white-space: nowrap;
}

.ap-offer-price-orig {
  font-size: 12px;
  color: #aaa;
  text-decoration: line-through;
}

.ap-offer-price-promo {
  font-size: 15px;
  font-weight: 800;
  color: #ED1C24;
}

.ap-offer-discount-badge {
  background: #ED1C24;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.ap-offer-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  white-space: nowrap;
}

.ap-offer-status-badge.ativa     { background: #dcfce7; color: #166534; }
.ap-offer-status-badge.agendada  { background: #fef9c3; color: #854d0e; }
.ap-offer-status-badge.encerrada { background: #f3f4f6; color: #6b7280; }
.ap-offer-status-badge.inativa   { background: #fee2e2; color: #991b1b; }

.ap-offer-actions {
  display: flex;
  gap: 6px;
}

.ap-offer-act-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #e0e3ea;
  border-radius: 6px;
  background: #fafbfd;
  color: #555;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ap-offer-act-btn:hover { background: #f0f2f6; }
.ap-offer-act-btn.del:hover { background: #fee2e2; color: #c41019; border-color: #fca5a5; }
.ap-offer-act-btn.edit:hover { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }

@media (max-width: 720px) {
  .ap-offer-form-grid { grid-template-columns: 1fr 1fr; }
  .ap-ofield--wide { grid-column: 1 / -1; }
  .ap-offer-row { grid-template-columns: 1fr auto; }
  .ap-offer-img { display: none; }
  .ap-offer-prices, .ap-offer-discount-badge { display: none; }
}
