/* ============================================================
   Mercearia Elian – Design System
   Tema: Azul Profissional / Mobile-First
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Nunito+Sans:wght@400;600;700&display=swap');

/* ── Variables ── */
:root {
  --blue-900: #0d2240;
  --blue-800: #1a3a6b;
  --blue-700: #1e4a8a;
  --blue-600: #2563b0;
  --blue-500: #3b7dd8;
  --blue-400: #60a3f0;
  --blue-100: #dbeafe;
  --blue-50:  #eff6ff;

  --accent:   #f59e0b;
  --accent-l: #fef3c7;
  --success:  #16a34a;
  --success-l:#dcfce7;
  --danger:   #dc2626;
  --danger-l: #fee2e2;
  --warn:     #d97706;
  --warn-l:   #fef9c3;

  --gray-900: #111827;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.12);
  --shadow:    0 4px 16px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);

  --font-main: 'Nunito', sans-serif;
  --font-body: 'Nunito Sans', sans-serif;

  --header-h: 60px;
  --nav-h:    64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-main); }
input, select, textarea { font-family: var(--font-body); }
img { max-width: 100%; }

/* ── Layout ── */
#app { min-height: 100vh; }

.page {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}
.page.active { display: flex; }

.main-content {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(var(--nav-h) + 1rem);
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--blue-800);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: .75rem;
  box-shadow: var(--shadow);
}
.app-header .logo {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--white);
  letter-spacing: -.3px;
}
.app-header .logo span { color: var(--accent); }
.app-header .page-title {
  flex: 1;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  text-align: center;
}
.btn-back {
  background: none;
  border: none;
  color: var(--white);
  font-size: 1.5rem;
  padding: .25rem;
  line-height: 1;
}
.header-actions {
  display: flex;
  gap: .5rem;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--gray-300);
  display: flex;
  z-index: 100;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: .65rem;
  font-family: var(--font-main);
  font-weight: 700;
  padding: .5rem .25rem;
  transition: color .2s;
}
.bottom-nav .nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav .nav-item.active { color: var(--blue-700); }
.bottom-nav .nav-item.active .nav-icon { transform: scale(1.15); }

/* ── Sidebar (Desktop) ── */
@media (min-width: 768px) {
  .desktop-layout {
    display: flex;
    min-height: 100vh;
  }
  .sidebar {
    width: 240px;
    background: var(--blue-900);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
  }
  .sidebar .sidebar-logo {
    padding: 0 1.5rem 1.5rem;
    font-family: var(--font-main);
    font-weight: 900;
    font-size: 1.2rem;
    color: var(--white);
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 1rem;
  }
  .sidebar .sidebar-logo span { color: var(--accent); }
  .sidebar-nav { flex: 1; }
  .sidebar-nav a, .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.5rem;
    color: rgba(255,255,255,.7);
    font-family: var(--font-main);
    font-weight: 600;
    font-size: .9rem;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: all .2s;
  }
  .sidebar-nav a:hover, .sidebar-nav button:hover {
    background: rgba(255,255,255,.08);
    color: var(--white);
  }
  .sidebar-nav a.active, .sidebar-nav button.active {
    background: var(--blue-700);
    color: var(--white);
  }
  .sidebar-nav .nav-icon { font-size: 1.1rem; }
  .sidebar-bottom {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .desktop-content {
    margin-left: 240px;
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  .bottom-nav { display: none; }
  .main-content { padding-bottom: 1.5rem; max-width: 100%; padding: 1.5rem 2rem; }
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.05);
}
.card + .card { margin-top: .75rem; }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.05);
}
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.stat-card .stat-val {
  font-family: var(--font-main);
  font-size: 2rem;
  font-weight: 900;
  color: var(--blue-800);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: .75rem;
  color: var(--gray-500);
  font-weight: 600;
  margin-top: .25rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 1.5rem;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .95rem;
  border: none;
  transition: all .2s;
  min-height: 48px;
  cursor: pointer;
}
.btn-primary {
  background: var(--blue-700);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(30,74,138,.3);
}
.btn-primary:hover { background: var(--blue-800); }
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-300); }

