/**
 * نظام حلول لإدارة المخازن — Hulul Warehouse Management System
 * طبقة الهوية: تستبدل ألوان القالب الأساسية بألوان هوية "حلول"
 * مشتقة من الشعار (بنفسجي → أزرق). تُحمّل بعد app.min.css لتتقدّم عليه
 * دون تعديل ملفات القالب الأصلية.
 */

:root {
    /* ---- ألوان الهوية ---- */
    --hulul-primary: #4a45a3;
    --hulul-primary-rgb: 74, 69, 163;
    --hulul-primary-hover: #3d3989;
    --hulul-primary-active: #332f73;
    --hulul-purple: #623b98;
    --hulul-blue: #0a5aa8;
    --hulul-primary-subtle: #ecebf8;
    --hulul-primary-border-subtle: #c9c7ea;
    --hulul-primary-emphasis: #3d3989;
    --hulul-gradient: linear-gradient(135deg, #623b98 0%, #4a45a3 50%, #0a5aa8 100%);
    --hulul-ink: #1c1b3a;
    --hulul-font: 'Alexandria', 'Segoe UI', Tahoma, sans-serif;

    /* ---- ربط متغيّرات القالب بالهوية ---- */
    --theme-primary: var(--hulul-primary);
    --theme-primary-rgb: var(--hulul-primary-rgb);
    --theme-primary-text-emphasis: var(--hulul-primary-emphasis);
    --theme-primary-bg-subtle: var(--hulul-primary-subtle);
    --theme-primary-border-subtle: var(--hulul-primary-border-subtle);
    --theme-link-color: var(--hulul-primary);
    --theme-link-color-rgb: var(--hulul-primary-rgb);
    --theme-link-hover-color: var(--hulul-primary-hover);
    --theme-sidenav-item-active-color: var(--hulul-primary);
    --theme-font-family-secondary: var(--hulul-font);
}

html[data-bs-theme='dark'] {
    --hulul-primary: #8e8ae0;
    --hulul-primary-rgb: 142, 138, 224;
    --hulul-primary-hover: #a6a2ea;
    --hulul-primary-active: #bcb9f1;
    --hulul-primary-subtle: #22203f;
    --hulul-primary-border-subtle: #3a3768;
    --hulul-primary-emphasis: #bcb9f1;
    --hulul-ink: #ffffff;
}

/* ---- الخط ---- */
body,
.side-nav,
.btn,
.form-control,
.form-select,
h1, h2, h3, h4, h5, h6 {
    font-family: var(--hulul-font);
}

/* ---- الأزرار ---- */
.btn-primary {
    --theme-btn-bg: var(--hulul-primary);
    --theme-btn-border-color: var(--hulul-primary);
    --theme-btn-hover-bg: var(--hulul-primary-hover);
    --theme-btn-hover-border-color: var(--hulul-primary-hover);
    --theme-btn-active-bg: var(--hulul-primary-active);
    --theme-btn-active-border-color: var(--hulul-primary-active);
    --theme-btn-disabled-bg: var(--hulul-primary);
    --theme-btn-disabled-border-color: var(--hulul-primary);
    --theme-btn-focus-shadow-rgb: var(--hulul-primary-rgb);
}

.btn-outline-primary {
    --theme-btn-color: var(--hulul-primary);
    --theme-btn-border-color: var(--hulul-primary);
    --theme-btn-hover-bg: var(--hulul-primary);
    --theme-btn-hover-border-color: var(--hulul-primary);
    --theme-btn-active-bg: var(--hulul-primary);
    --theme-btn-active-border-color: var(--hulul-primary);
    --theme-btn-disabled-color: var(--hulul-primary);
    --theme-btn-disabled-border-color: var(--hulul-primary);
    --theme-btn-focus-shadow-rgb: var(--hulul-primary-rgb);
}

.btn-soft-primary {
    --theme-btn-color: var(--hulul-primary);
    --theme-btn-bg: rgba(var(--hulul-primary-rgb), 0.12);
    --theme-btn-border-color: transparent;
    --theme-btn-hover-color: #fff;
    --theme-btn-hover-bg: var(--hulul-primary);
    --theme-btn-hover-border-color: var(--hulul-primary);
    --theme-btn-active-color: #fff;
    --theme-btn-active-bg: var(--hulul-primary);
    --theme-btn-active-border-color: var(--hulul-primary);
    --theme-btn-focus-shadow-rgb: var(--hulul-primary-rgb);
}

/* زر بتدرّج الهوية */
.btn-brand-gradient {
    background: var(--hulul-gradient);
    border: none;
    color: #fff;
}

.btn-brand-gradient:hover,
.btn-brand-gradient:focus,
.btn-brand-gradient:active {
    color: #fff;
    filter: saturate(1.15) brightness(0.95);
}

/* ---- أدوات النص والخلفية والحدود ---- */
.text-primary {
    color: var(--hulul-primary) !important;
}

.text-primary-emphasis {
    color: var(--hulul-primary-emphasis) !important;
}

.bg-primary,
.text-bg-primary {
    background-color: var(--hulul-primary) !important;
}

.text-bg-primary {
    color: #fff !important;
}

.bg-primary-subtle {
    background-color: var(--hulul-primary-subtle) !important;
}

.border-primary {
    border-color: var(--hulul-primary) !important;
}

.link-primary {
    color: var(--hulul-primary) !important;
}

.link-primary:hover,
.link-primary:focus {
    color: var(--hulul-primary-hover) !important;
}

.badge.bg-primary {
    background-color: var(--hulul-primary) !important;
}

.badge-soft-primary {
    color: var(--hulul-primary);
    background-color: rgba(var(--hulul-primary-rgb), 0.12);
}

.progress-bar {
    background-color: var(--hulul-primary);
}

a {
    color: var(--hulul-primary);
}

a:hover {
    color: var(--hulul-primary-hover);
}

/* ---- الحقول ---- */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: rgba(var(--hulul-primary-rgb), 0.5);
    box-shadow: 0 0 0 0.2rem rgba(var(--hulul-primary-rgb), 0.15);
}

