/* Force RTL for Persian Admin */
html {
    direction: rtl !important;
}

body {
    direction: rtl !important;
    text-align: right !important;
}

/* Unfold's sidebar is placed by its flex shell. Avoid fixed content margins so
   the shell can collapse into its mobile drawer without causing overflow. */
#main,
#content {
    min-width: 0;
}

/* Center the standalone OTP login card (there is no admin sidebar here). */
body.yara-login {
    --input-bg: #ffffff;
    --input-border: #d8cee7;
    --input-disabled-bg: #f1eafe;
    --input-focus-ring: rgb(135 80 235 / 14%);
    --input-placeholder: #736982;
    --input-text: #120826;
    --yara-border: #e5def0;
    --yara-canvas: #f3f4f6;
    --yara-ink: #120826;
    --yara-muted: #736982;
    --yara-primary: #8750eb;
    --yara-primary-dark: #6934c7;
    --yara-primary-soft: #f1eafe;
    --yara-surface: #ffffff;
    align-items: center;
    background: #f3f4f6;
    box-sizing: border-box;
    color: #120826;
    color-scheme: light;
    display: flex;
    justify-content: center;
    margin: 0;
    min-height: 100vh;
    padding: 1rem;
}

body.yara-login .otp-card {
    background: #ffffff !important;
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    box-sizing: border-box;
    margin: 0 !important;
    max-width: 28rem;
    padding: 2rem;
    width: 100%;
}

body.yara-login .otp-card input {
    -webkit-appearance: none;
    appearance: none;
    background: #ffffff !important;
    background-clip: padding-box !important;
    border-color: #d8cee7 !important;
    caret-color: #120826 !important;
    color: #120826 !important;
    color-scheme: light !important;
}

body.yara-login .otp-card input:-webkit-autofill,
body.yara-login .otp-card input:-webkit-autofill:hover,
body.yara-login .otp-card input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    -webkit-text-fill-color: #120826 !important;
    caret-color: #120826 !important;
}

body.yara-login .otp-card input:-webkit-autofill:focus {
    -webkit-box-shadow:
        0 0 0 1000px #ffffff inset,
        0 0 0 4px rgb(135 80 235 / 14%) !important;
    -webkit-text-fill-color: #120826 !important;
}

/* Fix dropdown menus */
.dropdown-menu {
    right: 0 !important;
    left: auto !important;
    text-align: right !important;
}

/* Fix breadcrumbs */
.breadcrumbs {
    direction: rtl !important;
    text-align: right !important;
}

/* Fix form inputs alignment */
input, textarea, select {
    text-align: right !important;
}

/* Dates, times, and amounts are easier to edit in their natural direction. */
input.yara-localized-input {
    direction: ltr !important;
    text-align: left !important;
}

.yara-toman-field {
    align-items: center;
    direction: ltr;
    display: flex;
    gap: 0.5rem;
}

.yara-toman-field input.yara-toman-input {
    flex: 1 1 auto;
    min-width: 0;
}

.yara-toman-suffix {
    color: var(--input-text);
    direction: rtl;
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Fix table text */
table {
    text-align: right !important;
}

th, td {
    text-align: right !important;
}

/* Fix pagination */
.paginator {
    direction: rtl !important;
}

/* Fix form labels */
label {
    text-align: right !important;
    display: block !important;
}

/* Fix alerts/messages */
.messagelist li {
    text-align: right !important;
    direction: rtl !important;
}

/* =========================================== */
/* DYNAMIC INPUT STYLES (light/dark theme)    */
/* =========================================== */

/* Define light theme variables (default) */
:root {
    --input-bg: #ffffff;
    --input-text: #212529;
    --input-border: #ced4da;
    --input-focus-ring: rgba(13, 110, 253, 0.25);
    --input-placeholder: #6c757d;
    --input-disabled-bg: #e9ecef;
}

/* Dark theme variables – Unfold usually adds .dark to <html> or <body> */
.dark,
[data-theme="dark"] {
    --input-bg: #1e293b;
    --input-text: #e2e8f0;
    --input-border: #475569;
    --input-focus-ring: rgba(96, 165, 250, 0.3);
    --input-placeholder: #94a3b8;
    --input-disabled-bg: #334155;
}

/* Also support system preference for completeness */
@media (prefers-color-scheme: dark) {
    :root:not(.light):not([data-theme="light"]) {
        --input-bg: #1e293b;
        --input-text: #e2e8f0;
        --input-border: #475569;
        --input-focus-ring: rgba(96, 165, 250, 0.3);
        --input-placeholder: #94a3b8;
        --input-disabled-bg: #334155;
    }
}

/* Apply variables to all form inputs */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
    background-clip: padding-box !important;
    border: 1px solid var(--input-border) !important;
    border-radius: 0.375rem !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
    box-sizing: border-box !important;
    color: var(--input-text) !important;
    background-color: var(--input-bg) !important;
}

