:root {
    --primary: #7c7ce8;
    --primary-dark: #8b8bf0;
    --primary-soft: rgba(124, 124, 232, 0.12);
    --primary-glow: rgba(124, 124, 232, 0.35);
    --bg: #f5f6fb;
    --bg-alt: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #eef0fa;
    --text: #1f2233;
    --text-soft: #4c5064;
    --text-muted: #8a8fa3;
    --border: #e3e5f0;
    --border-soft: #eef0f8;
    --shadow-sm: 0 2px 6px rgba(30, 32, 60, 0.05);
    --shadow: 0 8px 24px rgba(30, 32, 60, 0.08);
    --shadow-lg: 0 20px 50px rgba(30, 32, 60, 0.12);
    --success: #28c76f;
    --warning: #ff9f43;
    --danger: #ea5455;
    --info: #00cfe8;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;
    --transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s ease;
    --font: 'MirrorFont', 'Vazirmatn', 'Tahoma', sans-serif;
    color-scheme: light;
}

[data-theme="dark"] {
    --primary: #8b8bf0;
    --primary-dark: #a0a0f5;
    --primary-soft: rgba(139, 139, 240, 0.15);
    --primary-glow: rgba(139, 139, 240, 0.45);
    --bg: #0f1120;
    --bg-alt: #161a2e;
    --bg-card: #1a1e35;
    --bg-hover: #232846;
    --text: #eceefb;
    --text-soft: #b8bdd4;
    --text-muted: #7a7f9c;
    --border: #262a45;
    --border-soft: #1f2338;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

@font-face {
    font-family: 'MirrorFont';
    src: url('../fonts/MirrorFont.woff2') format('woff2'),
         url('../fonts/MirrorFont.woff') format('woff'),
         url('../fonts/MirrorFont.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    text-align: right;
    line-height: 1.75;
    font-size: 15px;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, var(--primary-soft), transparent 40%),
        radial-gradient(circle at 85% 80%, var(--primary-soft), transparent 40%);
    pointer-events: none;
    z-index: -1;
    opacity: 0.7;
    transition: opacity var(--transition);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast), opacity var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

svg {
    flex-shrink: 0;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    line-height: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

::selection {
    background: var(--primary);
    color: #fff;
}

::-moz-selection {
    background: var(--primary);
    color: #fff;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

html {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-alt);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.08); }
    70% { transform: scale(0.96); }
    100% { transform: scale(1); }
}

@keyframes ripple {
    0% { box-shadow: 0 0 0 0 var(--primary-glow); }
    70% { box-shadow: 0 0 0 14px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

.fade-in { animation: fadeIn 0.5s ease both; }
.fade-in-up { animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) both; }
.fade-in-down { animation: fadeInDown 0.6s cubic-bezier(0.4, 0, 0.2, 1) both; }
.scale-in { animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both; }
.slide-in-right { animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1) both; }
.slide-in-left { animation: slideInLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1) both; }

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
}

.num,
[data-num],
table.admin-table td,
.stat-value,
.dash-card-value,
.page-link {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

[dir="ltr"],
input[dir="ltr"],
textarea[dir="ltr"] {
    font-feature-settings: "tnum";
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    html {
        scroll-behavior: auto;
    }
}

@media print {
    body::before,
    .header,
    .footer,
    .toast-container,
    .admin-sidebar,
    .admin-topbar {
        display: none !important;
    }
    body {
        background: #fff;
        color: #000;
    }
    .card,
    .table-wrap {
        border: 1px solid #ccc;
        box-shadow: none;
    }
}