/* تفعيل RTL */
html,
body {
    direction: rtl;
}

body {
    margin: 0 !important;
    padding: 0 !important;
}

/* عكس توزيع الصفحة الرئيسية */
.dashboard-grid {
    direction: rtl;
}

/* القائمة الجانبية */
.dashboard-grid-sidenav-left {
    order: 3;
}

.dashboard-grid-content {
    order: 2;
}

/* شريط البحث */
form {
    direction: rtl;
}

input {
    text-align: right;
}

/* أيقونة البحث */
input {
    padding-right: 3rem !important;
    padding-left: .75rem !important;
}

.icon-lg,
.absolute.left-1 {
    left: auto !important;
    right: .25rem !important;
}

/* عكس الهوامش */
.ml-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.ml-3 {
    margin-left: 0 !important;
    margin-right: .75rem !important;
}

.ml-11 {
    margin-left: 0 !important;
    margin-right: 2.75rem !important;
}

.mr-1 {
    margin-right: 0 !important;
    margin-left: .25rem !important;
}

.mr-6 {
    margin-right: 0 !important;
    margin-left: 1.5rem !important;
}

/* القوائم */
[data-menu-id] a {
    flex-direction: row;
    justify-content: flex-start;
}

/* عكس النصوص */
.text-left {
    text-align: right !important;
}

/* الكاروسيل */
.carousel-grid {
    direction: rtl;
}

/* الأسهم */
.lucide-chevron-left {
    transform: rotate(180deg);
}

.lucide-chevron-right {
    transform: rotate(180deg);
}

/* أزرار الكاروسيل */
.carousel-grid + div button:first-child {
    order: 2;
}

.carousel-grid + div button:last-child {
    order: 1;
}

.z-popover,
.z-popover [role="dialog"],
.z-popover [role="menu"] {
    direction: rtl;
    text-align: right;
}

.z-popover > [role="dialog"],
.z-popover > [role="presentation"] {
    max-height: inherit !important;
}

#be-notifications-popover > [role="dialog"] {
    width: min(27.5rem, calc(100vw - 1.5rem));
}

.dashboard-grid-footer {
    backdrop-filter: blur(14px);
}

.be-mobile-footer-nav {
    display: none;
}

[data-be-track-active="true"] {
    background: var(--be-accent);
    border-radius: .5rem;
}

[data-be-track-active="true"] img {
    box-shadow: 0 0 0 2px var(--be-primary);
}

.dashboard-grid-navbar > .flex {
    justify-content: flex-start !important;
}

.dashboard-grid-navbar a[aria-label="Go to homepage"] {
    order: -10;
}

.dashboard-grid-navbar .ml-auto.flex.items-center {
    order: 10;
    margin-right: auto !important;
    margin-left: 0 !important;
}

.z-popover button,
.z-popover a,
.z-popover [role="menuitem"] {
    text-align: right !important;
}

.z-popover li > button,
.z-popover li > a {
    flex-direction: row;
}

.z-popover li > button > .mr-auto,
.z-popover li > a > .mr-auto {
    margin-right: 0 !important;
    margin-left: auto !important;
}

.z-popover li > button > svg,
.z-popover li > a > svg {
    transform: scaleX(-1);
}

html,
body,
#root {
    width: 100%;
    max-width: 100%;
}

.dashboard-grid,
.dashboard-grid-navbar,
.dashboard-grid-content,
.dashboard-grid-footer,
.web-player-container {
    min-width: 0;
}

.dashboard-grid-content {
    contain: layout paint;
}

.web-player-container {
    width: 100%;
    max-width: 100%;
}

.content-grid {
    max-width: 100%;
}

.z-popover {
    max-width: calc(100vw - 1.5rem);
}

