/* ============================================================
   Vendas — Design System
   ============================================================ */

/* --- Variables -------------------------------------------- */
:root {
  --ink:        #0f172a;
  --ink-soft:   #334155;
  --muted:      #64748b;
  --line:       #e2e8f0;
  --line-light: #f1f5f9;
  --brand:      #059669;
  --brand-dark: #047857;
  --brand-light:#d1fae5;
  --bg:         #f8fafc;
  --card:       #ffffff;
  --danger:     #dc2626;
  --danger-bg:  #fef2f2;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --radius:     12px;
  --radius-lg:  16px;
  --transition: .2s ease;
}

/* --- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; display: block; }

/* --- Header ----------------------------------------------- */
.header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 max(24px, calc((100% - 1140px) / 2));
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}

.header-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.5px;
}

.header-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all var(--transition);
}

.header-nav a:hover {
  color: var(--ink);
  background: var(--line-light);
}

.header-nav,
#admin-menu-slot {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Login Modal ------------------------------------------ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: fadeIn .2s ease;
}

.modal h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  color: var(--ink);
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
}

/* --- Layout ----------------------------------------------- */
.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  font-family: inherit;
  line-height: 1.4;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(5,150,105,.25);
}
.btn-primary:hover { background: var(--brand-dark); }

.btn-secondary {
  background: var(--line-light);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--line); }

.btn-dark {
  background: var(--ink);
  color: #fff;
}
.btn-dark:hover { background: #1e293b; }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 600;
}
.btn-danger:hover { background: #fee2e2; }

.btn-outline {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-outline:hover { background: var(--line-light); border-color: #cbd5e1; }

.btn-whatsapp {
  background: var(--brand);
  color: #fff;
  width: 100%;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(5,150,105,.25);
}
.btn-whatsapp:hover { background: var(--brand-dark); }
.btn-whatsapp::before { content: "📲 "; }
.btn-resale { background: #0f766e; margin-top: 8px; }
.btn-resale:hover { background: #115e59; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

/* --- Resumo particular de lucro ---------------------------------------- */
.profit-preview {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  border-radius: var(--radius);
}

.profit-preview-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--brand-dark);
  margin-bottom: 12px;
}

.profit-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.profit-preview-grid span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}

.profit-preview-grid b { color: var(--ink); white-space: nowrap; }
.profit-preview-final b, .profit-preview-grid .profit-preview-final { color: var(--brand-dark); font-size: 15px; }
.profit-preview small { display: block; color: var(--muted); margin-top: 12px; font-size: 11px; }
.profit-preview.has-invalid-cost { background: var(--danger-bg); border-color: #fecaca; }
.profit-preview.has-invalid-cost .profit-preview-title,
.profit-preview.has-invalid-cost .profit-preview-grid b { color: var(--danger); }

/* --- Alerts ----------------------------------------------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #166534;
}
.alert-success::before { content: "✓"; font-weight: 700; }

.alert-error {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: #991b1b;
}
.alert-error::before { content: "!"; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; background: #fecaca; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }

/* --- Section Header --------------------------------------- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.section-header .subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}

/* --- Category Filter -------------------------------------- */
.category-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.product-search {
  display: block;
  max-width: 360px;
  margin: 0 0 12px;
}

.category-filter .btn {
  padding: 7px 16px;
  font-size: 13px;
  border-radius: 20px;
}

.category-filter .btn.active {
  background: var(--brand);
  color: #fff;
}

.category-filter .btn:not(.active) {
  opacity: .7;
}
.category-filter .btn:not(.active):hover {
  opacity: 1;
}

/* --- Product Grid ----------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

@media (min-width: 769px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .modal-overlay {
    padding: 32px;
  }
}

/* --- Product Card ----------------------------------------- */
.product {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.product:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.product .photo-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #f8fafc;
  overflow: hidden;
}

.product .card-logo {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  opacity: .8;
  transition: opacity var(--transition);
}

.product:hover .card-logo {
  opacity: 1;
}

.product .photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .3s ease;
}

.product:hover .photo {
  transform: scale(1.03);
}

.product .no-photo {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: var(--line-light);
  color: var(--muted);
  font-size: 12px;
}

.product .no-photo::before {
  content: "🖼";
  font-size: 24px;
  display: block;
  margin-bottom: 2px;
  opacity: .5;
}

.product-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.product .category-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--brand);
  background: var(--brand-light);
  padding: 2px 7px;
  border-radius: 4px;
  width: fit-content;
}

.product h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.product .description {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
}

.product .price {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -.3px;
  margin-top: 2px;
}

.product .pickup {
  font-size: 11px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 3px;
}

.product .btn-whatsapp {
  margin-top: 4px;
  padding: 8px 12px;
  font-size: 12px;
}

.empty {
  color: var(--muted);
  padding: 50px 20px;
  text-align: center;
  font-size: 15px;
  grid-column: 1 / -1;
}

