/* Allgram admin: branded sidebar (--allgram-brand is set via admin_branding_css) */

.allgram-nav-icon,
.allgram-header-icon {
    font-size: 18px;
    width: 18px;
    flex-shrink: 0;
    line-height: 1;
}


#nav-sidebar,
#nav-sidebar-inner,
div:has(> #nav-sidebar) {
    background-color: var(--allgram-brand) !important;
    border: none;
}


/* Unfold uses SimpleBar (data-simplebar) and hides native scrollbars */
.simplebar-track .simplebar-scrollbar::before {
    background: #ffffff !important;
}

#main > div.border-b {
    background-color: var(--allgram-brand) !important;
    h1, .relative > a {
        color: #ffffff !important;
    }
}

/* Sidebar header: title + subheader (first child of #nav-sidebar-inner) */
#nav-sidebar-inner > div:first-child {
    background-color: var(--allgram-brand) !important;
    border-bottom-color: rgba(255, 255, 255, 0.15) !important;
}

#nav-sidebar-inner [class*="text-font-important-light"],
#nav-sidebar-inner [class*="text-font-subtle-light"],
#header-inner .material-symbols-outlined {
    color: #ffffff !important;
}

/* Logo icon tile on dark sidebar */
#nav-sidebar-inner a[class*="bg-primary-600"] {
    background-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

/* Section headings */
#nav-sidebar-inner h2 {
    color: rgba(255, 255, 255, 0.92) !important;
}

#nav-sidebar-inner h2:hover {
    color: #ffffff !important;
}

/* Nav links */
#nav-sidebar-inner ol a {
    color: rgba(255, 255, 255, 0.82) !important;
}

#nav-sidebar-inner ol a:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
}

#nav-sidebar-inner ol a[class*="bg-base-100"],
#nav-sidebar-inner ol a[class*="text-primary-600"] {
    background-color: rgba(255, 255, 255, 0.14) !important;
    color: #ffffff !important;
}

/* All applications footer link */
/* #nav-sidebar-inner .mt-auto > a {
    color: rgba(255, 255, 255, 0.82) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
} */

#nav-sidebar-inner .mt-auto > a:hover {
    color: #ffffff !important;
}

/* All applications slide-out panel */
#nav-sidebar-inner .mt-auto div.w-80.z-20 {
    background-color: rgb(36 36 59) !important;
    border-right-color: rgba(255, 255, 255, 0.15) !important;
}

#nav-sidebar-inner .mt-auto div.w-80.z-20 h2 {
    color: rgba(255, 255, 255, 0.92) !important;
}

#nav-sidebar-inner .mt-auto div.w-80.z-20 a {
    color: rgba(255, 255, 255, 0.82) !important;
}

#nav-sidebar-inner .mt-auto div.w-80.z-20 a:hover {
    color: #ffffff !important;
}

/* Search field on dark sidebar */
#nav-sidebar-inner [class*="bg-white"][class*="border-base-200"]:not(.absolute) {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

#nav-sidebar-inner input[type="search"],
#nav-sidebar-inner input[type="search"]::placeholder {
    color: rgba(255, 255, 255, 0.75) !important;
}

#nav-sidebar-inner [class*="text-base-400"] {
    color: rgba(255, 255, 255, 0.55) !important;
}

/* Mobile close control */
#nav-sidebar-inner > div:first-child > .material-symbols-outlined {
    color: #ffffff !important;
}

/* Language switcher: cap height so the list scrolls instead of reaching the sticky footer */
#header-inner .relative > div.absolute.w-52 {
    max-height: min(24rem, calc(100vh - 6rem));
    overflow-y: auto;
}

/* Login page */
.allgram-login-page {
    color: #ffffff;
}

.allgram-login-shell {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.allgram-login-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(
            ellipse 80% 70% at 50% 35%,
            color-mix(in srgb, var(--allgram-primary) 72%, #ffffff 8%) 0%,
            color-mix(in srgb, var(--allgram-primary) 42%, var(--allgram-brand) 58%) 38%,
            var(--allgram-brand) 100%
        );
}

.allgram-login-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

.allgram-login-return {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    transition: color 0.15s ease;
}

.allgram-login-return:hover {
    color: #ffffff;
}

.allgram-login-return .material-symbols-outlined {
    font-size: 1rem;
}

.allgram-login-language .relative > button,
.allgram-login-language .relative > a {
    color: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

.allgram-login-language .relative > a .material-symbols-outlined {
    color: rgba(255, 255, 255, 0.9) !important;
}

.allgram-login-language .relative > div.absolute {
    background: rgba(12, 16, 36, 0.96) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
    max-height: min(24rem, calc(100vh - 6rem));
    overflow-y: auto;
}

.allgram-login-language .relative > div.absolute button,
.allgram-login-language .relative > div.absolute a {
    color: rgba(255, 255, 255, 0.88) !important;
    background: rgba(12, 16, 36, 0.96) !important;
}

.allgram-login-center {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 5rem 1rem 2rem;
}

.allgram-login-card {
    width: 100%;
    max-width: 24rem;

    #page {
        background-color: transparent !important;

        h1 {
            color: #ffffff !important;
        }
    }
}

.allgram-login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 2rem;
}