.z-popover > [role="dialog"],
.z-popover > [role="presentation"] {
    max-width: 100% !important;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template:
            "navbar" auto
            "content" minmax(0, 1fr)
            "footer" auto / minmax(0, 1fr) !important;
        height: 100dvh;
        gap: .5rem;
    }

    .dashboard-grid-sidenav-left,
    .dashboard-grid-sidenav-left-2,
    .dashboard-grid-sidenav-left-3,
    .dashboard-grid-sidenav-right {
        display: none !important;
    }

    .dashboard-grid-navbar {
        margin: .5rem !important;
    }

    .dashboard-grid-navbar > .flex {
        height: auto !important;
        min-width: 0;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        row-gap: .5rem;
        padding-inline: .75rem !important;
    }

    .dashboard-grid-navbar form {
        order: 10;
        flex: 1 0 100% !important;
        width: 100%;
        margin-inline: 0 !important;
    }

    .dashboard-grid-navbar input {
        height: 2.75rem !important;
    }

    .dashboard-grid-content {
        margin-inline: .5rem;
        border-radius: min(var(--be-panel-radius), 16px);
    }

    .web-player-container {
        padding: 1rem !important;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        gap: .35rem;
    }

    .dashboard-grid-navbar a[href="/backstage/upload"] {
        display: none !important;
    }

    .dashboard-grid-navbar .ml-auto:not(.flex.items-center) {
        margin-right: 0 !important;
    }

    .dashboard-grid-footer {
        height: auto !important;
        min-height: 6rem;
        flex-wrap: wrap;
        align-items: center !important;
        gap: .5rem .75rem;
        padding: .75rem !important;
    }

    .dashboard-grid-footer > div {
        min-width: 0 !important;
    }

    .dashboard-grid-footer > div:first-child {
        order: 1;
        width: calc(100% - 3rem) !important;
        flex: 1 1 calc(100% - 3rem);
    }

    .dashboard-grid-footer > div:nth-child(2) {
        order: 3;
        width: 100% !important;
        max-width: none !important;
        flex: 1 0 100%;
    }

    .dashboard-grid-footer > div:nth-child(3) {
        order: 2;
        width: auto !important;
        min-width: 0 !important;
        flex: 0 0 auto;
    }

    .dashboard-grid-footer > div:nth-child(3) .w-24 {
        display: none !important;
    }

    .dashboard-grid-footer img {
        width: 3rem !important;
        height: 3rem !important;
    }

    .dashboard-grid-footer .min-w-45 {
        min-width: 0 !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:first-child {
        gap: .25rem;
    }

    .z-popover {
        left: .75rem !important;
        right: .75rem !important;
        width: auto !important;
    }
}

@media (max-width: 560px) {
    .dashboard-grid-navbar > .flex {
        gap: .35rem;
        padding-inline: .5rem !important;
    }

    .dashboard-grid-navbar {
        /*border-bottom: 1px solid var(--be-border) !important;*/
    }

    .dashboard-grid-navbar form {
        display: none !important;
    }

    .dashboard-grid-navbar a[aria-label="Go to homepage"] {
        display: flex !important;
        align-items: center;
        flex: 0 0 auto;
        height: 1.75rem !important;
        max-height: 1.75rem !important;
    }

    .dashboard-grid-navbar a[aria-label="Go to homepage"] img {
        display: block !important;
        width: auto !important;
        height: 100% !important;
        max-height: 1.75rem !important;
        object-fit: contain;
    }

    .dashboard-grid-navbar span[id="_r_d_"] span {
        display: none !important;
    }

    .dashboard-grid-navbar span[id="_r_d_"] svg,
    .dashboard-grid-navbar span[id="_r_d_"] svg path[d="m7 10 5 5 5-5H7z"] {
        display: none !important;
    }

    .web-player-container {
        padding: .75rem !important;
    }

    .default-grid {
        --grid-cols: 2;
        --grid-col-gap: 12px;
        --grid-row-gap: 14px;
    }

    .compact-grid {
        --grid-cols: 1;
        --grid-rows: 4;
        --grid-col-gap: 12px;
    }

    .content-grid.carousel-grid {
        scroll-padding-inline: .75rem;
    }

    .dashboard-grid-footer {
        margin: .35rem !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "track controls"
            "nav nav";
        align-items: center !important;
        gap: 0 .5rem !important;
        padding: 0 !important;
        border-radius: min(var(--be-panel-radius), 16px) !important;
        border: 1px solid var(--be-border);
        background: var(--be-card);
        box-shadow: 0 1px 3px #0000001a, 0 1px 2px -1px #0000001a;
        overflow: hidden;
    }

    .dashboard-grid-footer > div:first-child {
        grid-area: track;
        width: auto !important;
        min-width: 0 !important;
        flex-basis: auto;
        padding: .5rem .625rem .625rem 0;
    }

    .dashboard-grid-footer > div:first-child > .flex {
        gap: .625rem !important;
    }

    .dashboard-grid-footer > div:first-child img {
        width: 2.25rem !important;
        height: 2.25rem !important;
        border-radius: .375rem !important;
    }

    .dashboard-grid-footer #be-footer-like-btn {
        display: none !important;
    }

    .dashboard-grid-footer > div:nth-child(2) {
        grid-area: controls;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: .35rem .25rem .625rem .625rem;
        position: relative;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:first-child {
        justify-content: center;
        gap: 0 !important;
    }

    .dashboard-grid-footer #be-shuffle-btn,
    .dashboard-grid-footer #be-repeat-btn {
        display: none !important;
    }

    .dashboard-grid-footer > div:nth-child(2) button {
        width: 2.625rem !important;
        height: 2.625rem !important;
    }

    .dashboard-grid-footer > div:nth-child(2) .icon-xl {
        font-size: 2.125rem !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        height: .125rem;
        gap: 0 !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) > .text-muted-foreground {
        display: none !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) [role="group"] {
        width: 100% !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) [role="presentation"] {
        height: .125rem !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) [role="presentation"] > div:first-child,
    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) [role="presentation"] > div:nth-child(2) {
        height: .125rem !important;
        border-radius: 0 !important;
    }

    .dashboard-grid-footer > div:nth-child(2) > .flex:nth-child(2) [role="presentation"] > div:nth-child(3) {
        display: none !important;
    }

    .dashboard-grid-footer > div:nth-child(3) {
        display: none !important;
    }

    .be-mobile-footer-nav {
        grid-area: nav;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .75rem max(10%, 34px);
        border-top: 1px solid var(--be-border);
    }

    .be-mobile-footer-nav a,
    .be-mobile-footer-nav button {
        display: flex;
        min-width: 0;
        flex-direction: column;
        align-items: center;
        gap: .375rem;
        overflow: hidden;
        color: inherit;
        font-size: .75rem;
        line-height: 1rem;
        white-space: nowrap;
        border: 0;
        background: transparent;
    }

    .be-mobile-footer-nav a[aria-current="page"] {
        font-weight: 700;
    }
}