.btn-accent {
  background: var(--accent);
  color: var(--gray-900);
  box-shadow: 0 4px 12px rgba(245,158,11,.3);
}
.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-success {
  background: var(--success);
  color: var(--white);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--blue-600);
  color: var(--blue-700);
}

.btn-full { width: 100%; }
.btn-sm { padding: .5rem 1rem; font-size: .85rem; min-height: 36px; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; min-height: 56px; }

/* ── Action cards (menu principal repositor) ── */
.action-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  min-height: 130px;
}
.action-card:hover, .action-card:active { border-color: var(--blue-500); transform: translateY(-2px); }
.action-card .action-icon { font-size: 2.5rem; }
.action-card .action-label {
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--blue-800);
}
.action-card .action-sub { font-size: .8rem; color: var(--gray-500); }
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.actions-grid .action-card-full {
  grid-column: 1 / -1;
}

/* ── Produto Counter (operação) ── */
.product-counter {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-300);
  transition: border-color .2s, box-shadow .2s;
  margin-bottom: .65rem;
}
.product-counter.has-qty {
  border-color: var(--blue-400);
  box-shadow: 0 2px 12px rgba(59,125,216,.15);
}
.product-info { flex: 1; min-width: 0; }
.product-name {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .95rem;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-sub { font-size: .75rem; color: var(--gray-500); }
.counter-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.counter-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--blue-600);
  background: var(--white);
  color: var(--blue-700);
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.counter-btn:active {
  background: var(--blue-600);
  color: var(--white);
  transform: scale(.92);
}
.counter-input {
  width: 52px;
  height: 44px;
  text-align: center;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--blue-800);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  cursor: pointer;
  -moz-appearance: textfield;
}
.counter-input::-webkit-outer-spin-button,
.counter-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.counter-input:focus {
  outline: none;
  border-color: var(--blue-500);
  background: var(--blue-50);
}
.counter-input.nonzero { color: var(--blue-700); background: var(--blue-50); border-color: var(--blue-400); }

/* ── Checklist item ── */
.checklist-item {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-300);
  margin-bottom: .65rem;
  transition: all .2s;
  cursor: pointer;
}
.checklist-item.done {
  background: var(--success-l);
  border-color: var(--success);
  opacity: .8;
}
.checklist-item.falta {
  background: var(--danger-l);
  border-color: var(--danger);
}
.check-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2.5px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  transition: all .2s;
}
.checklist-item.done .check-icon {
  background: var(--success);
  border-color: var(--success);
  color: var(--white);
}
.checklist-item .check-label { flex: 1; }
.checklist-item .check-name {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .95rem;
}
.checklist-item .check-qty {
  font-family: var(--font-main);
  font-size: .85rem;
  color: var(--gray-500);
}
.badge-qty {
  background: var(--blue-700);
  color: var(--white);
  border-radius: 20px;
  padding: .2rem .75rem;
  font-family: var(--font-main);
  font-weight: 800;
  font-size: .9rem;
}

/* ── Progress Bar ── */
.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width .4s ease;
}

