/* بارگذاری فونت وزیرمتن */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-main: #f1f5f9;
  --card-bg: #ffffff;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --primary-dark: #3730a3;
  --emerald: #10b981;
  --emerald-soft: #ecfdf5;
  --amber: #f59e0b;
  --amber-soft: #fffbeb;
  --rose: #f43f5e;
  --rose-soft: #fff1f2;
  --purple: #8b5cf6;
  --purple-soft: #f5f3ff;
  --cyan: #06b6d4;
  --cyan-soft: #ecfeff;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-200: #e2e8f0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* توجه مهم: عدم اعمال position:relative روی html/body برای حفظ عملکرد صحیح fixed در موبایل */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 0.96rem;
  line-height: 1.55;
  background-color: var(--bg-main);
  color: var(--slate-900);
  margin: 0;
  padding: 0;
  padding-bottom: 84px !important; /* فضای کافی برای نوار منوی ثابت پایین */
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  overflow-x: hidden;
}

/* خنثی‌سازی حاشیه منفی row در بوت‌استرپ */
.row {
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.row > * {
  padding-left: 5px !important;
  padding-right: 5px !important;
}

/* هدر شیشه‌ای بالا با فونت خوانا */
.app-header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.header-action-btn {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  border: 1px solid var(--slate-200);
  background: #f8fafc;
  color: var(--slate-700);
  text-decoration: none;
}

/* کارت‌های مینیمال و مدرن */
.modern-card {
  background: var(--card-bg);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  box-shadow: 0 3px 14px -2px rgba(15, 23, 42, 0.05);
  width: 100%;
  overflow: hidden;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 16px;
  padding: 0.9rem 0.85rem;
  transition: all 0.2s ease;
  width: 100%;
  overflow: hidden;
}

.stat-card.clickable:hover {
  border-color: var(--primary);
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: clamp(1.1rem, 4.3vw, 1.35rem);
  font-weight: 800;
  word-break: break-word;
  line-height: 1.35;
}

/* دکمه‌های دسترسی سریع درشت و خوانا */
.quick-action-btn {
  background: var(--card-bg);
  border: 1px solid var(--slate-200);
  border-radius: 15px;
  padding: 0.8rem 0.7rem;
  color: var(--slate-900);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all 0.2s ease;
  width: 100%;
  text-align: right;
  overflow: hidden;
}

.quick-action-btn:hover {
  border-color: var(--primary);
  background-color: var(--primary-soft);
  color: var(--primary);
}

.quick-action-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* فرم‌ها، برچسب‌ها و ورودی‌ها با سایز خوانا برای موبایل */
.form-label {
  font-size: 0.88rem !important;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem !important; /* حداقل 15px برای خوانایی عالی در موبایل */
  color: var(--slate-900);
  max-width: 100%;
}

.form-control:focus,
.form-select:focus {
  background-color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
}

.btn-primary-modern {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  border: none;
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.75rem 1.1rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.24);
}

.btn-primary-modern:hover {
  background: linear-gradient(135deg, #4338ca, #3730a3);
  color: #fff;
}

.btn-emerald-modern {
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  border-radius: 13px;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.85rem 1.1rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
}

/* مدیریت ویوهای SPA */
.view-section {
  display: none;
  width: 100%;
  overflow-x: hidden;
  animation: fadeIn 0.18s ease-out;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* کادر امضای دیجیتال */
#signatureCanvas {
  border: 1.5px dashed #cbd5e1;
  border-radius: 14px;
  width: 100%;
  height: 110px;
  background-color: #fcfdff;
  cursor: crosshair;
  display: block;
}

/* ================= نوار منوی پایین: همیشه چسبیده به پایین صفحه در نگاه اول ================= */
.bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: 68px;
  background: #ffffff;
  border-top: 1.5px solid var(--slate-200);
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.08);
  padding: 0.3rem 0.2rem;
  z-index: 1040 !important;
  display: flex;
  align-items: center;
}

