/* IRASO — زبان بصری و انیمیشن (R-035) */

:root {
    --iraso-ease: cubic-bezier(.22, .61, .36, 1);
    --iraso-fast: 150ms;
    --iraso-base: 220ms;
    --iraso-slow: 320ms;
}

/* ---------- ورود پله‌ای ---------- */
@keyframes irapo-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rise { animation: irapo-rise var(--iraso-slow) var(--iraso-ease) both; }

.rise-stagger > * { animation: irapo-rise var(--iraso-slow) var(--iraso-ease) both; }
.rise-stagger > *:nth-child(1) { animation-delay: 0ms; }
.rise-stagger > *:nth-child(2) { animation-delay: 45ms; }
.rise-stagger > *:nth-child(3) { animation-delay: 90ms; }
.rise-stagger > *:nth-child(4) { animation-delay: 135ms; }
.rise-stagger > *:nth-child(5) { animation-delay: 180ms; }
.rise-stagger > *:nth-child(6) { animation-delay: 225ms; }

/* ---------- کارت‌ها ---------- */
.card {
    transition: transform var(--iraso-fast) var(--iraso-ease),
                box-shadow var(--iraso-fast) var(--iraso-ease);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .08);
}

/* ---------- دکمه‌ها ---------- */
.btn { transition: transform 120ms var(--iraso-ease), box-shadow 120ms var(--iraso-ease); }
.btn:active { transform: scale(.97); }

/* ---------- جدول ---------- */
.table tbody tr { transition: background-color var(--iraso-fast) ease; }

/* ---------- Skeleton ---------- */
@keyframes iraso-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: iraso-shimmer 1.4s infinite;
    border-radius: .5rem;
    min-height: 1rem;
}

[data-bs-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #2f3349 25%, #3b4058 50%, #2f3349 75%);
    background-size: 200% 100%;
}

/* ---------- Toast ---------- */
@keyframes iraso-toast-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.toast { animation: iraso-toast-in var(--iraso-base) var(--iraso-ease) both; }

/* ---------- Modal ---------- */
.modal.fade .modal-dialog { transform: scale(.97); transition: transform var(--iraso-base) var(--iraso-ease); }
.modal.show .modal-dialog { transform: scale(1); }

/* ---------- Command Palette ---------- */
.command-palette .modal-content {
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .22);
}

.command-palette .palette-input {
    border: 0;
    box-shadow: none;
    font-size: 1.05rem;
    padding: 1rem 1.25rem;
}

.command-palette .palette-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.command-palette .palette-item.active,
.command-palette .palette-item:hover { background: rgba(var(--bs-primary-rgb), .08); }

.command-palette .palette-group { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- احترام به تنظیم کاربر ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ---------- پنل تنظیمات کنار صفحه ---------- */
/* ---------- جستجوی نوار بالا (جمع‌شونده) ---------- */
.navbar-search { position: relative; display: flex; align-items: center; }

.navbar-search .search-trigger { padding: .35rem .5rem; }

.navbar-search .search-box {
    display: flex;
    align-items: center;
    gap: .4rem;
    width: 0;
    opacity: 0;
    overflow: hidden;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    padding: 0;
    transition: width .22s var(--iraso-ease), opacity .18s ease, padding .22s var(--iraso-ease);
}

.navbar-search.open .search-box {
    width: 20rem;
    max-width: 70vw;
    opacity: 1;
    padding: .25rem .6rem;
}

.navbar-search .search-box-icon { color: var(--bs-secondary-color); }

.navbar-search .search-box input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    color: var(--bs-body-color);
    font-size: .95rem;
}

.navbar-search .search-box-close {
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    line-height: 1;
    padding: 0 .1rem;
}

.navbar-search .search-results {
    position: absolute;
    top: calc(100% + .5rem);
    inset-inline-end: 0;
    width: 22rem;
    max-width: 80vw;
    max-height: 24rem;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .14);
    padding: .35rem 0;
    z-index: 1060;
}

.navbar-search .search-results .dropdown-item { border-radius: .5rem; margin: 0 .35rem; padding: .55rem .75rem; }
.navbar-search .search-results .dropdown-item.active,
.navbar-search .search-results .dropdown-item:hover { background: rgba(var(--bs-primary-rgb), .1); }

@media (max-width: 767.98px) {
    .navbar-search.open .search-box { width: 60vw; }
}

/* ---------- پنل تنظیمات کنار صفحه ---------- */