/* Focus states – dynamic ring */
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
    border-color: #86b7fe !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem var(--input-focus-ring) !important;
    background-color: var(--input-bg) !important;
}

/* Leave boolean controls to Unfold. Its checkbox and switch widgets rely on
   utility classes for their explicit dimensions and thumb positioning. */

/* Keep active boolean switches clearly green in both admin color modes. */
input[type="checkbox"].rounded-full::after {
    background-color: #ffffff !important;
}

input[type="checkbox"].rounded-full:checked {
    background-color: #16a34a !important;
}

.dark input[type="checkbox"].rounded-full:checked,
[data-theme="dark"] input[type="checkbox"].rounded-full:checked {
    background-color: #22c55e !important;
}

/* Disabled & readonly */
input:disabled,
textarea:disabled,
select:disabled,
input[readonly],
textarea[readonly] {
    background-color: var(--input-disabled-bg) !important;
    opacity: 1 !important;
    border-color: var(--input-border) !important;
}

/* Placeholder */
::placeholder {
    text-align: right !important;
    color: var(--input-placeholder) !important;
    opacity: 1 !important;
}

/* Django Unfold specific: flatpickr, autocomplete */
.flatpickr-input,
.autocomplete-input {
    border: 1px solid var(--input-border) !important;
    border-radius: 0.375rem !important;
    background-color: var(--input-bg) !important;
    color: var(--input-text) !important;
}

/* Select arrow consistency */
select {
    appearance: auto !important;
    -webkit-appearance: auto !important;
    background-image: none !important;
}

/* Error states – keep border red but still dynamic background */
.error input,
.error textarea,
.error select,
input.error,
textarea.error,
select.error {
    border-color: #dc3545 !important;
}

.dark .error input,
.dark .error textarea,
.dark .error select,
[data-theme="dark"] .error input,
[data-theme="dark"] .error textarea,
[data-theme="dark"] .error select {
    border-color: #f87171 !important;
}

.yara-store-switcher {
    align-items: center;
    background: rgb(var(--color-primary-50, 245 240 255));
    border-bottom: 1px solid rgb(var(--color-primary-200, 223 205 255));
    display: flex;
    gap: 0.75rem;
    min-height: 3rem;
    padding: 0.5rem 1.5rem;
}

.dark .yara-store-switcher {
    background: rgb(var(--color-primary-950, 45 12 89));
    border-color: rgb(var(--color-primary-800, 85 31 155));
}

.yara-store-switcher form {
    margin: 0;
    min-width: min(22rem, 70vw);
}

.yara-store-switcher select {
    margin: 0 !important;
}

.yara-store-switcher__label {
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Keep the selected-store control inside the viewport on phones. */
@media (max-width: 720px) {
    .yara-store-switcher {
        align-items: stretch;
        flex-direction: column;
        padding: 0.75rem 1rem;
    }

    .yara-store-switcher form {
        min-width: 0;
        width: 100%;
    }
}

@font-face {
  font-family: "Vazir";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/vazir/Vazir-FD-WOL.woff2") format("woff2");
}

@font-face {
  font-family: "Vazir";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/vazir/Vazir-Medium-FD-WOL.woff2") format("woff2");
}

@font-face {
  font-family: "Vazir";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/vazir/Vazir-Bold-FD-WOL.woff2") format("woff2");
}

:root,
:host {
  --font-sans: "Vazir", Tahoma, "Segoe UI", sans-serif;
  --default-font-family: var(--font-sans);
}

/* Ensure native form controls inherit the Persian admin font as well. */
body,
button,
input,
textarea,
select {
  font-family: var(--font-sans) !important;
}




/* Keep Unfold usable when its optional Alpine initialization is delayed. */
html[x-cloak] {
  display: block !important;
}

/* Command search is not used in this admin and must never block the page. */
body > div[x-data="searchCommand()"] {
  display: none !important;
}


:root {
  --yara-ink: #120826;
  --yara-primary: #8750eb;
  --yara-primary-dark: #6934c7;
  --yara-primary-soft: #f1eafe;
  --yara-surface: #ffffff;
  --yara-canvas: #f8f6fc;
  --yara-border: #e5def0;
  --yara-muted: #736982;
  --font-sans: "Vazir", Tahoma, "Segoe UI", sans-serif;
  --default-font-family: var(--font-sans);
}

.dark,
[data-theme="dark"] {
  --yara-ink: #f4efff;
  --yara-primary: #b692ff;
  --yara-primary-dark: #c8adff;
  --yara-primary-soft: #322151;
  --yara-surface: #171321;
  --yara-canvas: #0f0b17;
  --yara-border: #3d334c;
  --yara-muted: #b9adc8;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light):not([data-theme="light"]) {
    --yara-ink: #f4efff;
    --yara-primary: #b692ff;
    --yara-primary-dark: #c8adff;
    --yara-primary-soft: #322151;
    --yara-surface: #171321;
    --yara-canvas: #0f0b17;
    --yara-border: #3d334c;
    --yara-muted: #b9adc8;
    color-scheme: dark;
  }
}