.form-check-input:checked {
    background-color: var(--hulul-primary);
    border-color: var(--hulul-primary);
}

/* ---- القائمة الجانبية ---- */
.side-nav > .side-nav-item.active > a,
.side-nav > .side-nav-item.active > button,
.side-nav .side-nav-item .side-nav-link.active {
    color: var(--hulul-primary) !important;
}

/* ==========================================================================
   شعار الهوية (العلامة + الاسم)
   ========================================================================== */
.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    line-height: 1.15;
}

.brand-lockup:hover {
    text-decoration: none;
}

.brand-mark {
    flex: none;
    display: block;
    position: relative;
    width: 2.375rem;
    height: 2.375rem;
}

.brand-mark-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* النسخة البيضاء تظهر فقط فوق الأسطح الداكنة */
.brand-mark-white {
    display: none;
}

/* الوضع الليلي: كل الأسطح داكنة → العلامة البيضاء */
html[data-bs-theme='dark'] .brand-mark-color {
    display: none;
}

html[data-bs-theme='dark'] .brand-mark-white {
    display: block;
}

html[data-bs-theme='dark'] .brand-name {
    color: #fff;
}

html[data-bs-theme='dark'] .brand-tagline {
    color: rgba(255, 255, 255, 0.65);
}

.brand-lockup-invert .brand-mark-color,
html[data-menu-color='dark'] .sidenav-menu .brand-mark-color,
html[data-menu-color='gradient'] .sidenav-menu .brand-mark-color,
html[data-menu-color='image'] .sidenav-menu .brand-mark-color {
    display: none;
}

.brand-lockup-invert .brand-mark-white,
html[data-menu-color='dark'] .sidenav-menu .brand-mark-white,
html[data-menu-color='gradient'] .sidenav-menu .brand-mark-white,
html[data-menu-color='image'] .sidenav-menu .brand-mark-white {
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
    text-align: start;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--hulul-ink);
}

.brand-tagline {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--theme-secondary-color, #8a969c);
    white-space: nowrap;
}

.brand-lockup-invert .brand-name,
html[data-menu-color='dark'] .sidenav-menu .brand-name,
html[data-menu-color='gradient'] .sidenav-menu .brand-name,
html[data-menu-color='image'] .sidenav-menu .brand-name {
    color: #fff;
}

