﻿html, body {
    font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
    direction: rtl;
    text-align: right;
    font-size: 14px;
    line-height: 1.6;
}

/* MudBlazor RTL Support */
.mud-layout {
    direction: rtl;
}

.mud-app-bar {
    direction: rtl;
}

.mud-navmenu {
    direction: rtl;
}

    .mud-navmenu .mud-nav-link {
        text-align: right;
        font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
    }

.mud-table {
    direction: rtl;
}

    .mud-table th,
    .mud-table td {
        text-align: right;
        font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
    }

.mud-text-field .mud-input-control {
    text-align: right;
    font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
}

.mud-select .mud-input-control {
    text-align: right;
    font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
}

.mud-button {
    font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
}

.mud-typography {
    font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif !important;
}

/* Disable number formatting features that might interfere with Persian numbers */
* {
    font-variant-numeric: normal !important;
    font-feature-settings: normal !important;
}

/* Ensure consistent font size for numbers and text */
input, select, textarea, .mud-input, .mud-typography, .mud-table td, .mud-table th {
    font-variant-numeric: normal !important;
    font-feature-settings: normal !important;
}

/* Fix for mixed Persian/English text (like order numbers) */
.ltr-content {
    direction: ltr !important;
    display: inline-block;
    unicode-bidi: embed;
    text-align: left !important;
}

/* Ensure proper RTL/LTR handling for table cells with mixed content */
.mud-table td {
    unicode-bidi: plaintext;
}

/* RTL input fields */
.rtl-input input,
.rtl-input .mud-input-slot,
.rtl-input .mud-input-control,
.rtl-input .mud-input,
.mud-input-control-input-container input {
    text-align: right !important;
    direction: rtl !important;
}

.mud-input-adornment-start {
    order: 2;
    margin-left: 0 !important;
    margin-right: 8px !important;
}

/* Fix for Select component label */
.mud-select.mud-select-outlined .mud-input-label {
    right: 14px !important;
    left: auto !important;
    transform-origin: top right !important;
    background-color: transparent;
    padding: 0 4px;
}

.mud-select.mud-select-outlined:not(.mud-shrink) .mud-input-label {
    transform: translate(0, 16px) scale(1) !important;
    top: 0 !important;
}

.mud-select.mud-select-outlined.mud-shrink .mud-input-label {
    transform: translate(-12px, -9px) scale(0.75) !important;
    transform-origin: top right !important;
    background-color: white !important;
    top: 0 !important;
}

/* Fix for DatePicker component label */
.mud-picker.mud-picker-outlined .mud-input-label {
    right: 14px !important;
    left: auto !important;
    transform-origin: top right !important;
    background-color: transparent;
    padding: 0 4px;
}

.mud-picker.mud-picker-outlined:not(.mud-shrink) .mud-input-label {
    transform: translate(0, 16px) scale(1) !important;
    top: 0 !important;
}

.mud-picker.mud-picker-outlined.mud-shrink .mud-input-label {
    transform: translate(-12px, -9px) scale(0.75) !important;
    transform-origin: top right !important;
    background-color: white !important;
    top: 0 !important;
}

/* Fix for empty DatePicker - label should be centered inside the field */
.mud-picker.mud-picker-outlined:not(.mud-shrink) .mud-input-label {
    top: 50% !important;
    transform: translate(0, -50%) scale(1) !important;
}

/* Fix MudBlazor labels in RTL */
.mud-input-label {
    right: 0 !important;
    left: auto !important;
    transform-origin: top right !important;
    padding-right: 0 !important;
}

.mud-input-label-inputcontrol {
    right: 0 !important;
    left: auto !important;
    padding-right: 0 !important;
}

/* Fix outlined variant label positioning */
.mud-input-outlined .mud-input-label {
    right: 14px !important;
    left: auto !important;
    transform-origin: top right !important;
    background-color: white;
    padding: 0 4px;
    pointer-events: none;
    z-index: 1;
}

/* Fix for label when it's shrunk/focused */
.mud-input-label.mud-input-label-filled,
.mud-input-label.mud-input-label-outlined {
    right: 0 !important;
    left: auto !important;
}

/* Fix label inside outlined input when focused or has value */
.mud-input-outlined .mud-input-label.mud-input-label-inputcontrol {
    right: 14px !important;
    left: auto !important;
    background-color: white;
    padding: 0 4px;
}

/* When field is empty - label should be inside at vertical center */
.mud-input-outlined:not(.mud-shrink) .mud-input-label {
    transform: translate(0, 16px) scale(1) !important;
    top: 0 !important;
}

/* When field has focus or value - label moves to top */
.mud-input-outlined.mud-shrink .mud-input-label {
    transform: translate(-12px, -9px) scale(0.75) !important;
    top: 0 !important;
    background-color: white !important;
}

