@import url("../fonts/vazirmatn/vazirmatn.css?v=20261006-8");

:root {
  --abrak-fa-font: "Vazirmatn", "IRANSans", "Tahoma", sans-serif;
}

/* Frappe/ERPNext ships its own css-rtl bundles. These rules are the small
   application-layer overrides needed for the Persian locale and custom
   workspace launcher. */
html[dir="rtl"],
html[dir="rtl"] body,
html[lang^="fa"] {
  direction: rtl;
}

html[dir="rtl"] body,
html[dir="rtl"] button,
html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] textarea,
html[dir="rtl"] .frappe-control,
html[dir="rtl"] .desk-container,
html[dir="rtl"] .page-container,
html[dir="rtl"] .layout-main,
html[dir="rtl"] .layout-main-section,
html[dir="rtl"] .form-layout,
html[dir="rtl"] .list-row-container,
html[dir="rtl"] .list-row,
html[dir="rtl"] .report-wrapper,
html[dir="rtl"] .workspace {
  font-family: var(--abrak-fa-font);
}

html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .navbar,
html[dir="rtl"] .page-head,
html[dir="rtl"] .layout-side-section,
html[dir="rtl"] .sidebar,
html[dir="rtl"] .layout-main,
html[dir="rtl"] .workspace {
  direction: rtl;
}

html[dir="rtl"] .navbar .navbar-brand,
html[dir="rtl"] .navbar .navbar-nav,
html[dir="rtl"] .page-head .page-head-content,
html[dir="rtl"] .form-page,
html[dir="rtl"] .list-row {
  text-align: right;
}

html[dir="rtl"] .form-control,
html[dir="rtl"] textarea,
html[dir="rtl"] .ql-editor,
html[dir="rtl"] .input-with-feedback,
html[dir="rtl"] .search-bar input,
html[dir="rtl"] .search-box input {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .form-control[type="number"],
html[dir="rtl"] input[data-fieldtype="Float"],
html[dir="rtl"] input[data-fieldtype="Currency"],
html[dir="rtl"] input[data-fieldtype="Int"] {
  direction: ltr;
  text-align: right;
}

html[dir="rtl"] code,
html[dir="rtl"] pre,
html[dir="rtl"] .font-monospace,
html[dir="rtl"] input[data-fieldtype="Data"]:has(+ .control-value[data-fieldtype="Link"]) {
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .text-left { text-align: right !important; }
html[dir="rtl"] .text-right { text-align: left !important; }

/* The stock Frappe datepicker is Gregorian.  jalali.js supplies the
 * application-level Persian calendar; keep the stock popup from flashing
 * underneath it while preserving the core control and ISO value contract. */
html[data-abrak-jalali="1"] .datepickers-container {
  display: none !important;
}

.abrak-jalali-picker {
  position: absolute;
  z-index: 100000;
  width: 288px;
  box-sizing: border-box;
  padding: 10px;
  direction: rtl;
  color: var(--text-color, #1f272e);
  font-family: Vazirmatn, IRANSans, Tahoma, sans-serif;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #d1d8dd);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(24, 39, 75, 0.16);
}

.abrak-jalali-picker button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.abrak-jalali-picker__header {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  text-align: center;
}

.abrak-jalali-picker__nav,
.abrak-jalali-picker__today {
  min-height: 30px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.abrak-jalali-picker__nav:hover,
.abrak-jalali-picker__today:hover {
  background: var(--control-bg, #f5f7fa);
  border-color: var(--border-color, #d1d8dd);
}

.abrak-jalali-picker__title {
  font-weight: 600;
  white-space: nowrap;
}

.abrak-jalali-picker__weekdays,
.abrak-jalali-picker__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.abrak-jalali-picker__weekdays {
  margin-bottom: 3px;
  color: var(--text-muted, #74808a);
  font-size: 11px;
  font-weight: 600;
}

.abrak-jalali-picker__day {
  min-width: 0;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.abrak-jalali-picker__day:hover:not(:disabled),
.abrak-jalali-picker__day.is-today {
  background: var(--control-bg, #f5f7fa);
  border-color: var(--primary, #2490ef);
}

.abrak-jalali-picker__day.is-selected {
  color: #fff;
  background: var(--primary, #2490ef);
  border-color: var(--primary, #2490ef);
}

.abrak-jalali-picker__day.is-empty {
  cursor: default;
  opacity: 0;
}

.abrak-jalali-picker__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-top: 8px;
}

.abrak-jalali-picker__footer input[type="time"] {
  width: 108px;
  direction: ltr;
  text-align: center;
}

/* Abrak shell branding. */
.abrak-brand-logo {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  object-position: center;
}

html[dir="rtl"] .body-sidebar .sidebar-header .header-logo .icon-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
}

html[dir="rtl"] .body-sidebar .sidebar-header .header-logo .abrak-brand-logo {
  width: 32px;
  height: 32px;
}

/* Workspace launcher labels: Persian names must remain readable in RTL. */
html[dir="rtl"] .desktop-icon,
html[dir="rtl"] .desktop-icon .icon-caption,
html[dir="rtl"] .desktop-icon .icon-title {
  overflow: visible !important;
}

html[dir="rtl"] .desktop-icon .icon-title {
  display: block;
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  height: auto !important;
  max-height: none !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  text-overflow: clip !important;
  direction: rtl;
  text-align: center;
  line-height: 1.55;
  padding-inline: 2px;
}

html[dir="rtl"] .desktop-icon .icon-caption {
  height: auto !important;
  min-height: 1.55em;
  text-align: center;
}

/* Dashboard Chart DateRange: allow full Jalali range text without clipping */
html[dir="rtl"] [data-fieldtype="DateRange"] input,
html[dir="rtl"] .chart-actions [data-fieldtype="DateRange"] input,
html[dir="rtl"] .widget-control [data-fieldtype="DateRange"] input {
  min-width: 220px !important;
  text-align: center;
  direction: ltr;
}