.nav-link-item {
  color: var(--slate-700);
  text-decoration: none;
  font-size: 0.76rem; /* درشت و خوانا */
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.15rem;
  border-radius: 11px;
  transition: all 0.18s ease;
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
}

.nav-link-item i {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.nav-link-item.active-nav {
  color: var(--primary);
  font-weight: 800;
  background-color: var(--primary-soft);
}

/* ================= تضمین باز شدن تمام مودال‌ها و بارکدخوان دقیقاً در وسط صفحه ================= */
.modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  z-index: 1060 !important;
  overflow-x: hidden;
  overflow-y: auto;
}

.modal.show {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 12px !important;
}

.modal-dialog {
  width: 100% !important;
  max-width: 430px !important;
  margin: auto !important;
}

.modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 1050 !important;
}

/* نشانگر کد یکتا، بارکد و دسته‌بندی با فونت خوانا */
.sku-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 700;
  background-color: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
  padding: 2px 7px;
  border-radius: 6px;
  display: inline-block;
}

.category-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--purple-soft);
  color: var(--purple);
  border: 1px solid rgba(139, 92, 246, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
}

.barcode-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 600;
  background-color: #f8fafc;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  padding: 2px 6px;
  border-radius: 6px;
  display: inline-block;
  word-break: break-all;
}

/* تصاویر بندانگشتی و کارت کاتالوگ */
.product-thumb-sm {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--slate-200);
  background-color: #f8fafc;
  flex-shrink: 0;
}

.product-thumb-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px dashed #cbd5e1;
  background-color: #f8fafc;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.catalog-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.catalog-img-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #f8fafc, #eef2ff);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid #f1f5f9;
}

.catalog-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload-preview {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  border: 1.5px dashed #cbd5e1;
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}

.image-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* جدول‌های بدون اسکرول افقی با فونت درشت‌تر و خوانا */
.table-no-scroll {
  width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse;
  margin-bottom: 0;
}

.table-no-scroll th,
.table-no-scroll td {
  padding: 0.6rem 0.3rem !important;
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal !important;
  font-size: 0.88rem; /* خوانا روی موبایل */
}

.table-no-scroll thead th {
  font-size: 0.82rem;
  color: var(--slate-700);
  font-weight: 700;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
}

#barcodeReaderContainer {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #0f172a;
  min-height: 230px;
}

/* استایل پیش‌نمایش فیش چاپی مشتری */
.thermal-receipt-box {
  background: #fff;
  border: 1px dashed #94a3b8;
  border-radius: 14px;
  padding: 1rem;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  color: #000;
  font-size: 0.88rem;
}

.thermal-receipt-box table {
  table-layout: fixed;
  width: 100%;
}

.thermal-receipt-box table th,
.thermal-receipt-box table td {
  padding: 0.35rem 0.2rem;
  border-bottom: 1px dashed #cbd5e1;
  word-wrap: break-word;
}

/* مدیریت چاپ */
@media print {
  body {
    background-color: #fff !important;
    padding-bottom: 0 !important;
  }
  .app-header,
  .bottom-nav,
  .no-print {
    display: none !important;
  }
  body.printing-receipt .view-section,
  body.printing-receipt .modal:not(#receiptPrintModal) {
    display: none !important;
  }
  body.printing-receipt #receiptPrintModal {
    position: static !important;
    display: block !important;
    opacity: 1 !important;
    height: auto !important;
  }
  body.printing-receipt #receiptPrintModal .modal-dialog {
    max-width: 80mm !important;
    width: 100% !important;
    margin: 0 auto !important;
  }
  body.printing-receipt #receiptPrintModal .modal-content {
    border: none !important;
    box-shadow: none !important;
  }
  body.printing-receipt #receiptPrintModal .modal-header,
  body.printing-receipt #receiptPrintModal .modal-footer {
    display: none !important;
  }
  body.printing-receipt .thermal-receipt-box {
    border: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
}