/* ---------- نتایج جستجو (قالب خودش نوار را مدیریت می‌کند) ---------- */
.search-results {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    max-height: 24rem;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    border-radius: 0 0 .75rem .75rem;
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, .12);
    padding: .35rem 0;
    z-index: 1055;
}

.search-results .dropdown-item { border-radius: .5rem; margin: 0 .5rem; padding: .55rem .75rem; }
.search-results .dropdown-item.active,
.search-results .dropdown-item:hover { background: rgba(var(--bs-primary-rgb), .1); }

/* ---------- پنل تنظیمات کنار صفحه ---------- */

/* ---------- پنل تنظیمات کنار صفحه ---------- */
/* ---------- جستجوی نوار بالا (جمع‌شونده) ---------- */
.navbar-search { position: relative; display: flex; align-items: center; }

.navbar-search .search-trigger { padding: .35rem .5rem; }

.navbar-search .search-box {
    display: flex;
    align-items: center;
    gap: .4rem;
    width: 0;
    opacity: 0;
    overflow: hidden;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    padding: 0;
    transition: width .22s var(--iraso-ease), opacity .18s ease, padding .22s var(--iraso-ease);
}

.navbar-search.open .search-box {
    width: 20rem;
    max-width: 70vw;
    opacity: 1;
    padding: .25rem .6rem;
}

.navbar-search .search-box-icon { color: var(--bs-secondary-color); }

.navbar-search .search-box input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    color: var(--bs-body-color);
    font-size: .95rem;
}

.navbar-search .search-box-close {
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color);
    line-height: 1;
    padding: 0 .1rem;
}

.navbar-search .search-results {
    position: absolute;
    top: calc(100% + .5rem);
    inset-inline-end: 0;
    width: 22rem;
    max-width: 80vw;
    max-height: 24rem;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .14);
    padding: .35rem 0;
    z-index: 1060;
}

.navbar-search .search-results .dropdown-item { border-radius: .5rem; margin: 0 .35rem; padding: .55rem .75rem; }
.navbar-search .search-results .dropdown-item.active,
.navbar-search .search-results .dropdown-item:hover { background: rgba(var(--bs-primary-rgb), .1); }

@media (max-width: 767.98px) {
    .navbar-search.open .search-box { width: 60vw; }
}

/* ---------- پنل تنظیمات کنار صفحه ---------- */

/* ---------- جستجوی نوار بالا (مطابق دمو: تمام‌عرض) ---------- */
.layout-navbar { position: relative; }

.layout-navbar .search-input-wrapper {
    position: absolute;
    inset-inline: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    background: var(--bs-body-bg);
    border-radius: inherit;
    z-index: 20;
}

.layout-navbar .search-input-wrapper .search-input {
    background: transparent;
    font-size: 1rem;
    padding-inline: 0;
    height: 100%;
}

.layout-navbar .search-input-wrapper .search-toggler {
    position: static;
    color: var(--bs-secondary-color);
    font-size: 1.1rem;
}

.layout-navbar .search-results {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    max-height: 24rem;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    border-radius: 0 0 .75rem .75rem;
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, .12);
    padding: .35rem 0;
    z-index: 21;
}

.layout-navbar .search-results .dropdown-item { border-radius: .5rem; margin: 0 .5rem; padding: .55rem .75rem; }
.layout-navbar .search-results .dropdown-item.active,
.layout-navbar .search-results .dropdown-item:hover { background: rgba(var(--bs-primary-rgb), .1); }

/* ---------- موبایل: جدول → کارت (U1) ---------- */
@media (max-width: 767.98px) {
    .table-cards thead { display: none; }

    .table-cards tbody tr {
        display: block;
        border: 1px solid var(--bs-border-color);
        border-radius: .75rem;
        margin-bottom: .65rem;
        padding: .55rem .75rem;
        background: var(--bs-body-bg);
    }

    .table-cards tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        border: 0;
        padding: .3rem 0;
    }

    .table-cards tbody td::before {
        content: attr(data-label);
        color: var(--bs-secondary-color);
        font-size: .78rem;
        white-space: nowrap;
    }

    .table-cards tbody td:last-child::before { content: ""; }
}

/* ---------- کلاس‌های کمکی برای حذف استایل درون‌خطی (R-039) ---------- */
.toolbar-search { max-width: 20rem; }
.toolbar-search-sm { max-width: 18rem; }
.w-auto { width: auto !important; }
.col-qty { width: 7rem; }
.col-cost { width: 9rem; }
.col-icon { width: 3rem; }
.col-product-select { min-width: 16rem; }
.col-mini { width: 6rem; }

