/* Uyghur Font: Noto Naskh Arabic & UKIJ TuT */
@font-face {
  font-family: 'Noto Naskh Arabic';
  src: local('Noto Naskh Arabic'), local('NotoNaskhArabic'), url('/fonts/NotoNaskhArabic-Regular.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'UKIJ TuT';
  src: local('UKIJ Tuz Tom'), local('UKIJTuzTom'), local('UKIJ TuT'), url('/fonts/UKIJTuT.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'UKIJ Tuz Tom';
  src: local('UKIJ Tuz Tom'), local('UKIJTuzTom'), local('UKIJ TuT'), url('/fonts/UKIJTuT.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'UKIJTuzTom';
  src: local('UKIJ Tuz Tom'), local('UKIJTuzTom'), local('UKIJ TuT'), url('/fonts/UKIJTuT.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Fallback for Inter & Source Sans 3 when encountering Uyghur/Arabic Unicode range */
@font-face {
  font-family: 'Inter';
  src: local('Noto Naskh Arabic'), url('/fonts/NotoNaskhArabic-Regular.ttf') format('truetype'), url('/fonts/UKIJTuT.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

@font-face {
  font-family: 'Source Sans 3';
  src: local('Noto Naskh Arabic'), url('/fonts/NotoNaskhArabic-Regular.ttf') format('truetype'), url('/fonts/UKIJTuT.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

:root {
  --affine-font-uyghur: "Noto Naskh Arabic", "UKIJ TuT", "UKIJ Tuz Tom", "UKIJTuzTom", "Microsoft Uighur", Tahoma, sans-serif;
}

html[lang="ug"],
[lang="ug"] {
  --affine-font-family: var(--affine-font-uyghur), "Inter", "Source Sans 3", Poppins, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Tahoma, Arial, sans-serif !important;
  --affine-font-sans-family: var(--affine-font-uyghur), "Inter", "Source Sans 3", Poppins, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Tahoma, Arial, sans-serif !important;
  --affine-font-serif-family: var(--affine-font-uyghur), "Source Serif 4", serif !important;
  --affine-font-title-family: var(--affine-font-uyghur), "Inter", sans-serif !important;
  --affine-font-base: 15px;
  direction: rtl;
}

html[lang="ug"],
html[lang="ug"] body,
html[lang="ug"] #app,
html[lang="ug"] button,
html[lang="ug"] input,
html[lang="ug"] textarea,
html[lang="ug"] select,
html[lang="ug"] [data-block-id],
html[lang="ug"] [data-theme],
html[lang="ug"] .affine-page-viewport,
html[lang="ug"] .affine-note-block-container,
html[lang="ug"] .doc-title-container,
html[lang="ug"] .inline-editor,
html[lang="ug"] affine-editor-container,
html[lang="ug"] affine-paragraph,
html[lang="ug"] affine-list,
html[lang="ug"] affine-heading,
html[lang="ug"] affine-database,
html[lang="ug"] .affine-sidebar-container,
html[lang="ug"] .affine-modal-content,
html[lang="ug"] .affine-menu,
html[lang="ug"] [role="dialog"],
html[lang="ug"] [role="menu"],
html[lang="ug"] [role="tooltip"],
html[lang="ug"] .chat-panel,
html[lang="ug"] .chat-message,
html[lang="ug"] .ai-chat-history,
html[lang="ug"] .ai-chat-input,
html[lang="ug"] .action-button,
html[lang="ug"] .affine-database-column-text {
  font-family: "Noto Naskh Arabic", "UKIJ TuT", "UKIJ Tuz Tom", "UKIJTuzTom", "Microsoft Uighur", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  letter-spacing: 0 !important;
  font-feature-settings: "liga" 1, "calt" 1;
}

html[lang="ug"] .affine-paragraph-rich-text,
html[lang="ug"] .rich-text,
html[lang="ug"] [data-v-text] {
  line-height: 1.75 !important;
  letter-spacing: 0 !important;
}

html[lang="ug"] .doc-title-container,
html[lang="ug"] .affine-doc-page-block-title,
html[lang="ug"] h1,
html[lang="ug"] h2,
html[lang="ug"] h3,
html[lang="ug"] h4,
html[lang="ug"] h5,
html[lang="ug"] h6 {
  line-height: 1.5 !important;
  letter-spacing: 0 !important;
  font-weight: 600;
}

html[lang="ug"] input:not([type="number"]):not([type="password"]),
html[lang="ug"] textarea {
  direction: rtl;
  text-align: right;
  line-height: 1.6;
}

html[lang="ug"] code,
html[lang="ug"] pre,
html[lang="ug"] .code-block,
html[lang="ug"] affine-code {
  font-family: var(--affine-font-code-family) !important;
  direction: ltr !important;
  text-align: left !important;
}

/* 智能文字排版自动对齐规则 (Unicode-BIDI & Auto Alignment) */
/* 确保中文、英文等 LTR 语言默认靠左排版，避免因复制带格式被错误右对齐 */
.affine-paragraph-rich-text,
.rich-text,
.doc-title-container,
.affine-doc-page-block-title,
.inline-editor,
affine-paragraph,
affine-heading,
affine-list,
[data-block-id] {
  unicode-bidi: plaintext !important;
  text-align: start !important;
}

/* 仅在整体语言明确设置为维吾尔语且处于 RTL 容器时，才强制右对齐 */
html[lang="ug"] .affine-paragraph-rich-text,
html[lang="ug"] .doc-title-container {
  direction: rtl;
  text-align: right;
}

/* 无论何种语言，代码块必须左对齐 */
code, pre, .code-block, affine-code {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: normal !important;
}