.brand-lockup-invert .brand-tagline,
html[data-menu-color='dark'] .sidenav-menu .brand-tagline,
html[data-menu-color='gradient'] .sidenav-menu .brand-tagline,
html[data-menu-color='image'] .sidenav-menu .brand-tagline {
    color: rgba(255, 255, 255, 0.7);
}

.brand-lockup-sm .brand-mark {
    width: 1.875rem;
    height: 1.875rem;
}

.brand-lockup-sm .brand-name {
    font-size: 1rem;
}

.brand-lockup-lg .brand-mark {
    width: 3.25rem;
    height: 3.25rem;
}

.brand-lockup-lg .brand-name {
    font-size: 1.75rem;
}

.brand-lockup-lg .brand-tagline {
    font-size: 0.8125rem;
}

/* منطقة الشعار داخل القائمة الجانبية */
.sidenav-menu .logo {
    height: var(--theme-topbar-height);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-inline: 1.25rem;
    line-height: 1.15;
    overflow: hidden;
    text-align: start;
}

/* شعار الشريط العلوي — يظهر على الشاشات الصغيرة فقط (كما في القالب) */
.app-topbar .logo-topbar {
    height: var(--theme-topbar-height);
    padding-inline: 0.75rem;
    line-height: 1.15;
    overflow: hidden;
    text-align: start;
}

@media (max-width: 767.98px) {
    .app-topbar .logo-topbar {
        display: flex;
        align-items: center;
    }
}

/* القائمة المطويّة: العلامة فقط */
html[data-sidenav-size='condensed'] .sidenav-menu .brand-text {
    display: none;
}

/* ==========================================================================
   صفحة الدخول — تخطيط Split Full
   ========================================================================== */
.auth-split {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
}

.auth-split-form {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background-color: var(--theme-secondary-bg);
}

.auth-split-form-inner {
    width: 100%;
    max-width: 27rem;
    min-width: 0;
}

/* اللوحة الجانبية: صورة المخزن + تدرّج الهوية */
.auth-split-visual {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 3.5rem;
    color: #fff;
    background-color: var(--hulul-primary);
}

/* طبقة الصورة مستقلة حتى يمكن تكبيرها ببطء دون تحريك بقية الطبقات */
.auth-split-visual > .auth-split-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: url('../../auth-bg.jpg');
    background-size: cover;
    background-position: center;
    will-change: transform;
}

/* تدرّج الهوية فوق الصورة — بشفافية تُبقي المخزن ظاهراً */
.auth-split-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        200deg,
        rgba(98, 59, 152, 0.62) 0%,
        rgba(74, 69, 163, 0.66) 45%,
        rgba(10, 90, 168, 0.72) 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* تعتيم أسفل اللوحة ليبقى النص مقروءاً */
.auth-split-visual::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 55%;
    background: linear-gradient(to top, rgba(20, 16, 48, 0.72), rgba(20, 16, 48, 0));
    z-index: 1;
    pointer-events: none;
}

.auth-split-visual > * {
    position: relative;
    z-index: 2;
}

.auth-split-brand-mark {
    width: 4rem;
    height: 4rem;
    object-fit: contain;
    margin-bottom: 1.25rem;
    filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.35));
}

.auth-split-headline {
    font-size: clamp(1.6rem, 2.2vw, 2.25rem);
    font-weight: 700;
    line-height: 1.6;
    margin: 0;
    color: #fff;
    text-shadow: 0 1px 24px rgba(0, 0, 0, 0.25);
}

@media (max-width: 991.98px) {
    .auth-split-visual {
        display: none;
    }
}

/* ==========================================================================
   حركة الدخول (Intro)
   كل الحركات داخل prefers-reduced-motion: no-preference — فإن عطّل المستخدم
   الحركة في نظامه ظهرت الصفحة كاملة فوراً بلا أي تحريك.
   ========================================================================== */
