/* =========================================================
   کافه وال — واکنش‌گرایی (تبلت / لپ‌تاپ / موبایل)
   ========================================================= */

/* ---- لپ‌تاپ متوسط ---- */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .cart { flex-basis: 348px; }
}

/* ---- تبلت: سبد به کشوی پایین تبدیل می‌شود ---- */
@media (max-width: 1020px) {
  .pos {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .cart {
    position: fixed;
    z-index: var(--z-cartdrawer);
    inset-inline: var(--sp-3);
    bottom: 0;
    top: auto;
    flex-basis: auto;
    max-height: min(78dvh, 640px);
    transform: translateY(calc(100% + 24px));
    transition: transform var(--t-med) var(--ease);
    box-shadow: 0 -18px 48px rgba(63, 44, 29, 0.22);
  }
  body.cart-open .cart { transform: none; }

  .cart-close { display: inline-grid; }
  .cart-bar { display: flex; }
  .product-grid { max-height: none; overflow: visible; flex: 0 0 auto; }
  .pos-menu { flex: 1 1 auto; }

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

/* ---- موبایل: سایدبار → ناوبری پایین ---- */
@media (max-width: 880px) {
  :root { --pad-main: 16px; }

  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .bottom-nav { display: flex; }

  .main { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px) + 16px); }

  .topbar { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .brand-tag { display: none; }
  .topbar-clock .clock-date { display: none; }
  .topbar-clock .clock-sep { display: none; }
  .sync-chip span { display: none; }
  .sync-chip { padding: 0 11px; min-height: 38px; }
  .profile-role, .profile-name { display: none; }
  .profile-btn { padding: 4px; background: transparent; border-color: transparent; box-shadow: none; }

  .page-title { font-size: var(--fs-xl); }
  .stats-grid { gap: var(--sp-3); }
  .stat { padding: var(--sp-4); }
  .stat-value { font-size: 19px; }
}

/* ---- موبایل کوچک ---- */
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tables-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .cart-actions { grid-template-columns: 1fr 1fr; }
  .hbar-name { width: 84px; }
  .page-head-actions { width: 100%; }
  .page-head-actions > .btn { flex: 1; }
  .date-selector-group { flex: 1 1 auto; min-width: 0; }
  .date-display { flex: 1; min-width: 0; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .toasts { inset-inline: var(--sp-3); bottom: calc(var(--bottomnav-h) + 74px); }
  .toast { max-width: none; width: 100%; }
}

/* ---- لمس: اهداف بزرگ‌تر روی نمایشگر لمسی ---- */
@media (pointer: coarse) {
  .btn { min-height: 48px; }
  .date-nav, .date-display { height: 40px; }
  .date-nav { width: 40px; }
  .chip { min-height: 44px; }
  .table-chip { min-height: 46px; }
  .stepper button { width: 34px; height: 34px; }
}

/* ---- کاهش حرکت ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- چاپ ---- */
@media print {
  .topbar, .sidebar, .bottom-nav, .cart-bar, .toasts, .modal-backdrop { display: none !important; }
  body { background: #fff; color: #111; }
  .card, .stat { box-shadow: none; border-color: #ddd; }
}
