/* ============================================================
   Datis Financial System skin — RTL layout on top of Bootstrap.
   سامانه مالی داتیس
   ============================================================ */

:root {
  --datis-primary: #7c2982;
  --datis-primary-dark: #63216a;
  --datis-primary-light: #a13ba8;
  --datis-accent: #e83e8c;
  --datis-blue: #3f8cff;
  --datis-green: #24b26b;
  --datis-bg: #f2f3f7;
  --datis-border: #e4e6ef;
  --datis-text: #2b2b3c;
  --datis-muted: #8a8fa3;
  --datis-header-h: 58px;
  --datis-iconbar-w: 62px;
  --datis-submenu-w: 215px;
  --datis-radius: 8px;
}

html[dir="rtl"] body.datis {
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif !important;
  background: var(--datis-bg);
  color: var(--datis-text);
  direction: rtl;
  text-align: right;
  font-size: 13.5px;
}

body.datis h1, body.datis h2, body.datis h3, body.datis h4, body.datis h5, body.datis h6,
body.datis .btn, body.datis input, body.datis select, body.datis textarea, body.datis table {
  font-family: inherit !important;
}

/* ---------------- Header ---------------- */
.datis-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: var(--datis-header-h);
  background: linear-gradient(90deg, var(--datis-primary-dark), var(--datis-primary) 55%, var(--datis-primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 1040;
  box-shadow: 0 2px 10px rgba(60, 10, 70, 0.25);
}

.datis-header .brand {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  margin-left: 18px;
  white-space: nowrap;
}

.datis-header .brand:hover { color: #ffd9ff; }

.datis-header .biz-switcher {
  position: relative;
}

.datis-header .biz-switcher > button {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 13px;
  cursor: pointer;
}

.datis-header .spacer { flex: 1; }

.datis-header .header-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 6px 14px;
  margin-right: 8px;
  font-size: 12.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.datis-header .header-btn:hover { background: rgba(255, 255, 255, 0.28); color: #fff; }

.datis-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: #fff;
  color: var(--datis-text);
  border-radius: var(--datis-radius);
  box-shadow: 0 8px 30px rgba(30, 20, 60, 0.18);
  padding: 6px 0;
  display: none;
  z-index: 1060;
}

.datis-dropdown.open { display: block; }

.datis-dropdown a, .datis-dropdown button.item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 8px 16px;
  color: var(--datis-text);
  background: none;
  border: none;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.datis-dropdown a:hover, .datis-dropdown button.item:hover { background: #f6ecf8; color: var(--datis-primary); }
.datis-dropdown .active-item { background: #f6ecf8; color: var(--datis-primary); font-weight: 700; }
.datis-dropdown .divider { border-top: 1px solid var(--datis-border); margin: 5px 0; }

/* ---------------- Icon bar + submenu ---------------- */
.datis-iconbar {
  position: fixed;
  top: var(--datis-header-h);
  bottom: 0;
  right: 0;
  width: var(--datis-iconbar-w);
  background: #fff;
  border-left: 1px solid var(--datis-border);
  z-index: 1030;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
}

.datis-iconbar a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin: 4px auto;
  border-radius: 10px;
  color: #5a5f73;
  font-size: 17px;
  text-decoration: none;
  position: relative;
}

.datis-iconbar a:hover { background: #f3e6f5; color: var(--datis-primary); }
.datis-iconbar a.active { background: var(--datis-primary); color: #fff; }

.datis-iconbar a .tip {
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--datis-text);
  color: #fff;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  z-index: 1050;
}

.datis-iconbar a:hover .tip { opacity: 1; }

.datis-submenu {
  position: fixed;
  top: var(--datis-header-h);
  bottom: 0;
  right: var(--datis-iconbar-w);
  width: var(--datis-submenu-w);
  background: #fff;
  border-left: 1px solid var(--datis-border);
  z-index: 1020;
  overflow-y: auto;
  padding: 14px 0;
  scrollbar-width: thin;
}

.datis-submenu .group-title {
  color: var(--datis-primary);
  font-weight: 800;
  font-size: 14px;
  padding: 2px 18px 12px;
  border-bottom: 1px solid var(--datis-border);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.datis-submenu a {
  display: block;
  padding: 8px 18px;
  color: #4a4f63;
  font-size: 13px;
  text-decoration: none;
  border-right: 3px solid transparent;
}

.datis-submenu a:hover { color: var(--datis-primary); background: #faf5fb; }
.datis-submenu a.active {
  color: var(--datis-primary);
  background: #f6ecf8;
  border-right-color: var(--datis-primary);
  font-weight: 700;
}

/* ---------------- Content ---------------- */
.datis-content {
  margin-right: calc(var(--datis-iconbar-w) + var(--datis-submenu-w));
  margin-top: var(--datis-header-h);
  padding: 22px 24px 60px;
  min-height: calc(100vh - var(--datis-header-h));
}

body.datis.no-submenu .datis-content { margin-right: var(--datis-iconbar-w); }
body.datis.no-submenu .datis-submenu { display: none; }

.datis-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.datis-page-header h1 {
  font-size: 19px;
  font-weight: 800;
  margin: 0;
  color: var(--datis-text);
}

.datis-card {
  background: #fff;
  border: 1px solid var(--datis-border);
  border-radius: var(--datis-radius);
  box-shadow: 0 1px 4px rgba(40, 40, 80, 0.05);
  margin-bottom: 18px;
}

.datis-card .card-body { padding: 18px; }
.datis-card .card-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--datis-border);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------------- Buttons ---------------- */
.btn-datis {
  background: var(--datis-primary);
  border-color: var(--datis-primary);
  color: #fff !important;
  border-radius: 6px;
  padding: 7px 22px;
  font-size: 13.5px;
}
.btn-datis:hover { background: var(--datis-primary-dark); border-color: var(--datis-primary-dark); }

.btn-datis-blue {
  background: var(--datis-blue);
  border-color: var(--datis-blue);
  color: #fff !important;
  border-radius: 6px;
  font-size: 13px;
  padding: 6px 14px;
}
.btn-datis-blue:hover { background: #2f76e0; border-color: #2f76e0; }

.btn-datis-outline {
  background: #fff;
  border: 1px solid var(--datis-primary);
  color: var(--datis-primary) !important;
  border-radius: 6px;
  font-size: 13px;
  padding: 6px 16px;
}
.btn-datis-outline:hover { background: #f6ecf8; }

.btn-light-sm {
  background: #f1f2f8;
  border: 1px solid var(--datis-border);
  color: #4a4f63;
  border-radius: 6px;
  font-size: 12.5px;
  padding: 5px 12px;
}

/* ---------------- Forms ---------------- */
body.datis label { font-size: 12.5px; font-weight: 600; color: #5b6070; margin-bottom: 5px; }
body.datis label .req { color: #e5484d; }

body.datis .form-control, body.datis .custom-select, body.datis select.form-control {
  border: 1px solid #d9dbe8;
  border-radius: 6px;
  font-size: 13px;
  padding: 7px 10px;
  height: auto;
  color: var(--datis-text);
  background-color: #fff;
}

body.datis .form-control:focus, body.datis select.form-control:focus {
  border-color: var(--datis-primary-light);
  box-shadow: 0 0 0 3px rgba(124, 41, 130, 0.12);
}

body.datis .form-control.is-invalid { border-color: #e5484d; }
body.datis .invalid-feedback { display: block; font-size: 11.5px; }

.money-input, .qty-input { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.jdate-input { direction: ltr; text-align: center; }

.form-group { margin-bottom: 14px; }

.input-suffix {
  display: flex;
  align-items: stretch;
}
.input-suffix .form-control { border-radius: 0 6px 6px 0; }
.input-suffix .suffix {
  background: #f1f2f8;
  border: 1px solid #d9dbe8;
  border-right: 0;
  border-radius: 6px 0 0 6px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--datis-muted);
  display: flex;
  align-items: center;
}

/* ---------------- Tables ---------------- */
.datis-table { width: 100%; margin: 0; }
.datis-table thead th {
  background: #f7f8fc;
  border-bottom: 2px solid var(--datis-border);
  font-size: 12.5px;
  color: #5b6070;
  font-weight: 700;
  padding: 10px 12px;
  white-space: nowrap;
}
.datis-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #eef0f6;
  font-size: 13px;
  vertical-align: middle;
}
.datis-table tbody tr:hover { background: #fafafd; }
.datis-table .num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.datis-table tfoot td { font-weight: 700; background: #f7f8fc; padding: 10px 12px; }

.table-scroll { overflow-x: auto; }

/* editable line-items table */
.lines-table td { padding: 4px 5px; }
.lines-table .form-control { padding: 5px 8px; font-size: 12.5px; }
.lines-table .row-del {
  color: #e5484d;
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
}

/* ---------------- Badges ---------------- */
.badge-datis {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-light-success { background: #e2f7ec; color: #14804a; }
.badge-light-warning { background: #fdf3dc; color: #946200; }
.badge-light-danger { background: #fde8e8; color: #c81e1e; }
.badge-light-secondary { background: #eef0f6; color: #5b6070; }
.badge-light-info { background: #e3effd; color: #1c64f2; }
.badge-light-primary { background: #f3e6f5; color: var(--datis-primary); }

/* ---------------- Misc ---------------- */
.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--datis-muted);
}
.empty-state i { font-size: 44px; margin-bottom: 12px; display: block; color: #cfd2e3; }

.filter-panel {
  background: #fff;
  border: 1px solid var(--datis-border);
  border-radius: var(--datis-radius);
  padding: 14px 16px 4px;
  margin-bottom: 16px;
}

.summary-list { list-style: none; padding: 0; margin: 0; }
.summary-list li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed var(--datis-border);
  font-size: 13px;
}
.summary-list li:last-child { border-bottom: none; }
.summary-list .val { font-weight: 700; direction: ltr; }
.summary-list .text-green { color: var(--datis-green); }
.summary-list .text-red { color: #e5484d; }

.stat-card {
  background: #fff;
  border: 1px solid var(--datis-border);
  border-radius: var(--datis-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card .icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: #f3e6f5;
  color: var(--datis-primary);
  flex-shrink: 0;
}
.stat-card .title { font-size: 12px; color: var(--datis-muted); margin-bottom: 3px; }
.stat-card .value { font-size: 15.5px; font-weight: 800; direction: ltr; text-align: right; }

.alert-datis { border-radius: var(--datis-radius); font-size: 13px; }

/* actions dropdown in tables */
.row-actions { position: relative; display: inline-block; }
.row-actions > button {
  background: #f1f2f8;
  border: 1px solid var(--datis-border);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 13px;
}
.row-actions .datis-dropdown { right: auto; left: 0; min-width: 170px; }
.row-actions form { margin: 0; }

/* ---------------- Jalali datepicker ---------------- */
.jdp-pop {
  position: absolute;
  z-index: 1080;
  background: #fff;
  border: 1px solid var(--datis-border);
  border-radius: 10px;
  box-shadow: 0 10px 34px rgba(30, 20, 60, 0.2);
  padding: 10px;
  width: 252px;
  direction: rtl;
  font-size: 13px;
}
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.jdp-head button {
  background: #f1f2f8;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--datis-primary);
}
.jdp-title { font-weight: 700; }
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jdp-grid .dow { font-size: 10.5px; color: var(--datis-muted); text-align: center; padding: 3px 0; }
.jdp-grid .day {
  border: none;
  background: none;
  border-radius: 6px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 12.5px;
  text-align: center;
}
.jdp-grid .day:hover { background: #f3e6f5; }
.jdp-grid .day.today { border: 1px solid var(--datis-primary-light); }
.jdp-grid .day.selected { background: var(--datis-primary); color: #fff; }
.jdp-foot { text-align: center; margin-top: 8px; }
.jdp-foot button {
  background: none;
  border: none;
  color: var(--datis-blue);
  cursor: pointer;
  font-size: 12.5px;
}

/* ---------------- Modal ---------------- */
.datis-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 40, 0.45);
  z-index: 1090;
  display: flex;
  align-items: center;
  justify-content: center;
}
.datis-modal {
  background: #fff;
  border-radius: 12px;
  width: min(430px, 92vw);
  padding: 22px;
  text-align: center;
}
.datis-modal .msg { font-size: 14px; margin-bottom: 18px; }
.datis-modal .actions { display: flex; gap: 10px; justify-content: center; }

/* ---------------- Searchable select ---------------- */
.sel-search-box { padding: 6px 10px; position: sticky; top: 0; background: #fff; }
.sel-wrap { position: relative; }
.sel-wrap .sel-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  background: #fff;
  border: 1px solid var(--datis-border);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(30, 20, 60, 0.16);
  max-height: 260px;
  overflow-y: auto;
  z-index: 1070;
  display: none;
}
.sel-wrap.open .sel-list { display: block; }
.sel-wrap .sel-item { padding: 7px 12px; cursor: pointer; font-size: 13px; }
.sel-wrap .sel-item:hover, .sel-wrap .sel-item.hover { background: #f6ecf8; }
.sel-wrap .sel-empty { padding: 10px 12px; color: var(--datis-muted); font-size: 12.5px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 991px) {
  .datis-submenu { transform: translateX(100%); transition: transform .18s; }
  body.datis.submenu-open .datis-submenu { transform: none; box-shadow: -6px 0 30px rgba(0,0,0,.15); }
  .datis-content { margin-right: var(--datis-iconbar-w); padding: 16px 14px 50px; }
}

@media (max-width: 575px) {
  .datis-header .brand { font-size: 16px; margin-left: 8px; }
  .datis-header .header-btn.hide-sm { display: none; }
}

/* ---------------- Print ---------------- */
@media print {
  .datis-header, .datis-iconbar, .datis-submenu, .no-print { display: none !important; }
  .datis-content { margin: 0 !important; padding: 0 !important; }
  body.datis { background: #fff; }
  .datis-card { border: none; box-shadow: none; }
}

body.print-page {
  font-family: "Vazirmatn", Tahoma, sans-serif !important;
  direction: rtl;
  background: #fff;
  color: #111;
  font-size: 13px;
  padding: 24px;
}
.print-doc { max-width: 900px; margin: 0 auto; }
.print-doc .doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #333;
  padding-bottom: 12px;
  margin-bottom: 14px;
}
.print-doc h1 { font-size: 18px; margin: 0 0 6px; }
.print-doc table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.print-doc table th, .print-doc table td { border: 1px solid #555; padding: 6px 8px; font-size: 12px; }
.print-doc table th { background: #efefef; }
.print-doc .num { direction: ltr; text-align: left; }
.print-doc .meta { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-bottom: 12px; font-size: 12.5px; }
.print-doc .signatures { display: flex; justify-content: space-around; margin-top: 44px; }
.print-doc .signatures div { text-align: center; min-width: 140px; border-top: 1px dashed #888; padding-top: 8px; }
.print-actions { text-align: center; margin: 18px 0; }
@media print { .print-actions { display: none; } }

/* ============ Phase 2: toasts ============ */
.datis-toasts { position: fixed; top: 18px; left: 18px; z-index: 3000; display: flex;
  flex-direction: column; gap: 10px; max-width: 360px; }
.datis-toast { background: #fff; border-radius: 10px; padding: 12px 38px 12px 14px; font-size: 13px;
  box-shadow: 0 8px 26px rgba(0,0,0,.18); border-right: 4px solid #3f8cff; position: relative;
  animation: datisToastIn .26s ease; color: #2a2f45; }
.datis-toast.leaving { opacity: 0; transform: translateX(-12px); transition: all .25s ease; }
.datis-toast-success { border-right-color: #24b26b; }
.datis-toast-error { border-right-color: #e0364a; }
.datis-toast-info { border-right-color: #3f8cff; }
.datis-toast-x { position: absolute; left: 10px; top: 8px; cursor: pointer; opacity: .5; font-size: 16px; }
.datis-toast-x:hover { opacity: 1; }
@keyframes datisToastIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

/* ============ Phase 2: bulk selection bar ============ */
.datis-bulkbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; margin-bottom: 12px;
  background: #f6ecf8; border: 1px solid #e6d3ec; border-radius: 10px; font-size: 13px; }
.datis-bulkbar .count { font-weight: 600; color: #7c2982; }
.datis-bulkbar.hidden { display: none; }

/* ============ Phase 2: document detail / action bar ============ */
.datis-actionbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.doc-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 22px; }
.info-grid .k { color: #8a8fa3; font-size: 12px; }
.info-grid .v { font-size: 13.5px; color: #2a2f45; font-weight: 500; }

/* ============ Phase 2: account tree ============ */
.acct-tree { font-size: 13.5px; }
.acct-tree .node-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid #f0f1f6; }
.acct-tree .node-row:hover { background: #faf7fb; }
.acct-tree .twisty { width: 18px; text-align: center; cursor: pointer; color: #7c2982; user-select: none; }
.acct-tree .twisty.leaf { color: #c9ccd8; cursor: default; }
.acct-tree .children { display: none; }
.acct-tree .children.open { display: block; }
.acct-tree .acode { direction: ltr; font-family: monospace; color: #6b7280; margin-inline-end: 6px; }
.acct-tree .row-actions-inline { margin-inline-start: auto; display: flex; gap: 6px; }
.acct-tree .lvl-badge { font-size: 10px; padding: 1px 6px; border-radius: 6px; background: #eef0f6; color: #6b7280; }

/* ============ Phase 2: attachments ============ */
.att-count { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: #7c2982; color: #fff; font-size: 10px; margin-inline-start: 4px; }
.datis-modal-panel { max-width: 640px; }
.att-drop { border: 1.5px dashed #c9ccd8; border-radius: 10px; padding: 18px; text-align: center; color: #8a8fa3;
  font-size: 13px; cursor: pointer; }
.att-drop:hover { border-color: #7c2982; color: #7c2982; }

/* ============ Phase 2: dashboard chart & tabs ============ */
.chart-bars { display: flex; align-items: flex-end; gap: 18px; height: 210px; padding: 8px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-val { font-size: 10.5px; color: #6b7280; direction: ltr; margin-bottom: 4px; }
.chart-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: 60%; max-width: 54px; border-radius: 6px 6px 0 0; min-height: 4px; transition: height .3s ease; }
.chart-label { font-size: 12px; margin-top: 6px; color: #2a2f45; font-weight: 600; }
.datis-tabs { display: flex; gap: 6px; border-bottom: 1px solid #eef0f6; margin-bottom: 10px; }
.datis-tabs .tab-btn { border: none; background: none; padding: 8px 14px; font-size: 13px; cursor: pointer;
  color: #6b7280; border-bottom: 2px solid transparent; font-family: inherit; }
.datis-tabs .tab-btn.active { color: #7c2982; border-bottom-color: #7c2982; font-weight: 600; }
.tab-pane.hidden { display: none; }