.empty::before {
  content: "📦";
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
  opacity: .5;
}

/* --- Admin Area ------------------------------------------- */
.admin-area {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 2px solid var(--line);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
}

.admin-menu {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.admin-menu-header {
  margin: 0;
  flex-wrap: nowrap;
}

.admin-menu-header .btn {
  padding: 7px 11px;
  font-size: 13px;
  white-space: nowrap;
}

.admin-area.menu-ready [data-admin-view] {
  display: none;
}

.admin-area.menu-ready [data-admin-view].is-active {
  display: block;
}

.admin-area.menu-ready .admin-grid.hidden-by-menu {
  display: none;
}

.admin-area.menu-ready .admin-grid.is-single {
  grid-template-columns: minmax(0, 760px);
}

/* --- Panel (Cards) ---------------------------------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

/* --- Multiplier Panel ------------------------------------- */
.multiplier-panel {
  margin-bottom: 24px;
}

.multiplier-panel h2 {
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.multiplier-panel .hint {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.multiplier-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.multiplier-actions label {
  min-width: 200px;
}

.point-rates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.point-rate-item {
  background: var(--brand-light);
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.brand-logo-setting {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.brand-logo-setting > div { flex: 1 1 320px; }
.brand-logo-setting b,
.brand-logo-setting small { display: block; }
.brand-logo-setting small { color: var(--muted); font-size: 12px; margin: 3px 0 8px; }
.brand-logo-setting input { max-width: 360px; }
.brand-logo-setting img { width: 86px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }

/* --- Form Fields ------------------------------------------ */
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.wide { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

input, textarea, select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  width: 100%;
  transition: all var(--transition);
  background: #fff;
  color: var(--ink);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}

input::placeholder, textarea::placeholder {
  color: #94a3b8;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
}

.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* --- Product Mini List (Admin Sidebar) -------------------- */
.mini-list {
  max-height: 520px;
  overflow-y: auto;
}

.mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-light);
}

.mini:last-child { border-bottom: none; }

.mini .thumb {
  width: 52px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--line-light);
  flex-shrink: 0;
}

.mini .thumb-empty {
  width: 52px;
  height: 44px;
  border-radius: 8px;
  background: var(--line-light);
  flex-shrink: 0;
}

.mini-info {
  flex: 1;
  min-width: 0;
}

.mini-info b {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-info span {
  display: block;
  font-size: 13px;
  color: var(--brand);
  font-weight: 600;
  margin-top: 2px;
}

.mini-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.mini-actions form { display: inline; }

/* --- Ofertas por produto --------------------------------- */
.offers-manager {
  margin-top: 28px;
}

.offer-list {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.offer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.offer-row.is-active {
  border-color: var(--brand);
  background: #f0fdf4;
}

.offer-row b,
.offer-row span {
  display: block;
}

.offer-row span {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
}

.offer-active {
  color: var(--brand-dark) !important;
  background: var(--brand-light);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
}

/* --- Footer ----------------------------------------------- */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  margin-top: 20px;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  .wrap {
    padding: 20px 16px 40px;
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-area.menu-ready .admin-grid.is-single {
    grid-template-columns: 1fr;
  }

  .admin-menu .btn {
    flex: 1 1 140px;
  }

  .header {
    padding: 0 16px;
  }

  .header-inner {
    height: auto;
    min-height: 56px;
    gap: 10px;
  }

  .header-nav {
    gap: 4px;
  }

  .admin-menu-header {
    gap: 4px;
  }

  .admin-menu-header .btn {
    padding: 6px 8px;
    font-size: 11px;
  }

  .header-nav a {
    padding: 7px 6px;
    font-size: 12px;
  }

  .offer-row {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .profit-preview-grid { grid-template-columns: 1fr; }

  .wide { grid-column: auto; }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .multiplier-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .multiplier-actions label {
    min-width: auto;
  }
}

/* --- Install Page ----------------------------------------- */
.install-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.install-box {
  max-width: 520px;
  width: 100%;
  background: var(--card);
  padding: 36px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.install-box h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.install-box h1::before {
  content: "✈ ";
}

.install-box .intro {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
  font-size: 14px;
}

.install-box label {
  margin-top: 16px;
}

.install-box label:first-of-type {
  margin-top: 0;
}

.install-box .btn {
  margin-top: 24px;
  width: 100%;
  padding: 13px;
}

/* --- Scrollbar -------------------------------------------- */
.mini-list::-webkit-scrollbar { width: 4px; }
.mini-list::-webkit-scrollbar-track { background: transparent; }
.mini-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* --- Animations ------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.product { animation: fadeIn .3s ease both; }
.product:nth-child(2) { animation-delay: .05s; }
.product:nth-child(3) { animation-delay: .1s; }
.product:nth-child(4) { animation-delay: .15s; }
.product:nth-child(5) { animation-delay: .2s; }
.product:nth-child(6) { animation-delay: .25s; }

.alert { animation: fadeIn .3s ease; }