/* Fix for TextField with Margin.Dense */
.mud-input-outlined.mud-input-margin-dense:not(.mud-shrink) .mud-input-label {
    transform: translate(0, 12px) scale(1) !important;
    top: 0 !important;
}

.mud-input-outlined.mud-input-margin-dense.mud-shrink .mud-input-label {
    transform: translate(-12px, -9px) scale(0.75) !important;
    top: 0 !important;
}

/* Fix for empty Select - label should be centered inside the field */
.mud-select.mud-select-outlined:not(.mud-shrink) .mud-input-label {
    top: 50% !important;
    transform: translate(0, -50%) scale(1) !important;
}

/* Additional fixes for RTL TextField labels */
.mud-input-control .mud-input-label {
    right: 14px !important;
    left: auto !important;
}

/* Force proper label positioning for all MudTextField variants */
.mud-input.mud-input-outlined .mud-input-slot::before {
    content: none !important;
}

/* Ensure label stays within bounds */
.mud-input-outlined .mud-input-label-inputcontrol {
    max-width: calc(100% - 28px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Fix for MudTextField specifically in RTL */
.rtl-input.mud-input-outlined .mud-input-label {
    right: 14px !important;
    left: auto !important;
    transform-origin: top right !important;
}

/* When empty, center the label vertically */
.rtl-input.mud-input-outlined:not(.mud-shrink) .mud-input-label {
    top: 50% !important;
    transform: translate(0, -50%) scale(1) !important;
}

/* When focused or has value, move label to top */
.rtl-input.mud-input-outlined.mud-shrink .mud-input-label,
.rtl-input.mud-input-outlined.mud-input-adorned-end .mud-shrink .mud-input-label {
    top: 0 !important;
    transform: translate(-12px, -9px) scale(0.75) !important;
    background-color: white !important;
    padding: 0 4px;
}

/* Fix for TextField component label */
.mud-input-outlined.mud-input-text .mud-input-label {
    right: 14px !important;
    left: auto !important;
    transform-origin: top right !important;
    background-color: transparent;
    padding: 0 4px;
}

/* RTL Dialog Support */
.rtl-dialog {
    direction: rtl !important;
}

    .rtl-dialog .mud-dialog-content {
        direction: rtl !important;
        text-align: right !important;
    }

    .rtl-dialog .mud-dialog-actions {
        direction: rtl !important;
        justify-content: flex-start !important;
    }

    .rtl-dialog .mud-input-label {
        right: 14px !important;
        left: auto !important;
        transform-origin: top right !important;
    }

    .rtl-dialog .mud-input-outlined:not(.mud-shrink) .mud-input-label {
        top: 50% !important;
        transform: translate(0, -50%) scale(1) !important;
    }

    .rtl-dialog .mud-input-outlined.mud-shrink .mud-input-label {
        transform: translate(-12px, -9px) scale(0.75) !important;
        background-color: white !important;
        top: 0 !important;
    }

    /* Fix NumericField label */
    .rtl-dialog .mud-input-outlined .mud-input-label {
        background-color: white !important;
    }

/* Fix MudTabs RTL */
.mud-tabs .mud-tabs-toolbar {
    direction: rtl !important;
}

.mud-tabs .mud-tabs-toolbar-wrapper {
    direction: rtl !important;
}

.mud-tabs .mud-tabs-panels {
    direction: rtl !important;
}

/* Fix tab content */
.mud-tab-panel {
    direction: rtl !important;
}

/* Ensure tabs toolbar content is properly aligned RTL */
.mud-tabs-toolbar-content {
    flex-direction: row-reverse !important;
}

html[dir="rtl"] .mud-tabs .mud-tab-slider {
    display: none !important;
}

/* Loading Progress Animation */
#app {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.loading-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
}

    .loading-progress circle {
        fill: none;
        stroke: #594ae2;
        stroke-width: 4;
        transform-origin: 50% 50%;
        stroke-dasharray: 251.2;
        stroke-dashoffset: 0;
    }

        .loading-progress circle:nth-child(1) {
            stroke: #e8e8e8;
        }

        .loading-progress circle:nth-child(2) {
            stroke: #594ae2;
            animation: loading-progress 2s ease-in-out infinite;
        }

@keyframes loading-progress {
    0% {
        stroke-dashoffset: 251.2;
        transform: rotate(0deg);
    }

    50% {
        stroke-dashoffset: 62.8;
        transform: rotate(180deg);
    }

    100% {
        stroke-dashoffset: 251.2;
        transform: rotate(360deg);
    }
}

.loading-progress-text {
    position: absolute;
    top: calc(50% + 60px);
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-weight: bold;
    color: #594ae2;
    font-size: 16px;
    font-family: 'IRANSans', 'YekanBakh', 'Tahoma', 'Arial', sans-serif;
}

    .loading-progress-text::after {
        content: "در حال بارگذاری";
    }