@media (max-width: 390px) {
    .default-grid {
        --grid-cols: 2;
        --grid-col-gap: 10px;
    }

    .dashboard-grid-navbar button {
        width: 2.35rem !important;
        height: 2.35rem !important;
    }
}

a[href="/popular-albums"] + svg,
a[href="/popular-tracks"] + svg,
a[href="/new-releases"] + svg,
a[href="/genres"] + svg {
    transform: scaleX(-1);
}

.be-search-empty {
    margin: 2.5rem auto 0;
    width: max-content;
    max-width: 100%;
    text-align: center;
    text-wrap: balance;
}

.be-search-tabs {
    position: relative;
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    border-bottom: 1px solid var(--be-border);
}

.be-search-tabs a {
    display: flex;
    height: 3rem;
    min-width: max-content;
    align-items: center;
    justify-content: center;
    padding-inline: 1.125rem;
    color: var(--be-muted-foreground);
    font-size: .875rem;
    cursor: pointer;
}

.be-search-tabs a[aria-selected="true"] {
    color: var(--be-primary);
}

.be-search-tab-indicator {
    position: absolute;
    right: 0;
    bottom: 0;
    height: 2px;
    width: 106px;
    background: var(--be-primary);
}

.be-search-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    margin-bottom: .5rem;
    border: 1px solid transparent;
    border-radius: min(var(--be-panel-radius), 12px);
    padding-inline: .5rem 0;
    cursor: pointer;
}

.be-search-row:hover {
    background: var(--be-accent);
}

.be-search-row-main {
    display: flex;
    min-width: 0;
    height: 3.5rem;
    flex: 1;
    align-items: center;
    gap: .75rem;
    overflow: hidden;
}

.be-search-row-menu {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    color: var(--be-muted-foreground);
    border-radius: var(--be-button-radius);
}

.be-search-page h2 a > svg {
    transform: scaleX(-1);
}

.be-library-page {
    direction: rtl;
}

.be-library-add-btn {
    display: inline-flex;
    width: 2.625rem;
    height: 2.625rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: var(--be-button-radius);
}

.be-library-add-btn:hover {
    background: var(--be-accent);
}

.be-library-list a {
    display: flex;
    align-items: center;
    gap: .875rem;
    margin-bottom: 1.125rem;
    color: inherit;
    font-size: .875rem;
}

.be-library-icon,
.be-library-placeholder {
    display: flex;
    width: 2.625rem;
    height: 2.625rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: .375rem;
    background: var(--be-secondary);
}

.be-library-placeholder svg {
    max-width: 60%;
    color: var(--be-border);
    font-size: 6rem;
}

@media (max-width: 560px) {
    .be-search-empty {
        margin-top: 2rem;
        padding-inline: 1rem;
    }

    .be-search-page h2 {
        font-size: 1.25rem;
    }

    .be-search-row {
        padding-inline: .25rem 0;
    }
}
