body {
  font-family: 'Tajawal', sans-serif;
}

/* ========== زر المحفوظات في الهيدر ========== */
.history-btn {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  transition: all 0.3s;
  text-decoration: none;
}
.history-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  transform: translateY(-1px);
}
.save-settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: white;
  font-size: 13px;
  cursor: pointer;
}
.save-settings-toggle input[type="checkbox"] {
  width: 38px;
  height: 20px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}
.save-settings-toggle input[type="checkbox"]:checked {
  background: #28a745;
}
.save-settings-toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  top: 3px;
  right: 3px;
  transition: right 0.3s;
}
.save-settings-toggle input[type="checkbox"]:checked::before {
  right: 21px;
}

/* ========== نافذة المحفوظات ========== */
.history-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}
.history-modal.active {
  display: flex;
}
.history-content {
  background: white;
  width: 92%;
  max-width: 820px;
  max-height: 82vh;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
}
.history-header {
  background: #084498;
  color: white;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.history-header h2 {
  margin: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.close-history {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.close-history:hover {
  opacity: 0.8;
}
.history-list {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.history-item {
  padding: 14px 16px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #f8f9fa;
  transition: box-shadow 0.2s;
}
.history-item:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.history-item-title {
  font-weight: 700;
  color: #084498;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.history-item-date {
  font-size: 12px;
  color: #6c757d;
}
.history-item-details {
  font-size: 13px;
  color: #495057;
  margin-bottom: 10px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.history-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.history-item-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Tajawal', sans-serif;
  transition: opacity 0.2s;
}
.history-item-btn:hover { opacity: 0.85; }
.history-item-btn.print  { background: #17a2b8; color: white; }
.history-item-btn.edit   { background: #ffc107; color: #212529; }
.history-item-btn.delete { background: #dc3545; color: white; }
.no-history {
  text-align: center;
  padding: 50px 20px;
  color: #6c757d;
}
.no-history i { font-size: 52px; opacity: 0.25; display: block; margin-bottom: 12px; }

.history-subtabs { display: flex; gap: 8px; padding: 0 20px; border-bottom: 1px solid #e6e6e6; }
.history-subtab {
  background: none; border: none; padding: 12px 16px; cursor: pointer; font-family: 'Tajawal', sans-serif;
  font-size: 13px; font-weight: 700; color: #6c757d; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.history-subtab.active { color: #084498; border-bottom-color: #084498; }

/* ========== Invoice Generator ========== */
.invoice-generator-container {
  max-width: 1200px;
  margin: 30px auto;
  padding: 20px;
  background: #fff;
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1);
  border-radius: 15px;
}
.form-section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e6e6e6;
}
.section-title {
  font-size: 20px;
  font-weight: 600;
  color: #084498;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}
.section-title i {
  margin-left: 10px;
  font-size: 22px;
}
.invoice-header {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 30px;
}
.invoice-details {
  flex: 1;
  min-width: 300px;
}
.tax-setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 8px;
}
.tax-setting > * { margin: 5px 0; }
.tax-setting label,
.tax-setting .tax-title {
  font-weight: 600;
  color: #084498;
}
.tax-rate-input {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tax-rate-input input {
  width: 80px;
  text-align: center;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 15px;
}
.form-group {
  flex: 1;
  min-width: 250px;
}
.form-control {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 15px;
  transition: all 0.3s;
}
.form-control:focus {
  border-color: #084498;
  box-shadow: 0 0 0 3px rgba(8, 68, 152, 0.1);
}
.logo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 8px;
  min-width: 200px;
}
.logo-preview {
  width: 100px;
  height: 100px;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.logo-preview img {
  max-width: 100%;
  max-height: 100%;
}
.logo-upload label {
  cursor: pointer;
  padding: 8px 15px;
  background: #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
}
.add-field-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #084498;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  margin-top: 10px;
  padding: 5px 0;
}
.add-field-btn i { font-size: 18px; }
.info-box {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.info-column {
  flex: 1;
  min-width: 300px;
  padding: 20px;
  background: #f8fafc;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}
.invoice-items-table th,
.invoice-items-table td {
  padding: 12px 15px;
  text-align: right;
  border-bottom: 1px solid #e6e6e6;
}
.invoice-items-table th {
  background: #f8fafc;
  font-weight: 600;
}
.invoice-items-table input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}
.invoice-items-table .item-actions {
  display: flex;
  gap: 5px;
}
.invoice-items-table .action-btn {
  padding: 5px 8px;
  background: #f1f5f9;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #475569;
}
.invoice-items-table .delete-btn { color: #ef4444; }
.add-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  background: #084498;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  margin-top: 10px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s;
}
.add-item-btn:hover { background: #063579; }
.invoice-summary {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
}
.summary-row {
  display: flex;
  width: 100%;
  max-width: 400px;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #e6e6e6;
}
.summary-row:last-child {
  border-bottom: none;
  font-weight: 700;
  font-size: 18px;
  color: #084498;
}
.summary-label { font-weight: 600; }
.summary-value { font-weight: 500; }
.invoice-terms-section {
  margin-top: 20px;
  padding: 15px;
  background: #f8fafc;
  border-radius: 8px;
}
.invoice-terms-section label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #084498;
  margin-bottom: 8px;
  font-size: 14px;
}
.invoice-terms-section textarea {
  resize: vertical;
  font-family: 'Tajawal', sans-serif;
}

.qr-section {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}
.qr-code { text-align: center; }
.qr-code img { max-width: 90px; max-height: 90px; }
.qr-label { font-size: 14px; color: #666; margin-top: 10px; }
.invoice-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
}
.invoice-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 25px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  font-family: 'Tajawal', sans-serif;
}
.invoice-btn i { font-size: 18px; }
.invoice-save-btn  { background: #084498; color: white; }
.invoice-save-btn:hover { background: #063579; }
.invoice-print-btn { background: #f8fafc; color: #1e293b; border: 1px solid #e2e8f0; }
.invoice-print-btn:hover { background: #e2e8f0; }
.invoice-share-btn { background: #25D366; color: white; }
.invoice-share-btn:hover { background: #1ebe57; }
.added-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.added-field .field-label { flex: 1; }
.added-field .field-value { flex: 2; }
.added-field .remove-field {
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
}

@media print {
  body > *:not(.invoice-print-container) { display: none; }
  .invoice-print-container {
    display: block !important;
    visibility: visible !important;
    position: static;
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: white !important;
    color: black !important;
    font-family: Arial, sans-serif;
    direction: rtl;
    font-size: 10pt;
  }
  .invoice-print-container * {
    visibility: visible !important;
    color: black !important;
  }
  .invoice-print-container h1 { font-size: 14pt; margin: 5px 0; }
  .invoice-print-container h2 { font-size: 12pt; margin: 5px 0; }
  .invoice-print-container p { margin: 2px 0; line-height: 1.2; }
  .invoice-print-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }
  .invoice-print-container th,
  .invoice-print-container td { padding: 3px 5px; border: 0.5px solid #000; }
  .invoice-print-container .logo img { max-height: 40px; width: auto; }
  .invoice-print-container .print-qr img { width: 70px; height: 70px; }
  .no-print { display: none !important; }
  @page { size: A4; margin: 5mm; }
}

body, #pdf-container { font-family: 'Tajawal', sans-serif; }

@media (max-width: 768px) {
  #invoiceItemsTable thead { display: none; }
  #invoiceItemsTable tbody tr { display: block; margin-bottom: 15px; padding: 10px; background: #f8fafc; }
  #invoiceItemsTable tbody td { display: block; padding: 5px 0; }
  #invoiceItemsTable tbody td:before { font-weight: bold; display: block; margin-bottom: 5px; }
  #invoiceItemsTable tbody input { width: 100%; height: 44px; font-size: 16px; }
  #invoiceItemsTable tbody td:nth-of-type(1):before { content: "المنتج/الخدمة"; }
  #invoiceItemsTable tbody td:nth-of-type(2):before { content: "سعر الوحدة"; }
  #invoiceItemsTable tbody td:nth-of-type(3):before { content: "الكمية"; }
  #invoiceItemsTable tbody td:nth-of-type(4):before { content: "المجموع الفرعي"; }
  #invoiceItemsTable tbody td:nth-of-type(5):before { content: "نسبة الضريبة"; }
  #invoiceItemsTable tbody td:nth-of-type(6):before { content: "قيمة الضريبة"; }
  #invoiceItemsTable tbody td:nth-of-type(7):before { content: "المجموع شامل الضريبة"; }
  #invoiceItemsTable tbody td:nth-of-type(8):before { content: "الإجراءات"; }
  .invoice-header { flex-direction: column; }
  .info-column { min-width: 100%; }
  .invoice-items-table th,
  .invoice-items-table td { padding: 8px 10px; }
  .form-row { flex-direction: column; }
  .form-group { min-width: 100%; }
  .invoice-actions { flex-direction: column; }
  .invoice-btn { width: 100%; justify-content: center; }
}

/* ========== تنسيق الهيدر ========== */
.header {
  background: linear-gradient(135deg, #084498, #0a5ac2);
  color: white;
  padding: 20px 0;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}
.header .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}
.logo h1 {
  font-size: 28px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo p {
  font-size: 14px;
  opacity: 0.9;
  margin-top: 5px;
}
@media (max-width: 768px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ========== نوافذ الاشتراك ========== */
.subscription-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  justify-content: center;
  align-items: center;
}
.subscription-modal.active {
  display: flex;
}
.subscription-content {
  background: white;
  width: 90%;
  max-width: 450px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  direction: rtl;
  animation: modalFadeIn 0.3s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
.subscription-header {
  background: linear-gradient(135deg, #084498, #0a5ac2);
  color: white;
  padding: 25px 20px;
}
.subscription-header i {
  font-size: 48px;
  margin-bottom: 10px;
}
.subscription-header h2 {
  margin: 0;
  font-size: 22px;
}
.subscription-body {
  padding: 25px 20px;
}
.subscription-body p {
  color: #333;
  margin-bottom: 15px;
  font-size: 15px;
}
.subscription-body input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  font-family: 'Tajawal', sans-serif;
  margin-bottom: 15px;
  text-align: center;
}
.subscription-body input:focus {
  border-color: #084498;
  outline: none;
  box-shadow: 0 0 0 3px rgba(8, 68, 152, 0.1);
}
.subscription-btn {
  background: linear-gradient(135deg, #084498, #0a5ac2);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: 'Tajawal', sans-serif;
  transition: all 0.3s;
}
.subscription-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(8, 68, 152, 0.3);
}

/* ========== نافذة الرسائل الأنيقة (بدل alert) ========== */
.shams-info-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 20000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.shams-info-modal.active { display: flex; }
.shams-info-box {
  background: white;
  max-width: 380px;
  width: 100%;
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  direction: rtl;
  box-shadow: 0 15px 50px rgba(0,0,0,.3);
}
.shams-info-box p {
  font-size: 15px;
  line-height: 1.8;
  color: #1e293b;
  white-space: pre-line;
  margin: 0 0 20px;
}
.shams-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #25D366;
  color: white;
  text-decoration: none;
  padding: 11px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}
.shams-whatsapp-btn:hover { background: #1ebe57; color: white; }
.shams-info-close {
  background: #f1f5f9;
  color: #334155;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  width: 100%;
}
.shams-info-close:hover { background: #e2e8f0; }

/* ========== فوتر بسيط أسفل صفحة الفاتورة ========== */
.shams-simple-footer {
  background: linear-gradient(135deg, #084498, #0a5ac2);
  color: white;
  padding: 22px 20px;
  margin-top: 40px;
  text-align: center;
}
.shams-simple-footer-inner {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 15px;
}
.shams-footer-btn {
  background: white;
  color: #084498;
  text-decoration: none;
  padding: 8px 22px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
  transition: transform .15s;
}
.shams-extra-footer-link {
  background: rgba(255,255,255,.15);
  color: white;
  text-decoration: none;
  padding: 7px 18px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,.4);
  transition: background .15s;
}
.shams-extra-footer-link:hover { background: rgba(255,255,255,.28); color: white; }
.shams-footer-btn:hover { transform: translateY(-2px); color: #084498; }
.shams-footer-support {
  display: none;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
  font-size: 12px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
}
.shams-footer-support:hover { color: white; }

/* ========== نافذة الاشتراك والباقات ========== */
.current-plan-box {
  background: linear-gradient(135deg, #084498, #0a5ac2);
  color: white;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.current-plan-business { font-size: 14px; font-weight: 700; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.25); }
.current-plan-title { font-size: 12px; opacity: .85; margin-bottom: 6px; }
.current-plan-name { font-size: 18px; font-weight: 700; }
.current-plan-type { font-size: 12px; font-weight: 400; opacity: .85; }
.current-plan-expiry { margin-top: 8px; font-size: 13px; background: rgba(255,255,255,.15); display: inline-block; padding: 3px 10px; border-radius: 8px; }
.plans-catalog-title { font-weight: 700; color: #084498; margin-bottom: 12px; font-size: 15px; }
.plans-catalog { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.plan-catalog-card { border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; text-align: center; background: #f8fafc; }
.plan-catalog-name { font-weight: 700; color: #084498; margin-bottom: 6px; }
.plan-catalog-price { font-size: 13px; color: #7c3aed; font-weight: 700; margin-bottom: 8px; }
.plan-catalog-features { list-style: none; padding: 0; margin: 0 0 12px; font-size: 13px; color: #475569; }
.plan-catalog-features li { padding: 3px 0; }
.plan-subscribe-btn {
  width: 100%; background: #084498; color: white; border: none; border-radius: 6px;
  padding: 9px; cursor: pointer; font-family: 'Tajawal', sans-serif; font-weight: 600; font-size: 13px;
}
.plan-subscribe-btn:hover { background: #063579; }
.plan-subscribe-btn:disabled { background: #94a3b8; cursor: not-allowed; }
