/* =====================================================
   PiataFood / Delivery Max — CSS portado do design system
   Tokens de src/index.css e tailwind.config.ts
   ===================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap");

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: 355 85% 51%; /* Vermelho iFood #EA1D2C */
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 355 85% 51%;
  --radius: 0.5rem;
  --success: 142 71% 45%;
  --sidebar-background: 0 0% 98%;
  --sidebar-foreground: 240 5.3% 26.1%;
  --sidebar-accent: 240 4.8% 95.9%;
  --sidebar-border: 220 13% 91%;
  --delivery-50: 355 100% 97%;
  --delivery-100: 355 100% 94%;
  --delivery-500: 355 85% 51%;
  --delivery-600: 355 85% 45%;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --sidebar-background: 240 10% 3.9%;
  --sidebar-foreground: 0 0% 98%;
  --sidebar-accent: 240 3.7% 15.9%;
  --sidebar-border: 240 3.7% 15.9%;
}

* { box-sizing: border-box; border-color: hsl(var(--border)); }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-feature-settings: "rlig" 1, "calt" 1;
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Poppins", "Inter", sans-serif;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

a { color: inherit; }
img { max-width: 100%; display: block; }

.text-muted { color: hsl(var(--muted-foreground)); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s, opacity 0.2s;
  min-height: 2.5rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: hsl(var(--delivery-500)); color: #fff; }
.btn-primary:hover { background: hsl(var(--delivery-600)); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { background: hsl(var(--accent)); }
.btn-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.btn-outline:hover { background: hsl(var(--secondary)); }
.btn-destructive { background: hsl(var(--destructive)); color: #fff; }
.btn-success { background: hsl(var(--success)); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: hsl(var(--secondary)); }
.btn-sm { padding: 0.25rem 0.625rem; min-height: 2rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0.5rem; min-width: 2.5rem; }

/* ---------- Cards ---------- */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  padding: 1.25rem;
}
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-default { background: hsl(var(--delivery-500)); color: #fff; }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { background: transparent; border-color: hsl(var(--border)); color: hsl(var(--foreground)); }
.badge-destructive { background: hsl(var(--destructive)); color: #fff; }
.badge-success { background: hsl(var(--success)); color: #fff; }

/* ---------- Formulários ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  min-height: 2.5rem;
}
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 1px;
}
.field-error { color: hsl(var(--destructive)); font-size: 0.8125rem; margin-top: 0.25rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; }
.checkbox-row input { width: 1rem; height: 1rem; accent-color: hsl(var(--delivery-500)); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  text-align: left;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.table td { padding: 0.625rem 0.75rem; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tr:hover td { background: hsl(var(--muted) / 0.5); }

/* ---------- Layout admin ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 16rem;
  flex-shrink: 0;
  background: hsl(var(--sidebar-background));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 4rem;
  padding: 0 1rem;
  border-bottom: 1px solid hsl(var(--sidebar-border));
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
  color: hsl(var(--foreground));
}
.sidebar-brand .brand-icon {
  background: hsl(var(--delivery-500));
  color: #fff;
  width: 2rem;
  height: 2rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.sidebar nav { flex: 1; padding: 1rem 0.75rem; display: grid; gap: 0.375rem; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.75rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--sidebar-foreground));
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: hsl(var(--sidebar-accent)); }
.sidebar nav a.active {
  background: hsl(var(--sidebar-accent));
  border-left-color: hsl(var(--delivery-500));
  color: hsl(var(--foreground));
}
.sidebar nav a .nav-icon { width: 1.25rem; text-align: center; }
.sidebar-footer {
  border-top: 1px solid hsl(var(--sidebar-border));
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  background: hsl(var(--delivery-500));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-header {
  height: 4rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: hsl(var(--background));
  z-index: 30;
}
.admin-content { padding: 1.5rem; flex: 1; }

/* Menu mobile */
.mobile-nav-toggle { display: none; }
@media (max-width: 767px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform 0.3s; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 40; }
  .sidebar-overlay.open { display: block; }
  .mobile-nav-toggle { display: inline-flex; }
  .admin-content { padding: 1rem; }
}

/* ---------- Grids ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

.stat-card .stat-label { font-size: 0.8125rem; color: hsl(var(--muted-foreground)); }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0; }
.stat-trend-up { color: hsl(var(--success)); font-size: 0.75rem; }
.stat-trend-down { color: hsl(var(--destructive)); font-size: 0.75rem; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; background: hsl(var(--muted)); border-radius: var(--radius); padding: 0.25rem; gap: 0.25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a {
  padding: 0.375rem 0.875rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  color: hsl(var(--muted-foreground));
}
.tabs a.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(240px, 1fr)); gap: 1rem; overflow-x: auto; align-items: start; }
@media (max-width: 1100px) { .kanban { display: flex; } .kanban-col { min-width: 260px; } }
.kanban-col { background: hsl(var(--muted) / 0.6); border-radius: var(--radius); padding: 0.75rem; }
.kanban-col h4 { display: flex; justify-content: space-between; font-size: 0.875rem; margin-bottom: 0.75rem; }
.kanban-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.75rem; font-size: 0.875rem; }
.kanban-card .actions { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; }

/* ---------- Catálogo público ---------- */
.public-header { position: relative; }
.public-banner { height: 180px; background: hsl(var(--delivery-500)); background-size: cover; background-position: center; }
@media (min-width: 640px) { .public-banner { height: 240px; } }
.public-restaurant {
  max-width: 64rem;
  margin: -3rem auto 0;
  padding: 0 1rem;
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}
.public-logo {
  width: 5rem;
  height: 5rem;
  border-radius: 1rem;
  border: 3px solid #fff;
  background: #fff;
  object-fit: cover;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
}
.public-container { max-width: 64rem; margin: 0 auto; padding: 1rem; }
.category-filter { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; margin-bottom: 1rem; }
.category-filter .chip {
  flex-shrink: 0;
  border: 1px solid hsl(var(--border));
  border-radius: 9999px;
  background: hsl(var(--background));
  padding: 0.375rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
}
.category-filter .chip.active { background: hsl(var(--delivery-500)); border-color: hsl(var(--delivery-500)); color: #fff; }

.product-card {
  display: flex;
  gap: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem;
  background: hsl(var(--card));
  transition: box-shadow 0.2s, transform 0.2s;
}
.product-card:hover { box-shadow: 0 8px 20px rgb(0 0 0 / 0.08); transform: translateY(-2px); }
.product-card img { width: 6rem; height: 6rem; object-fit: cover; border-radius: calc(var(--radius) - 2px); flex-shrink: 0; }
.product-card .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.product-card .info p { margin: 0.25rem 0; font-size: 0.8125rem; color: hsl(var(--muted-foreground)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card .price-row { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.product-card .price { font-weight: 700; color: hsl(var(--delivery-500)); }
.public-products { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) { .public-products { grid-template-columns: 1fr 1fr; } }

/* ---------- Carrinho flutuante / drawer ---------- */
.cart-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  background: hsl(var(--delivery-500));
  color: #fff;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgb(234 29 44 / 0.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-fab .badge-count {
  position: absolute;
  top: -0.375rem;
  right: -0.375rem;
  min-width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: hsl(var(--delivery-600));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
}
.drawer-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 60; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: 100%;
  max-width: 28rem;
  background: hsl(var(--background));
  z-index: 70;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgb(0 0 0 / 0.15);
}
.drawer-header {
  flex-shrink: 0;
  padding: 1rem;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem; }
.drawer-footer { flex-shrink: 0; padding: 1rem; border-top: 1px solid hsl(var(--border)); background: hsl(var(--background)); }
.cart-item { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.cart-item img { width: 4rem; height: 4rem; border-radius: calc(var(--radius) - 2px); object-fit: cover; flex-shrink: 0; }
.qty-control { display: inline-flex; align-items: center; border: 1px solid hsl(var(--border)); border-radius: var(--radius); }
.qty-control button { border: none; background: transparent; width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem; }
.qty-control span { width: 2rem; text-align: center; font-size: 0.875rem; }
.order-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  min-height: 120px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  text-align: center;
  width: 100%;
}
.order-type-option:hover { background: hsl(var(--secondary)); }
.order-type-option .icon-circle {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 9999px;
  background: hsl(var(--delivery-100));
  color: hsl(var(--delivery-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.payment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.payment-option {
  border: 2px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  font-size: 0.875rem;
  background: hsl(var(--background));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.payment-option input { position: absolute; opacity: 0; }
.payment-option:has(input:checked) { border-color: hsl(var(--delivery-500)); background: hsl(var(--delivery-50)); }

/* ---------- Toasts ---------- */
#toast-region {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  max-width: 22rem;
}
.toast {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-left: 4px solid hsl(var(--delivery-500));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
  animation: toast-in 0.25s ease-out;
}
.toast-success { border-left-color: hsl(var(--success)); }
.toast-error { border-left-color: hsl(var(--destructive)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }

/* ---------- Tracker ---------- */
.tracker-steps { display: flex; flex-direction: column; gap: 0; margin: 1rem 0; }
.tracker-step { display: flex; gap: 0.75rem; position: relative; padding-bottom: 1.5rem; }
.tracker-step:last-child { padding-bottom: 0; }
.tracker-step::before {
  content: "";
  position: absolute;
  left: 0.9375rem;
  top: 2rem;
  bottom: 0;
  width: 2px;
  background: hsl(var(--border));
}
.tracker-step:last-child::before { display: none; }
.tracker-dot {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  font-size: 0.875rem;
}
.tracker-step.done .tracker-dot { background: hsl(var(--success)); color: #fff; }
.tracker-step.current .tracker-dot { background: hsl(var(--delivery-500)); color: #fff; }
.tracker-step.done::before { background: hsl(var(--success)); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.5);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal {
  background: hsl(var(--background));
  border-radius: calc(var(--radius) + 4px);
  width: 100%;
  max-width: 34rem;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ---------- Login ---------- */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--muted) / 0.5);
  padding: 1rem;
}
.auth-card { width: 100%; max-width: 26rem; }

/* ---------- HTMX indicators ---------- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--delivery-500));
  border-radius: 9999px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Impressão 80mm ---------- */
@media print {
  body * { visibility: hidden; }
  .print-receipt, .print-receipt * { visibility: visible; }
  .print-receipt { position: absolute; left: 0; top: 0; width: 80mm; }
  @page { margin: 0; size: 80mm 297mm; }
}
.print-receipt { font-family: "Courier New", monospace; font-size: 12px; width: 80mm; padding: 4mm; }
.print-receipt hr { border: none; border-top: 1px dashed #000; }
.print-receipt table { width: 100%; font-size: 11px; border-collapse: collapse; }
.print-receipt td { padding: 1px 0; vertical-align: top; }

/* Alpine.js — hide until initialized */
[x-cloak] { display: none !important; }