@keyframes hululRise {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes hululMarkIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.82);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* تكبير بطيء للصورة (Ken Burns) */
@keyframes hululKenBurns {
    from {
        opacity: 0;
        transform: scale(1.14);
    }
    12% {
        opacity: 1;
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ومضة ضوء تمرّ مرّة واحدة فوق الصورة */
@keyframes hululSheen {
    from {
        transform: translateX(-130%);
    }
    to {
        transform: translateX(130%);
    }
}

/* انزلاق طبقة التدرّج اللوني عند الفتح */
@keyframes hululVeil {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: no-preference) {
    /* ---- اللوحة الجانبية ---- */
    .auth-split-visual > .auth-split-bg {
        animation: hululKenBurns 18s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .auth-split-visual::before,
    .auth-split-visual::after {
        animation: hululVeil 1.1s ease-out both;
    }

    .auth-split-visual > .auth-split-bg::after {
        content: '';
        position: absolute;
        inset: -25%;
        background: linear-gradient(
            105deg,
            transparent 42%,
            rgba(255, 255, 255, 0.16) 50%,
            transparent 58%
        );
        transform: translateX(-130%);
        animation: hululSheen 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.75s both;
        pointer-events: none;
    }

    .auth-split-brand-mark {
        animation: hululMarkIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.42s both;
    }

    .auth-split-headline {
        animation: hululRise 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.58s both;
    }

    /* ---- عمود النموذج: ظهور متدرّج ---- */
    .auth-split-form-inner > *:not(form),
    .auth-split-form-inner form > * {
        animation: hululRise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
    }

    .auth-split-form-inner > *:nth-child(1) { animation-delay: 0.10s; }  /* الشعار */
    .auth-split-form-inner > *:nth-child(2) { animation-delay: 0.18s; }  /* العنوان */
    .auth-split-form-inner > *:nth-child(3) { animation-delay: 0.24s; }  /* السطر التعريفي */
    .auth-split-form-inner > *:nth-child(5) { animation-delay: 0.72s; }
    .auth-split-form-inner > *:nth-child(6) { animation-delay: 0.80s; }

    /* حقوق النشر آخر عنصر دائماً مهما تغيّر ترتيب ما قبله */
    .auth-split-form-inner > *:last-child { animation-delay: 0.80s; }

    /* حقول النموذج — العنصر الأول هو حقل CSRF المخفي */
    .auth-split-form-inner form > *:nth-child(2) { animation-delay: 0.34s; }
    .auth-split-form-inner form > *:nth-child(3) { animation-delay: 0.42s; }
    .auth-split-form-inner form > *:nth-child(4) { animation-delay: 0.50s; }
    .auth-split-form-inner form > *:nth-child(5) { animation-delay: 0.58s; }
    .auth-split-form-inner form > *:nth-child(6) { animation-delay: 0.66s; }

    /* نبضة خفيفة على علامة الشعار في عمود النموذج */
    .auth-brand .brand-mark {
        animation: hululMarkIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
    }
}

/* ---- صف جدول قابل للنقر (row-link.js) ---- */
tr[data-row-href] {
    cursor: pointer;
}

tr[data-row-href]:hover > td {
    background-color: var(--theme-tertiary-bg);
}

tr[data-row-href]:focus-visible {
    outline: 2px solid var(--theme-primary);
    outline-offset: -2px;
}

/* ---- قوائم Choices داخل القالب ---- */
.choices { margin-bottom: 0; }

.choices__inner {
    background-color: var(--theme-body-bg);
    border-color: var(--theme-border-color);
    border-radius: var(--theme-border-radius);
    min-height: calc(1.5em + 0.9rem + 2px);
    padding: 0.35rem 0.75rem 0.15rem;
    font-size: 0.875rem;
}

.choices[data-type*='select-one']::after {  /* سهم القائمة إلى اليسار في RTL */
    right: auto;
    left: 11.5px;
}

.choices[data-type*='select-one'] .choices__inner { padding-bottom: 0.35rem; }

.choices__list--dropdown,
.choices__list[aria-expanded] {
    background-color: var(--theme-body-bg);
    border-color: var(--theme-border-color);
}

.choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: var(--theme-tertiary-bg);
}

.choices__list--dropdown .choices__input { padding: 0.5rem; }

.choices.is-disabled .choices__inner { background-color: var(--theme-secondary-bg); }

.choices-invalid .choices__inner { border-color: var(--theme-danger); }

/* ---- قائمة Choices المنسدلة فوق كل شيء ---- */
.choices__list--dropdown,
.choices__list[aria-expanded] {
    z-index: 1080;                 /* z-index:1 الافتراضي يمرّ تحت البطاقة المجاورة */
}