/* تودرتویی درخت حساب‌ها بر اساس سطح (R-039) */
.account-tree-cell[data-level="2"] { padding-inline-start: 1.5rem !important; }
.account-tree-cell[data-level="3"] { padding-inline-start: 3rem !important; }
.account-tree-cell[data-level="4"] { padding-inline-start: 4.5rem !important; }

/* ---------- نتایج جستجوی سراسری (R-040) ---------- */
.layout-navbar { position: relative; }

.layout-navbar .search-input { color: var(--bs-body-color); }

.search-results {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    z-index: 2000;
    max-height: 24rem;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    border-radius: 0 0 .75rem .75rem;
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, .15);
    padding: .35rem;
}

.search-results .dropdown-item { border-radius: .5rem; }
.search-results .dropdown-item.active,
.search-results .dropdown-item:hover { background: rgba(var(--bs-primary-rgb), .1); }

/* ---------- بلاکر بارگذاری (R-030) ---------- */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--bs-body-bg-rgb, 255, 255, 255), .65);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.page-loader.is-visible { opacity: 1; visibility: visible; }

.page-loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 1.5rem 2rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, .15);
}

.page-loader-text { color: var(--bs-secondary-color); font-size: .9rem; }

/* نمایش فوری بلاکر تا زمان آماده‌شدن صفحه */
.page-loader.is-static { opacity: 1; visibility: visible; }

/* ---------- جستجوی سراسری نوار بالا (طراحی اختصاصی) ---------- */
.global-search-bar {
    position: absolute;
    inset-inline: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: .5rem 1rem;
    background: var(--bs-navbar-bg, var(--bs-body-bg));
    border-radius: inherit;
}

.global-search-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
}

.global-search-icon {
    color: var(--bs-secondary-color);
    font-size: 1.15rem;
    flex: 0 0 auto;
}

.global-search-input {
    height: 2.75rem;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--bs-body-color);
    padding-inline-start: .5rem;
    padding-inline-end: 2.75rem;
}

.global-search-input:focus {
    box-shadow: 0 0 0 .15rem rgba(var(--bs-primary-rgb), .15);
    border-color: var(--bs-primary);
}

.global-search-clear {
    position: absolute;
    inset-inline-end: .6rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(var(--bs-secondary-rgb, 108, 117, 125), .12);
    color: var(--bs-secondary-color);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.global-search-clear:hover { background: rgba(var(--bs-danger-rgb), .15); color: var(--bs-danger); }

.global-search-results {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    z-index: 31;
    max-height: 24rem;
    overflow-y: auto;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    border-radius: 0 0 .75rem .75rem;
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, .15);
    padding: .35rem;
}

.global-search-results .dropdown-item { border-radius: .5rem; }
.global-search-results .dropdown-item.active,
.global-search-results .dropdown-item:hover { background: rgba(var(--bs-primary-rgb), .1); }

/* ---------- تقویم شمسی (اختصاصی) ---------- */
.jalali-pop {
    position: absolute;
    z-index: 2500;
    width: 260px;
    padding: .6rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .75rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, .18);
    font-size: .85rem;
}

.jalali-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.jalali-title { font-weight: 600; }
.jalali-nav { border: 0; background: transparent; font-size: 1.1rem; line-height: 1; padding: .1rem .4rem; border-radius: .35rem; cursor: pointer; color: var(--bs-body-color); }
.jalali-nav:hover { background: rgba(var(--bs-primary-rgb), .1); }
.jalali-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jalali-wd { text-align: center; color: var(--bs-secondary-color); font-size: .72rem; padding: .15rem 0; }
.jalali-day { border: 0; background: transparent; padding: .35rem 0; border-radius: .35rem; cursor: pointer; color: var(--bs-body-color); }
.jalali-day:hover { background: rgba(var(--bs-primary-rgb), .1); }
.jalali-day.is-selected { background: var(--bs-primary); color: #fff; }
.jalali-foot { display: flex; justify-content: space-between; gap: .35rem; margin-top: .45rem; }

/* کارت‌های قابل کلیک داشبورد */
.card-link { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.card-link:hover { transform: translateY(-2px); box-shadow: 0 .75rem 1.5rem rgba(0,0,0,.08); }
