@font-face {
  font-family: 'InvoiceFont';
  src: url('font.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'InvoiceFont', Tahoma, Arial, sans-serif !important;
}

body {
  background-color: #f1f5f9;
  color: #1e293b;
  padding: 20px;
  direction: rtl;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 1024px) {
  .container {
    flex-direction: row;
    align-items: flex-start;
  }
  .form-panel {
    width: 45%;
    position: sticky;
    top: 20px;
  }
  .preview-panel {
    width: 55%;
  }
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.title-area h1 {
  font-size: 20px;
  font-weight: bold;
  color: #0f172a;
}

.title-area p {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
}

.btn-print {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  transition: background 0.2s;
}

.btn-print:hover {
  background: #1d4ed8;
}

.form-group {
  margin-bottom: 14px;
}

.lbl-small {
  font-size: 11px;
  font-weight: bold;
  color: #475569;
  display: block;
  margin-bottom: 4px;
}

.file-input {
  font-size: 11px;
  width: 100%;
}

.input-field {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: #2563eb;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.section-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  background: #fafafa;
}

.section-title {
  font-size: 13px;
  font-weight: bold;
  color: #0f172a;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot-green { width: 8px; height: 8px; border-radius: 50%; background: #10b981; }
.dot-blue { width: 8px; height: 8px; border-radius: 50%; background: #3b82f6; }

.item-row-input {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr auto;
  gap: 8px;
  align-items: center;
}

.text-center { text-align: center; }

.btn-add {
  background: #0f172a;
  color: #ffffff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}

.btn-add:hover {
  background: #1e293b;
}

.toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.lbl-discount {
  font-size: 12px;
  font-weight: bold;
  color: #334155;
}

.toggle-btn-group {
  display: flex;
  background: #e2e8f0;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  color: #475569;
}

.toggle-btn.active {
  background: #2563eb;
  color: #ffffff;
}

.discount-input-wrapper {
  position: relative;
}

.pl-discount {
  padding-left: 55px;
}

.discount-badge {
  position: absolute;
  left: 10px;
  top: 9px;
  font-size: 11px;
  color: #94a3b8;
  font-weight: bold;
}

.mb-0 { margin-bottom: 0; }

.lbl-notes {
  font-size: 12px;
  font-weight: bold;
  color: #475569;
  display: block;
  margin-bottom: 6px;
}

/* برگ فاکتور */
.invoice-sheet {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 36px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  position: relative;
}

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.inv-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.inv-logo {
  max-height: 65px;
  max-width: 140px;
  object-fit: contain;
  display: none;
}

.inv-brand-text h2 {
  font-size: 20px;
  font-weight: bold;
  color: #0f172a;
}

.inv-brand-text span {
  font-size: 12px;
  color: #64748b;
}

.inv-meta {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  min-width: 170px;
  line-height: 1.8;
}

.parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.party-card {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
  font-size: 12px;
  line-height: 1.8;
}

.party-card-title {
  font-weight: bold;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.party-row {
  display: flex;
  gap: 4px;
  color: #334155;
}

.party-row strong {
  color: #64748b;
  font-weight: normal;
  white-space: nowrap;
}

/* جدول اقلام - تمام سلول‌ها وسط‌چین */
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 20px;
}

.items-table th,
.items-table td {
  padding: 10px 8px;
  border: 1px solid #cbd5e1;
  text-align: center !important; /* وسط‌چین کردن کامل */
  vertical-align: middle;
}

.items-table th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: bold;
}

.w-row { width: 45px; }
.w-qty { width: 65px; }
.w-price { width: 140px; }
.w-total { width: 160px; }
.font-bold { font-weight: bold; }

.items-table tfoot td {
  background: #f8fafc;
  padding: 10px 12px;
}

.highlight-row td {
  background: #e2e8f0 !important;
  font-size: 14px;
}

.text-rose { color: #e11d48 !important; }
.text-blue { color: #2563eb !important; font-size: 15px; }

.item-name-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

.btn-delete {
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}

.btn-delete:hover {
  background: #fca5a5;
}

.inv-notes {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #475569;
  margin-bottom: 30px;
  line-height: 1.6;
}

.inv-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  text-align: center;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 30px;
}

.sign-box {
  border-top: 1px dashed #cbd5e1;
  padding-top: 10px;
  height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.inv-footer {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #94a3b8;
}

.inv-footer a {
  color: #475569;
  font-weight: bold;
  text-decoration: underline;
}

/* دکمه دونیشن فنجان قهوه */
.coffee-btn {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, #ff813f, #ffdd00);
  color: #432205 !important;
  text-decoration: none !important;
  padding: 6px 10px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(255, 129, 63, 0.25);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  max-width: 36px;
  white-space: nowrap;
  cursor: pointer;
}

.coffee-icon {
  font-size: 16px;
  display: inline-block;
  line-height: 1;
}

.coffee-text {
  opacity: 0;
  max-width: 0;
  margin-right: 0;
  transition: all 0.3s ease;
  font-size: 11px;
}

.coffee-btn:hover {
  max-width: 240px;
  padding: 6px 14px;
  box-shadow: 0 6px 16px rgba(255, 129, 63, 0.4);
  transform: translateY(-2px);
}

.coffee-btn:hover .coffee-text {
  opacity: 1;
  max-width: 200px;
  margin-right: 8px;
}

/* قوانین چاپ */
@media print {
  body {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .no-print {
    display: none !important;
  }
  .container {
    display: block !important;
  }
  .preview-panel {
    width: 100% !important;
  }
  .invoice-sheet {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 10mm !important;
  }
  .btn-delete {
    display: none !important;
  }
  @page {
    size: A4 portrait;
    margin: 0;
  }
}