/* ═══════════════════════════════════════════════════════════════
   استایل‌های سراسری اپلیکیشن
   ═══════════════════════════════════════════════════════════════ */

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--kerman-font-family);
    background-color: var(--kerman-background);
    color: var(--kerman-text-primary);
    direction: rtl;
    text-align: right;
}

/* ── جلوگیری از overflow افقی ──
   overflow-x روی body در موبایل (به‌ویژه iOS) position:fixed دراور را می‌بُرد
   و منوی همبرگری «بالا نمی‌آید». برش افقی را به محتوای اصلی محدود می‌کنیم. */
html {
    overflow-x: clip;
}

.mud-main-content,
.kerman-main-content {
    overflow-x: clip;
    max-width: 100%;
}

/* ── ریست لینک‌ها ── */
a {
    color: var(--kerman-primary);
    text-decoration: none;
}

a:hover {
    color: var(--kerman-primary-dark);
    text-decoration: underline;
}

/* ── Blazor Error UI ── */
#blazor-error-ui {
    background: var(--kerman-error);
    color: var(--kerman-text-on-primary);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    direction: rtl;
    text-align: right;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 0.75rem;
    top: 0.5rem;
}

/* ── حذف outline پیش‌فرض mouse focus ── */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ── انیمیشن fade برای transition صفحات ── */
.kerman-page-fade {
    animation: kermanFadeIn 0.2s ease-out;
}

@keyframes kermanFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── کلاس‌های utility ── */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* ── ست کردن رنگ Primary روی متون MudBlazor ── */
.mud-text-primary {
    color: var(--kerman-primary) !important;
}

/* ═══════════════════════════════════════════════════════════════
   RTL Fixes for MudBlazor 8 — نسخه اصلاح‌شده
   ═══════════════════════════════════════════════════════════════ */

/* ── ۱. اصلاح transform-origin برچسب‌ها ── */
[dir="rtl"] .mud-input-label,
[dir="rtl"] .mud-input-label-animated,
[dir="rtl"] .mud-input-label-outlined {
    transform-origin: top right !important;
    right: 0 !important;
    left: auto !important;
}

/* ── ۲. موقعیت برچسب در حالت Outlined (وقتی فیلد خالی است) ── */
[dir="rtl"] .mud-input-outlined .mud-input-label {
    right: 14px !important;
    left: auto !important;
}

/* ── ۳. ⭐ اصلاح shrink — مقدار صحیح برای چسبیدن به نوار ── */
[dir="rtl"] .mud-input-label-outlined.mud-input-label-shrink {
    transform: translate(0, -6px) scale(0.75) !important;
    transform-origin: top right !important;
}

/* ── ۴. ⭐ ویژه برای MudNumericField و textarea ها ── */
/* این فیلدها ساختار داخلی متفاوتی دارند و نیاز به اصلاح جدا دارند */
[dir="rtl"] .mud-input-control .mud-input-label-outlined.mud-input-label-shrink {
    transform: translate(0, -6px) scale(0.75) !important;
}

/* ── ۵. اصلاح notch (شکاف outline اطراف label) ── */
[dir="rtl"] .mud-input-outlined-border legend {
    text-align: right !important;
    margin-right: 8px !important;
    margin-left: 0 !important;
    padding-right: 4px !important;
    padding-left: 4px !important;
}

/* ── ۶. اصلاح padding داخلی فیلدها ── */
[dir="rtl"] .mud-input-slot.mud-input-root-outlined {
    padding-right: 14px !important;
    padding-left: 14px !important;
}

/* ── ۷. HelperText و ErrorText ── */
[dir="rtl"] .mud-input-helper-text {
    text-align: right !important;
}

/* ── ۸. character counter (مثل 0/500) ── */
[dir="rtl"] .mud-input-control-helper-container {
    flex-direction: row-reverse !important;
}

/* ── ۹. adornment (آیکون داخل فیلد) ── */
[dir="rtl"] .mud-input-adornment-start {
    margin-right: 0 !important;
    margin-left: 8px !important;
}

[dir="rtl"] .mud-input-adornment-end {
    margin-left: 0 !important;
    margin-right: 8px !important;
}

/* ═══════════════════════════════════════════════════════════════
   ⭐ Fix ویژه textarea (MudTextField با Lines > 1)
   ═══════════════════════════════════════════════════════════════ */

/* وقتی container کلاس mud-shrink دارد (یعنی فیلد focus یا پر است) */
[dir="rtl"] .mud-input.mud-shrink .mud-input-label-outlined,
[dir="rtl"] .mud-input.mud-input-outlined.mud-shrink > label {
    transform: translate(0, -6px) scale(0.75) !important;
    transform-origin: top right !important;
    background: var(--mud-palette-surface, #ffffff) !important;
    padding: 0 4px !important;
    right: 10px !important;
    left: auto !important;
}

/* اطمینان از اینکه label در textarea position درست دارد */
[dir="rtl"] .mud-input-outlined.mud-input-outlined-with-label textarea + label,
[dir="rtl"] .mud-input-outlined.mud-input-outlined-with-label ~ label {
    right: 14px !important;
    left: auto !important;
}

/* کادر آبی توضیحی (MudAlert از نوع Info) — متن از راست */
.mud-alert-filled-info,
.mud-alert-outlined-info,
.mud-alert-text-info {
    direction: rtl !important;
    text-align: right !important;
}

.mud-alert-filled-info .mud-alert-message,
.mud-alert-outlined-info .mud-alert-message,
.mud-alert-text-info .mud-alert-message {
    direction: rtl !important;
    text-align: right !important;
    width: 100%;
}