html,
body {
  direction: rtl;
}

body,
button,
input,
textarea,
select {
  font-family: var(--font-sans) !important;
}

/* OTP login is intentionally independent from Unfold's application shell. */
.yara-login {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  box-sizing: border-box;
  color: var(--yara-ink);
  background:
    radial-gradient(circle at 15% 10%, rgb(135 80 235 / 16%), transparent 34%),
    radial-gradient(circle at 90% 90%, rgb(18 8 38 / 10%), transparent 30%),
    var(--yara-canvas);
}

.otp-card {
  width: min(100%, 430px);
  box-sizing: border-box;
  padding: 40px;
  border: 1px solid var(--yara-border);
  border-radius: 28px;
  background: var(--yara-surface);
  box-shadow: 0 28px 80px rgb(18 8 38 / 14%);
  backdrop-filter: blur(12px);
}

.otp-logo {
  display: block;
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
}

.otp-card h1 {
  margin: 0 0 10px;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 700;
}

.otp-card > p {
  margin: 0 0 28px;
  color: var(--yara-muted);
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.8;
}

.otp-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}

.otp-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  border: 1px solid #d8cee7;
  border-radius: 13px;
  outline: 0;
  background: var(--yara-surface);
  color: var(--yara-ink);
  font-size: 1rem;
  transition: border-color 150ms, box-shadow 150ms;
}

.otp-card input:focus {
  border-color: var(--yara-primary);
  box-shadow: 0 0 0 4px rgb(135 80 235 / 14%);
}

.otp-card button {
  width: 100%;
  margin-top: 18px;
  padding: 13px 16px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--yara-primary);
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms, transform 150ms;
}

.otp-card button:hover {
  background: var(--yara-primary-dark);
}

.otp-card button:active {
  transform: translateY(1px);
}

.otp-card button.secondary {
  margin-top: 8px;
  color: var(--yara-muted);
  background: transparent;
}

.otp-card button.secondary:hover {
  color: var(--yara-ink);
  background: var(--yara-primary-soft);
}

