/* ============================================================
   EXTRAS v3.0
   - شامل: Modal, Viewer, Snapshot, Profile, Report, Toast, Flash
   - بدون @media print (چاپ در print.css)
============================================================ */

/* ============================================================
   Modal Overlay (پایه‌ی همه مودال‌ها)
============================================================ */
.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(20,30,60,.5);
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
  z-index:60;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  animation:fadeIn .18s ease-out;
}
.modal-overlay[hidden]{display:none!important}

@keyframes fadeIn{
  from{opacity:0}
  to{opacity:1}
}
@keyframes slideUp{
  from{opacity:0;transform:translateY(16px) scale(.98)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
@keyframes rowFlash{
  0%   { background:#fef3c7!important; }
  60%  { background:#fef3c7!important; }
  100% { background:transparent; }
}

/* ============================================================
   Modal Box
============================================================ */
.modal{
  background:#fff;
  border-radius:16px;
  width:100%;
  max-width:560px;
  max-height:85vh;
  display:flex;
  flex-direction:column;
  box-shadow:0 24px 60px rgba(20,30,60,.28);
  overflow:hidden;
  animation:slideUp .22s cubic-bezier(.16,1,.3,1);
}
.modal-lg{max-width:760px}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg,#fcfdff,#f8faff);
}
.modal-head h3{
  margin:0;
  font-size:14.5px;
  color:var(--brand);
  font-weight:800;
  display:flex;
  align-items:center;
  gap:8px;
}
.modal-head h3::before{
  content:'';
  display:inline-block;
  width:4px;
  height:14px;
  background:linear-gradient(180deg,var(--accent),var(--brand));
  border-radius:3px;
}

.btn-close{
  border:none;
  background:transparent;
  font-size:22px;
  line-height:1;
  cursor:pointer;
  color:var(--ink-faint);
  padding:0;
  border-radius:8px;
  transition:all .15s;
  width:32px;
  height:32px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex-shrink:0;
}
.btn-close:hover{
  background:#fdecea;
  color:#c0392b;
}

.modal-body{
  padding:14px 18px;
  overflow-y:auto;
  flex:1;
}
.modal-foot{
  padding:12px 18px 14px;
  border-top:1px solid var(--line);
  background:linear-gradient(180deg,#fcfdff,#f8faff);
  display:flex;
  gap:8px;
  justify-content:flex-start;
  flex-wrap:wrap;
}

/* ============================================================
   Modal Search / Filters
============================================================ */
.modal-search{padding:10px 18px 0}
.modal-search input{
  width:100%;
  padding:8px 12px;
  border-radius:10px;
  border:1px solid var(--line);
  font-family:inherit;
  font-size:12.5px;
  outline:none;
  transition:.15s;
}
.modal-search input:focus{
  border-color:#9fb0dd;
  box-shadow:0 0 0 3px rgba(47,59,107,.10);
}

.snap-filters{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
.snap-filters .mini-sel{padding:5px 8px;font-size:11.5px}

.mini-sel{
  padding:3px 6px;
  border-radius:6px;
  border:1px solid var(--line);
  background:#fff;
  font-size:11px;
  font-family:inherit;
  color:var(--ink);
  cursor:pointer;
  transition:.15s;
}
.mini-sel:hover{border-color:#b6bfd4}
.mini-sel:focus{
  outline:none;
  border-color:#9fb0dd;
  box-shadow:0 0 0 2px rgba(47,59,107,.10);
}

/* ============================================================
   Empty state
============================================================ */
.empty{
  text-align:center;
  color:var(--ink-faint);
  padding:50px 20px;
  font-size:13px;
}

/* ============================================================
   Snapshot Item
============================================================ */
.snap-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:11px 13px;
  border:1px solid var(--line);
  border-radius:12px;
  margin-bottom:8px;
  background:linear-gradient(180deg,#fcfdff,#f8faff);
  transition:all .15s;
}
.snap-item:hover{
  background:#f4f7fd;
  border-color:#b6bfd4;
  transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(20,30,60,.06);
}
.snap-item-main{flex:1;min-width:0}
.snap-item-title{
  font-weight:700;
  font-size:13px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--ink);
}
.snap-item-sub{
  font-size:11.5px;
  color:var(--ink-faint);
  margin-top:2px;
}
.snap-item-total{
  font-size:13px;
  font-weight:800;
  color:var(--brand);
  direction:ltr;
  white-space:nowrap;
  text-align:left;
}
.snap-item-total small{
  font-weight:500;
  color:var(--ink-faint);
  font-size:10.5px;
}
.snap-item-actions{display:flex;gap:4px;flex-shrink:0}

.mini-btn{
  border:1px solid var(--line);
  background:#fff;
  width:32px;
  height:32px;
  border-radius:8px;
  cursor:pointer;
  font-size:14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:all .12s;
  padding:0;
  font-family:inherit;
}
.mini-btn:hover{
  background:var(--soft);
  border-color:#b6bfd4;
  transform:translateY(-1px);
}
.mini-btn.danger{color:#c0392b;border-color:#f0c4bf}
.mini-btn.danger:hover{background:#fdecea}

/* ============================================================
   Viewer (نمایش اسنپ‌شات تمام‌صفحه)
============================================================ */
.viewer-overlay{
  position:fixed;
  inset:0;
  background:#e9edf5;
  z-index:50;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  animation:fadeIn .18s ease-out;
}
.viewer-overlay[hidden]{display:none!important}

.viewer-bar{
  position:sticky;
  top:0;
  z-index:5;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 16px;
  background:rgba(255,255,255,.95);
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
  box-shadow:0 2px 8px rgba(20,30,60,.06);
}
.viewer-info{display:flex;flex-direction:column;gap:2px;font-size:13px}
.viewer-info strong{color:var(--brand)}
.viewer-info span{color:var(--ink-faint);font-size:11.5px}
.viewer-actions{display:flex;flex-wrap:wrap;gap:6px}
.viewer-body{padding:22px 14px 60px}

/* اسنپ‌شات: غیرفعال کردن ویرایش */
.snapshot-view .field,
.snapshot-view .del,
.snapshot-view .stamp-box,
.snapshot-view .logo-box{pointer-events:none}
.snapshot-view .field:hover{background:transparent}
.snapshot-view .hint{display:none}
.snapshot-view .no-print{display:none}
.snapshot-view [contenteditable]:hover{background:transparent}

/* ============================================================
   انیمیشن ردیف جدید
============================================================ */
.items tbody tr.flash td{
  animation:rowFlash .9s ease-out;
}

/* ============================================================
   Settings Sections
============================================================ */
.settings-section{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px 14px;
  margin-bottom:10px;
  background:linear-gradient(180deg,#fcfdff,#f8faff);
}
.settings-section h4{
  margin:0 0 10px;
  font-size:12.5px;
  color:var(--brand);
  font-weight:700;
  display:flex;
  align-items:center;
  gap:6px;
}
.settings-section h4::before{
  content:'';
  width:4px;
  height:12px;
  background:var(--accent);
  border-radius:2px;
}
.settings-section .fld{
  display:flex;
  align-items:center;
  gap:8px;
  padding:3px 0;
  font-size:12.5px;
}
.settings-section .fld > span{
  min-width:170px;
  color:var(--ink-soft);
  font-weight:600;
}
.settings-help{
  margin:8px 0 0;
  font-size:11px;
  color:var(--ink-faint);
}
.settings-help b{color:var(--brand);font-weight:800}

/* ============================================================
   Profile
============================================================ */
.tb-profile{
  padding-inline-start:8px;
  border-inline-start:1px solid var(--line);
}

.profile-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  margin-bottom:8px;
  background:linear-gradient(180deg,#fcfdff,#f8faff);
  transition:.15s;
}
.profile-row:hover{background:var(--soft)}
.profile-row.active{
  border-color:var(--brand);
  background:#eef2fb;
  box-shadow:0 0 0 2px rgba(47,59,107,.08);
}
.profile-row .pr-name{flex:1;font-weight:700;font-size:13px}
.profile-row .pr-sub{font-size:11px;color:var(--ink-faint)}
.profile-row .pr-actions{display:flex;gap:4px}

/* ============================================================
   Report
============================================================ */
.report-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(140px,1fr));
  gap:10px;
  margin-bottom:14px;
}
.report-card{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  background:linear-gradient(180deg,#fcfdff,#f8faff);
}
.report-card .rc-label{
  font-size:11.5px;
  color:var(--ink-soft);
  font-weight:600;
}
.report-card .rc-value{
  font-size:17px;
  font-weight:800;
  color:var(--brand);
  direction:ltr;
  text-align:left;
  margin-top:4px;
}
.report-card .rc-value small{
  font-size:10.5px;
  font-weight:500;
  color:var(--ink-faint);
}
.report-table{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}
.report-table th,
.report-table td{
  border-bottom:1px solid var(--line);
  padding:7px 8px;
  text-align:right;
}
.report-table th{
  background:var(--soft);
  font-weight:700;
  color:var(--brand);
  font-size:11.5px;
}
.report-table td.num{
  direction:ltr;
  text-align:left;
  font-weight:600;
}
.report-month-head{
  margin:14px 0 6px;
  font-size:13px;
  font-weight:700;
  color:var(--brand);
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:2px solid var(--line);
  padding-bottom:4px;
}

/* ============================================================
   Toast
============================================================ */
#toast{
  position:fixed;
  bottom:26px;
  left:50%;
  transform:translateX(-50%) translateY(100px);
  background:var(--ink);
  color:#fff;
  padding:11px 22px;
  border-radius:30px;
  font-size:13.5px;
  box-shadow:0 12px 40px rgba(20,30,60,.20);
  opacity:0;
  transition:all .3s;
  z-index:100;
  pointer-events:none;
  max-width:calc(100% - 32px);
  text-align:center;
}
#toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* ============================================================
   دکمه‌های غیرفعال
============================================================ */
#btnUndo:disabled,
#btnRedo:disabled{
  opacity:.4;
  cursor:not-allowed;
}
.btn[disabled]{opacity:.5;cursor:not-allowed;pointer-events:none}

/* ============================================================
   چک‌باکس‌های داخل تنظیمات
============================================================ */
.settings-section .fld input[type="checkbox"]{
  width:auto;
  accent-color:var(--brand);
  cursor:pointer;
}
/* ============================================================
   Jalali Date Picker
============================================================ */
.jalali-picker{
  position:fixed;
  z-index:200;
  width:280px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:0 20px 60px rgba(20,30,60,.24);
  padding:10px;
  direction:rtl;
  font-family:inherit;
  user-select:none;
  animation:jpIn .16s ease-out;
}
.jalali-picker[hidden]{display:none!important}
@keyframes jpIn{
  from{opacity:0;transform:translateY(-4px)}
  to{opacity:1;transform:translateY(0)}
}

.jp-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:4px;
  padding-bottom:8px;
  margin-bottom:8px;
  border-bottom:1px solid var(--line);
}
.jp-title{
  flex:1;
  text-align:center;
  font-size:13px;
  font-weight:800;
  color:var(--brand);
  letter-spacing:.2px;
}
.jp-nav{
  border:none;
  background:transparent;
  color:var(--brand);
  width:28px;
  height:28px;
  border-radius:8px;
  cursor:pointer;
  font-family:inherit;
  font-size:16px;
  font-weight:700;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:background .15s;
}
.jp-nav:hover{background:var(--soft)}
.jp-nav:active{transform:scale(.95)}

.jp-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:2px;
}
.jp-dow{
  text-align:center;
  font-size:11px;
  font-weight:700;
  color:var(--ink-faint);
  padding:4px 0;
  user-select:none;
}
.jp-day{
  border:none;
  background:transparent;
  padding:6px 0;
  border-radius:8px;
  cursor:pointer;
  font-family:inherit;
  font-size:12.5px;
  color:var(--ink);
  font-weight:500;
  transition:all .12s;
  min-height:30px;
}
.jp-day:hover:not(:disabled){background:var(--soft)}
.jp-day:disabled{cursor:default}
.jp-day.other{opacity:0;pointer-events:none}
.jp-day.today{
  color:var(--accent);
  font-weight:800;
  position:relative;
}
.jp-day.today::after{
  content:'';
  position:absolute;
  bottom:2px; left:50%; transform:translateX(-50%);
  width:4px; height:4px;
  background:var(--accent);
  border-radius:50%;
}
.jp-day.selected{
  background:linear-gradient(180deg,var(--brand),var(--brand-dark));
  color:#fff;
  font-weight:800;
  box-shadow:0 2px 8px rgba(47,59,107,.25);
}
.jp-day.selected:hover{background:var(--brand-dark)}
.jp-day.selected::after{display:none}

.jp-foot{
  display:flex;
  gap:6px;
  margin-top:10px;
  padding-top:8px;
  border-top:1px solid var(--line);
}
.jp-btn{
  flex:1;
  padding:7px 6px;
  border-radius:8px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
  font-family:inherit;
  font-size:12px;
  color:var(--ink);
  font-weight:600;
  transition:all .12s;
}
.jp-btn:hover{background:var(--soft);border-color:#b6bfd4}
.jp-btn.primary{
  background:linear-gradient(180deg,var(--brand),var(--brand-dark));
  color:#fff;
  border-color:var(--brand-dark);
}
.jp-btn.primary:hover{background:var(--brand-dark)}

/* input خود تاریخ */
.field.w-date,
#deliveryDateField{
  cursor:pointer;
}

@media screen and (max-width:700px){
  .jalali-picker{width:260px}
  .jp-day{font-size:12px;min-height:28px}
}

@media print{
  .jalali-picker{display:none!important}
}