.allgram-login-logo {
    /* display: flex;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem; */
    margin-bottom: 1.25rem;
    /* border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 0.9rem;
    background: linear-gradient(
        145deg,
        color-mix(in srgb, var(--allgram-primary) 70%, #ffffff 10%) 0%,
        color-mix(in srgb, var(--allgram-brand) 80%, #000000 20%) 100%
    );
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    overflow: hidden; */
}

.allgram-login-logo img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.allgram-login-title {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.allgram-login-form label,
.allgram-login-form .required {
    color: rgba(255, 255, 255, 0.95) !important;
}

.allgram-login-form input[type="text"],
.allgram-login-form input[type="password"] {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.34) !important;
    border-radius: 0.65rem !important;
    box-shadow: none !important;
}

.allgram-login-form input[type="text"]::placeholder,
.allgram-login-form input[type="password"]::placeholder {
    color: rgba(255, 255, 255, 0.45) !important;
}

.allgram-login-form input[type="text"]:focus,
.allgram-login-form input[type="password"]:focus {
    border-color: rgba(255, 255, 255, 0.72) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12) !important;
}

.allgram-login-submit button,
.allgram-login-submit a {
    background: color-mix(in srgb, var(--allgram-primary) 88%, #ffffff 4%) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    border-radius: 0.65rem !important;
    min-height: 2.75rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.allgram-login-submit button:hover,
.allgram-login-submit a:hover {
    background: color-mix(in srgb, var(--allgram-primary) 96%, #ffffff 6%) !important;
}

.allgram-login-reset button,
.allgram-login-reset a {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.22) !important;
    color: rgba(255, 255, 255, 0.82) !important;
}

.allgram-login-errors [class*="text-red"],
.allgram-login-errors [class*="bg-red"] {
    color: #fecaca !important;
    background: rgba(127, 29, 29, 0.35) !important;
    border-color: rgba(248, 113, 113, 0.35) !important;
}

/* Changelist footer pagination counters */
.change-list .flex.flex-row.grow.items-center:has(> .py-4) > div[class*="pr-"] > span.font-medium,
.change-list .flex.flex-row.grow.items-center:has(> .py-4) > div[class*="pr-"] > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    flex-shrink: 0;
}

.change-list .flex.flex-row.grow.items-center:has(> .py-4) > div[class*="pr-"] > span.font-medium {
    background: var(--allgram-primary);
    color: #ffffff !important;
}

.change-list .flex.flex-row.grow.items-center:has(> .py-4) > div[class*="pr-"] > a {
    color: var(--allgram-primary) !important;
    background: color-mix(in srgb, var(--allgram-primary) 14%, transparent);
}

.change-list .flex.flex-row.grow.items-center:has(> .py-4) > div[class*="pr-"] > a:hover {
    background: var(--allgram-primary);
    color: #ffffff !important;
}

/* -------------------------------------------------------------------------- */
/* RTL (Arabic and other bidi locales — html dir is set by Unfold/Django)      */
/* -------------------------------------------------------------------------- */

html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] #main,
html[dir="rtl"] #content,
html[dir="rtl"] .change-list,
html[dir="rtl"] .allgram-login-form {
    text-align: right;
}

html[dir="rtl"] input:not([type="checkbox"]):not([type="radio"]),
html[dir="rtl"] select,
html[dir="rtl"] textarea {
    text-align: right;
}

html[dir="rtl"] #nav-sidebar {
    left: auto !important;
    right: 0 !important;
}

html[dir="rtl"] #nav-sidebar-inner .mt-auto div.w-80.z-20 {
    border-right: none !important;
    border-left: 1px solid rgba(255, 255, 255, 0.15) !important;
}

html[dir="rtl"] .allgram-login-return .material-symbols-outlined {
    transform: scaleX(-1);
}

