/* بارگذاری فونت وزیرمتن به صورت آفلاین از پوشه fonts */
@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;
}

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background-color: var(--bg-main);
  color: var(--slate-900);
  padding-bottom: 105px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.app-container {
  max-width: 650px;
  margin: 0 auto;
}

/* هدر شیشه‌ای مدرن */
.app-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--slate-200);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.28);
}

/* کارت‌های مینیمال و مدرن */
.modern-card {
  background: var(--card-bg);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 20px;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.04);
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 18px;
  padding: 1rem;
  transition: all 0.2s ease;
}

.stat-card.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 8px 20px -4px rgba(79, 70, 229, 0.12);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* دکمه‌های دسترسی سریع */
.quick-action-btn {
  background: var(--card-bg);
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  padding: 0.75rem;
  color: var(--slate-700);
  font-weight: 600;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all 0.2s ease;
  width: 100%;
  text-align: right;
}

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

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

/* فرم‌ها و ورودی‌ها */
.form-control,
.form-select {
  background-color: #f8fafc;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  color: var(--slate-900);
}

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

.btn-primary-modern {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  border: none;
  color: #fff;
  border-radius: 13px;
  font-weight: 600;
  padding: 0.7rem 1.2rem;
  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: 14px;
  font-weight: 600;
  padding: 0.8rem 1.2rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
}

.btn-emerald-modern:hover {
  color: #fff;
  opacity: 0.95;
}

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

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

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

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

/* نوار ناوبری پایین */
.bottom-nav {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--slate-200);
  padding: 0.4rem 0.15rem;
  z-index: 1030;
}

.nav-link-item {
  color: var(--slate-500);
  text-decoration: none;
  font-size: 0.66rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.35rem;
  border-radius: 12px;
  transition: all 0.18s ease;
}

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

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

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

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

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

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

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

.catalog-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: 18px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.catalog-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px -6px rgba(15, 23, 42, 0.08);
}

.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;
  position: relative;
  border-bottom: 1px solid #f1f5f9;
}

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

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

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

.table > :not(caption) > * > * {
  padding: 0.65rem 0.45rem;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, background-color 0.15s ease;
  border-radius: 8px;
}

.sortable-th:hover {
  color: var(--primary) !important;
  background-color: var(--primary-soft);
}

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

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

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

/* مدیریت هوشمند چاپ */
@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;
    overflow: visible !important;
  }
  body.printing-receipt #receiptPrintModal .modal-dialog {
    max-width: 80mm !important;
    width: 100% !important;
    margin: 0 auto !important;
    transform: none !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;
  }

  /* حالت ۲: چاپ کاتالوگ کالاها */
  body:not(.printing-receipt) .app-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body:not(.printing-receipt) .catalog-card {
    break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
  }
}