/* ── Forms ── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
  display: block;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .85rem;
  color: var(--gray-700);
  margin-bottom: .4rem;
}
.form-control {
  width: 100%;
  padding: .8rem 1rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: var(--font-body);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color .2s;
  min-height: 48px;
}
.form-control:focus { outline: none; border-color: var(--blue-500); }
.form-control.error { border-color: var(--danger); }
select.form-control { cursor: pointer; }

/* ── Badge / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .7rem;
  border-radius: 999px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-blue     { background: var(--blue-100); color: var(--blue-800); }
.badge-success  { background: var(--success-l); color: var(--success); }
.badge-warn     { background: var(--warn-l); color: var(--warn); }
.badge-danger   { background: var(--danger-l); color: var(--danger); }
.badge-gray     { background: var(--gray-100); color: var(--gray-700); }

/* ── List items ── */
.list-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.06);
  margin-bottom: .5rem;
  cursor: pointer;
  transition: transform .15s;
}
.list-item:active { transform: scale(.99); }
.list-item .item-icon {
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  background: var(--blue-50);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.list-item .item-body { flex: 1; min-width: 0; }
.list-item .item-title {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .item-sub { font-size: .78rem; color: var(--gray-500); margin-top: .15rem; }
.list-item .item-arrow { color: var(--gray-400); font-size: 1.1rem; }

/* ── Search ── */
.search-bar {
  position: relative;
  margin-bottom: 1rem;
}
.search-bar input {
  width: 100%;
  padding: .8rem 1rem .8rem 2.8rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-xl);
  font-size: .95rem;
  font-family: var(--font-body);
  background: var(--white);
  min-height: 48px;
}
.search-bar input:focus { outline: none; border-color: var(--blue-500); }
.search-bar .search-icon {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 1.1rem;
  pointer-events: none;
}

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
  margin-top: .5rem;
}
.section-title {
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 1rem;
  color: var(--gray-900);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .3s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title {
  font-family: var(--font-main);
  font-weight: 800;
  font-size: 1.1rem;
}
.modal-close {
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  cursor: pointer;
}

/* ── Toast ── */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + .75rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}
.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: .85rem 1.25rem;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: .9rem;
  text-align: center;
  animation: toastIn .3s ease, toastOut .3s ease 2.5s forwards;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warn    { background: var(--warn); color: var(--gray-900); }
@keyframes toastIn  { from { opacity:0; transform:translateY(-12px); } to { opacity:1; transform:translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; } }

/* ── Login ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--blue-900) 0%, var(--blue-700) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon { font-size: 3rem; }
.login-logo h1 {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--blue-900);
  margin-top: .5rem;
}
.login-logo h1 span { color: var(--blue-600); }

/* ── Summary bar ── */
.summary-bar {
  background: var(--blue-50);
  border: 1.5px solid var(--blue-200);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.summary-item { text-align: center; }
.summary-val {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--blue-800);
  line-height: 1;
}
.summary-lbl { font-size: .72rem; color: var(--gray-500); font-weight: 600; margin-top: .15rem; }

/* ── Floating action bar ── */
.fab-bar {
  position: fixed;
  bottom: calc(var(--nav-h) + .75rem);
  left: 0;
  right: 0;
  padding: 0 1rem;
  z-index: 90;
  display: flex;
  gap: .75rem;
  pointer-events: none;
}
.fab-bar > * { pointer-events: all; }

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 1rem 0;
}

/* ── Table (desktop) ── */
@media (min-width: 768px) {
  .table-wrap { overflow-x: auto; }
  table.data-table { width: 100%; border-collapse: collapse; }
  table.data-table th {
    text-align: left;
    padding: .75rem 1rem;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
    background: var(--gray-50);
  }
  table.data-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: .9rem;
  }
  table.data-table tr:hover td { background: var(--blue-50); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Loader ── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--blue-100);
  border-top-color: var(--blue-700);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── User greeting ── */
.greeting-bar {
  background: linear-gradient(135deg, var(--blue-700), var(--blue-900));
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  color: var(--white);
  margin-bottom: 1rem;
}
.greeting-bar .greet-name {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.2rem;
}
.greeting-bar .greet-sub { font-size: .82rem; opacity: .8; margin-top: .2rem; }

/* ── Category chip ── */
.chips-wrap {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding-bottom: .5rem;
  margin-bottom: .75rem;
  scrollbar-width: none;
}
.chips-wrap::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: .4rem .9rem;
  border-radius: 999px;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: .8rem;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  color: var(--gray-700);
  cursor: pointer;
  transition: all .15s;
}
.chip.active {
  background: var(--blue-700);
  border-color: var(--blue-700);
  color: var(--white);
}

/* ── Responsive tweaks ── */
@media (max-width: 380px) {
  .counter-btn { width: 40px; height: 40px; font-size: 1.2rem; }
  .counter-input { width: 46px; height: 40px; font-size: 1.1rem; }
  .product-name { font-size: .88rem; }
}