.errorlist,
.messages {
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.errorlist {
  color: #b42318;
}

.messages li {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #dfd2f7;
  border-radius: 11px;
  background: var(--yara-primary-soft);
}

@media (max-width: 520px) {
  .yara-login {
    padding: 14px;
  }

  .otp-card {
    padding: 30px 24px;
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dashboard additions intentionally build on Unfold instead of replacing it. */
.yara-dashboard { width: 100%; max-width: 100%; min-width: 0; margin-bottom: 2rem; }
/*
 * Do not use auto-fit here. A long localized sales total can otherwise affect
 * the implicit grid sizing and push the neighbouring card outside a phone's
 * viewport. Explicit minmax(0, 1fr) tracks keep every card inside its column.
 */
.yara-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.yara-stat { display: flex; align-items: center; gap: 1rem; min-width: 0; min-height: 108px; padding: 1.25rem; border: 1px solid var(--yara-border); border-radius: 18px; background: var(--yara-surface); color: var(--yara-ink); box-shadow: 0 8px 24px rgb(18 8 38 / 5%); transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease; }
a.yara-stat:hover { transform: translateY(-2px); border-color: var(--yara-primary); box-shadow: 0 14px 34px rgb(18 8 38 / 9%); }
.yara-stat > span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: var(--yara-primary-dark); background: var(--yara-primary-soft); }
.yara-stat > div { min-width: 0; }
.yara-stat small, .yara-stat strong { display: block; }
.yara-stat small { color: var(--yara-muted); font-size: .78rem; line-height: 1.55; }
.yara-stat strong { margin-top: .35rem; font-size: clamp(1.15rem, 2.2vw, 1.55rem); line-height: 1.55; overflow-wrap: anywhere; }
.yara-dashboard-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.4fr); gap: 1rem; }
.yara-panel { min-width: 0; padding: 1.25rem; border: 1px solid var(--yara-border); border-radius: 18px; background: var(--yara-surface); box-shadow: 0 8px 24px rgb(18 8 38 / 5%); }
.yara-panel > header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.yara-panel h2 { margin: 0; font-size: 1rem; }
.yara-panel header p { margin: .25rem 0 0; color: var(--yara-muted); font-size: .75rem; }
.yara-panel header a { color: var(--yara-primary-dark); font-size: .78rem; font-weight: 700; }
.yara-chart { display: flex; align-items: end; gap: .75rem; min-height: 220px; min-width: 0; overflow-x: auto; overflow-y: hidden; padding-top: 2rem; border-bottom: 1px solid var(--yara-border); -webkit-overflow-scrolling: touch; }
.yara-chart-column { position: relative; display: flex; flex: 1; align-items: center; flex-direction: column; justify-content: end; height: 190px; min-width: 30px; }
.yara-chart-column i { width: min(36px, 70%); height: max(4px, var(--bar-height)); border-radius: 8px 8px 2px 2px; background: linear-gradient(180deg, var(--yara-primary), var(--yara-primary-dark)); transition: height 350ms ease; }
.yara-chart-column small { margin-top: .5rem; color: var(--yara-muted); font-size: .65rem; white-space: nowrap; }
.yara-chart-value { position: absolute; bottom: calc(max(4px, var(--bar-height)) + 27px); opacity: 0; padding: .2rem .4rem; border-radius: 6px; background: var(--yara-ink); color: #fff; font-size: .65rem; transition: opacity 150ms; }
.yara-chart-column:hover .yara-chart-value { opacity: 1; }
.yara-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.yara-panel table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.yara-panel th, .yara-panel td { padding: .75rem .5rem; border-bottom: 1px solid var(--yara-border); text-align: right; white-space: nowrap; }
.yara-panel th { color: var(--yara-muted); font-size: .7rem; font-weight: 500; }
.yara-panel td a { color: var(--yara-primary-dark); font-weight: 700; }
.yara-badge { display: inline-flex; padding: .25rem .55rem; border-radius: 999px; background: var(--yara-primary-soft); color: var(--yara-primary-dark); }
.yara-empty { width: 100%; padding: 2rem !important; color: var(--yara-muted); text-align: center !important; }
* { scrollbar-width: thin; scrollbar-color: #c7b6df transparent; }
@media (max-width: 1024px) {
  .yara-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* The payment total needs a full row to stay readable on compact screens. */
  .yara-stat--sales { grid-column: 1 / -1; }
  .yara-dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .yara-stat-grid { grid-template-columns: minmax(0, 1fr); gap: .75rem; }
  .yara-stat--sales { grid-column: auto; }
  .yara-stat { min-height: 90px; padding: .9rem; }
  .yara-stat > span { width: 38px; height: 38px; }
  .yara-stat strong { font-size: 1.15rem; }
  .yara-panel { padding: 1rem; }
  .yara-panel > header { align-items: flex-start; flex-wrap: wrap; }
  .yara-chart { gap: .5rem; }
  .yara-chart-column { min-width: 2rem; }
}

/* A resized desktop sidebar can otherwise be wider than a narrow viewport. */
@media (max-width: 1280px) {
  #page > div[x-data] {
    max-width: calc(100vw - 1rem);
  }

  #nav-sidebar {
    max-width: calc(100vw - 1rem) !important;
  }
}
@media print { aside, nav, header, .submit-row, .object-tools, .breadcrumbs { display: none !important; } body, main, .yara-panel { background: #fff !important; box-shadow: none !important; color: #000 !important; } main { width: 100% !important; margin: 0 !important; padding: 0 !important; } .invoice { break-inside: avoid; } }