/* Mirror Tailwind physical margin utilities (ml-* <-> mr-*) */
html[dir="rtl"] [class~="ml-1"] { margin-left: 0 !important; margin-right: 0.25rem !important; }
html[dir="rtl"] [class~="ml-2"] { margin-left: 0 !important; margin-right: 0.5rem !important; }
html[dir="rtl"] [class~="ml-3"] { margin-left: 0 !important; margin-right: 0.75rem !important; }
html[dir="rtl"] [class~="ml-4"] { margin-left: 0 !important; margin-right: 1rem !important; }
html[dir="rtl"] [class~="ml-5"] { margin-left: 0 !important; margin-right: 1.25rem !important; }
html[dir="rtl"] [class~="ml-6"] { margin-left: 0 !important; margin-right: 1.5rem !important; }
html[dir="rtl"] [class~="ml-8"] { margin-left: 0 !important; margin-right: 2rem !important; }
html[dir="rtl"] [class~="ml-auto"] { margin-left: 0 !important; margin-right: auto !important; }

html[dir="rtl"] [class~="mr-1"] { margin-right: 0 !important; margin-left: 0.25rem !important; }
html[dir="rtl"] [class~="mr-2"] { margin-right: 0 !important; margin-left: 0.5rem !important; }
html[dir="rtl"] [class~="mr-3"] { margin-right: 0 !important; margin-left: 0.75rem !important; }
html[dir="rtl"] [class~="mr-4"] { margin-right: 0 !important; margin-left: 1rem !important; }
html[dir="rtl"] [class~="mr-5"] { margin-right: 0 !important; margin-left: 1.25rem !important; }
html[dir="rtl"] [class~="mr-6"] { margin-right: 0 !important; margin-left: 1.5rem !important; }
html[dir="rtl"] [class~="mr-8"] { margin-right: 0 !important; margin-left: 2rem !important; }
html[dir="rtl"] [class~="mr-auto"] { margin-right: 0 !important; margin-left: auto !important; }

/* Mirror Tailwind physical padding utilities (pl-* <-> pr-*) */
html[dir="rtl"] [class~="pl-1"] { padding-left: 0 !important; padding-right: 0.25rem !important; }
html[dir="rtl"] [class~="pl-2"] { padding-left: 0 !important; padding-right: 0.5rem !important; }
html[dir="rtl"] [class~="pl-3"] { padding-left: 0 !important; padding-right: 0.75rem !important; }
html[dir="rtl"] [class~="pl-4"] { padding-left: 0 !important; padding-right: 1rem !important; }
html[dir="rtl"] [class~="pl-5"] { padding-left: 0 !important; padding-right: 1.25rem !important; }
html[dir="rtl"] [class~="pl-6"] { padding-left: 0 !important; padding-right: 1.5rem !important; }
html[dir="rtl"] [class~="pl-8"] { padding-left: 0 !important; padding-right: 2rem !important; }

html[dir="rtl"] [class~="pr-1"] { padding-right: 0 !important; padding-left: 0.25rem !important; }
html[dir="rtl"] [class~="pr-2"] { padding-right: 0 !important; padding-left: 0.5rem !important; }
html[dir="rtl"] [class~="pr-3"] { padding-right: 0 !important; padding-left: 0.75rem !important; }
html[dir="rtl"] [class~="pr-4"] { padding-right: 0 !important; padding-left: 1rem !important; }
html[dir="rtl"] [class~="pr-5"] { padding-right: 0 !important; padding-left: 1.25rem !important; }
html[dir="rtl"] [class~="pr-6"] { padding-right: 0 !important; padding-left: 1.5rem !important; }
html[dir="rtl"] [class~="pr-8"] { padding-right: 0 !important; padding-left: 2rem !important; }

/* Mirror border-r / border-l */
html[dir="rtl"] [class~="border-r"] {
    border-right-width: 0 !important;
    border-left-width: 1px !important;
}

html[dir="rtl"] [class~="border-l"] {
    border-left-width: 0 !important;
    border-right-width: 1px !important;
}

/* Mirror absolute left/right positioning */
html[dir="rtl"] [class~="left-0"] { left: auto !important; right: 0 !important; }
html[dir="rtl"] [class~="left-3"] { left: auto !important; right: 0.75rem !important; }
html[dir="rtl"] [class~="right-0"] { right: auto !important; left: 0 !important; }
html[dir="rtl"] [class~="right-3"] { right: auto !important; left: 0.75rem !important; }
html[dir="rtl"] [class~="-right-2"] { right: auto !important; left: -0.5rem !important; }

/* Sidebar-open content offset (Unfold uses xl:ml-72) */
@media (min-width: 1280px) {
    html[dir="rtl"] [class*="xl:ml-72"] {
        margin-left: 0 !important;
        margin-right: 18rem !important;
    }

    html[dir="rtl"] [class*="xl:ml-0"] {
        margin-right: 0 !important;
    }
}

/* Changelist pagination container uses physical padding-right */
html[dir="rtl"] .change-list .flex.flex-row.grow.items-center:has(> .py-4) > div[class*="pr-"] {
    padding-right: 0 !important;
    padding-left: 1rem !important;
}
