/* Modern Submenu Styles */
.modern-submenu {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Menu Level Styles */
.menu-level {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

.menu-level.active {
    opacity: 1;
    transform: translateX(0);
    z-index: 10;
}

/* Smooth transition for menu level changes */
.menu-level.leaving {
    opacity: 0;
    transform: translateX(-100%);
}

.menu-level.entering {
    opacity: 1;
    transform: translateX(0);
}

/* Menu Header */
.menu-header {
    justify-content: center !important;
    display: flex;
    align-items: center !important;
    padding: 10px 14px;
    background: #d6d6d6; /* رمادي فاتح */
    color: #000000; /* أسود */
    border-radius: 12px 12px 0 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.menu-back-btn {
    display: flex;
    align-items: center;
    background: #ffcc00;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    color: #595a5c;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    margin-right: 5px;
}

.menu-back-btn:hover {
    background: #595a5c;
    transform: translateY(-2px);
}

.menu-back-btn i {
    margin-left: 6px;
    font-size: 12px;
}

.menu-title {
    margin-right: 5px;
    font-size: 16px;
    font-weight: 600;
    color: #000000;
}

/* Menu Items */
.menu-items {
    flex: 1;
    padding: 2px 0;
    margin: 0;
    list-style: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ffcc00 #f1f1f1;
}

.menu-items::-webkit-scrollbar {
    width: 6px;
}

/* RTL Scrollbar positioning - ensure scrollbar appears on the right */
[dir="rtl"] .menu-items {
    /* Force scrollbar to appear on the right for RTL */
    direction: ltr;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ffcc00 #f1f1f1;
}

[dir="rtl"] .menu-items * {
    /* Keep content RTL but scrollbar on right */
    direction: rtl;
}

[dir="rtl"] .menu-items::-webkit-scrollbar {
    width: 6px;
    /* Ensure scrollbar appears on the right */
    direction: ltr;
}

/* Force scrollbar to appear on the left for all menus */
.menu-items {
    direction: rtl;
}

.menu-items * {
    direction: ltr;
}

.menu-items::-webkit-scrollbar {
    width: 6px;
    direction: ltr;
}

.menu-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.menu-items::-webkit-scrollbar-thumb {
    background: #ffcc00;
    border-radius: 3px;
}

.menu-items::-webkit-scrollbar-thumb:hover {
    background: #595a5c;
}

.menu-item {
    margin: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(255, 204, 0, 0.05);
    transform: translateX(4px);
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    color: #2d3748;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.menu-link:hover {
    color: #707070;
}

.menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: #ffcc00;
    transition: width 0.3s ease;
    z-index: -1;
}

.menu-item:hover .menu-link::before {
    width: 4px;
}

.menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    margin-left: 6px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.menu-item:hover .menu-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(255, 204, 0, 0.2);
}

.menu-icon img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.menu-icon i {
    font-size: 12px;
    color: #616161;
}

.menu-text {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    margin: 0 8px;
    line-height: 1.2;
}

.menu-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;    
    border: none;
    color: #595a5c;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}



.menu-arrow i {
    font-size: 10px;
    transition: transform 0.3s ease;
}

.menu-arrow:hover i {
    transform: translateX(-2px);
}

/* Arrow placeholder for items without children */
.menu-arrow-placeholder {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

/* Children count indicator */
.children-count {
    position: absolute;
    left: 8px;
    top: 8px;
    background: #ffcc00;
    color: #595a5c;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    z-index: 1;
}

/* Special styles for home item */
.menu-item-home .menu-icon {
    background: #595a5c;
}

.menu-item-home .menu-icon i {
    color: #595a5c;
}

.menu-item-home:hover .menu-icon {
    box-shadow: 0 4px 16px rgba(89, 90, 92, 0.3);
}

/* RTL Support */
[dir="rtl"] .menu-link {
    flex-direction: row-reverse;
}

[dir="rtl"] .menu-icon {
    order: 1;
    margin-left: 12px;
    margin-right: 0;
}

[dir="rtl"] .menu-text {
    order: 0;
    margin: 0 12px;
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .menu-arrow {
    order: -1;
    margin-left: 12px;
    margin-right: 0;
}

[dir="rtl"] .menu-arrow i {
    /* Keep original direction for RTL - arrow points left */
    transform: none;
}

[dir="rtl"] .menu-arrow:hover i {
    /* Move arrow further left on hover */
    transform: translateX(-2px);
}

[dir="rtl"] .menu-back-btn {
    flex-direction: row-reverse;
}

[dir="rtl"] .menu-back-btn i {
    margin-left: 0;
    margin-right: 6px;
}

/* LTR Support for English */
[dir="ltr"] .menu-link {
    flex-direction: row;
}

[dir="ltr"] .menu-icon {
    order: -1;
    margin-left: 0;
    margin-right: 10px;
}

[dir="ltr"] .menu-text {
    order: 0;
    margin: 0 10px;
    text-align: left;
    direction: ltr;
}

[dir="ltr"] .menu-arrow {
    order: 1;
    margin-left: auto;
    margin-right: 0;
}

[dir="ltr"] .menu-arrow i {
    transform: none;
}

[dir="ltr"] .menu-arrow:hover i {
    transform: translateX(2px);
}

/* Prevent horizontal scrollbar */
.modern-submenu {
    overflow-x: hidden !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .menu-header {
        padding: 12px 16px;
    }

    .menu-title {
        font-size: 16px;
    }

    .menu-link {
        padding: 14px 16px;
    }

    .menu-icon {
        width: 36px;
        height: 36px;
    }

    .menu-text {
        font-size: 14px;
    }
}

/* Animation classes */
.menu-level-entering {
    animation: slideInFromRight 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.menu-level-leaving {
    animation: slideOutToLeft 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutToLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* Loading state */
.modern-submenu.loading {
    position: relative;
}

.modern-submenu.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ffcc00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Legacy support - hide old submenu styles */
.submenu {
    display: none !important;
}
/* Modern Submenu Styles */
.modern-submenu {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Menu Level Styles */
.menu-level {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

.menu-level.active {
    opacity: 1;
    transform: translateX(0);
    z-index: 10;
}

/* Menu Header */
.menu-header {
    justify-content: flex-start;
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #d6d6d6; /* رمادي فاتح */
    color: #000000; /* أسود */
    border-radius: 12px 12px 0 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.menu-back-btn {
    display: flex;
    align-items: center;
    background: #ffcc00;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    color: #595a5c;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    margin-right: 5px;
}

.menu-back-btn:hover {
    background: #595a5c;
    transform: translateY(-2px);
}

.menu-back-btn i {
    margin-left: 6px;
    font-size: 12px;
}

.menu-title {
    margin-right: 5px;
    font-size: 16px;
    font-weight: 600;
    color: #000000;
}

/* Menu Items */
.menu-items {
    flex: 1;
    padding: 4px 0;
    margin: 0;
    list-style: none;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ffcc00 #f1f1f1;
}

.menu-items::-webkit-scrollbar {
    width: 6px;
}

/* RTL Scrollbar positioning - ensure scrollbar appears on the right */
[dir="rtl"] .menu-items {
    /* Force scrollbar to appear on the right for RTL */
    direction: ltr;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ffcc00 #f1f1f1;
}

[dir="rtl"] .menu-items * {
    /* Keep content RTL but scrollbar on right */
    direction: rtl;
}

[dir="rtl"] .menu-items::-webkit-scrollbar {
    width: 6px;
    /* Ensure scrollbar appears on the right */
    direction: ltr;
}

.menu-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.menu-items::-webkit-scrollbar-thumb {
    background: #ffcc00;
    border-radius: 3px;
}

.menu-items::-webkit-scrollbar-thumb:hover {
    background: #595a5c;
}

.menu-item {
    margin: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(255, 204, 0, 0.05);
    transform: translateX(4px);
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: #2d3748;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.menu-link:hover {
    color: #585858;
}

.menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: #ffcc00;
    transition: width 0.3s ease;
    z-index: -1;
}

.menu-item:hover .menu-link::before {
    width: 4px;
}

.menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    margin-left: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.menu-item:hover .menu-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(255, 204, 0, 0.2);
}

.menu-icon img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.menu-icon i {
    font-size: 14px;
    color: #616161;
}

.menu-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    margin: 0 10px;
}

.menu-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: #595a5c;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.menu-arrow:hover {
    transform: scale(1.1);
    background: transparent!important;

}

.menu-arrow i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.menu-arrow:hover i {
    transform: translateX(-2px);
}

/* Special styles for home item */
.menu-item-home .menu-icon {
    background: #595a5c;
}

.menu-item-home .menu-icon i {
    color: #595a5c;
}

.menu-item-home:hover .menu-icon {
    box-shadow: 0 4px 16px rgba(89, 90, 92, 0.3);
}

/* RTL Support */
[dir="rtl"] .menu-link {
    flex-direction: row-reverse;
}

[dir="rtl"] .menu-icon {
    order: 1;
    margin-left: 12px;
    margin-right: 0;
}

[dir="rtl"] .menu-text {
    order: 0;
    margin: 0 12px;
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .menu-arrow {
    order: -1;
    margin-left: 12px;
    margin-right: 0;
}

[dir="rtl"] .menu-arrow i {
    /* Keep original direction for RTL - arrow points left */
    transform: none;
}

[dir="rtl"] .menu-arrow:hover i {
    /* Move arrow further left on hover */
    transform: translateX(-2px);
}

[dir="rtl"] .menu-back-btn {
    flex-direction: row-reverse;
}

[dir="rtl"] .menu-back-btn i {
    margin-left: 0;
    margin-right: 6px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .menu-header {
        padding: 12px 16px;
    }

    .menu-title {
        font-size: 16px;
    }

    .menu-link {
        padding: 14px 16px;
    }

    .menu-icon {
        width: 36px;
        height: 36px;
    }

    .menu-text {
        font-size: 14px;
    }
}

/* Animation classes */
.menu-level-entering {
    animation: slideInFromRight 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

.menu-level-leaving {
    animation: slideOutToLeft 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutToLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* Loading state */
.modern-submenu.loading {
    position: relative;
}

.modern-submenu.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ffcc00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Legacy support - hide old submenu styles */
.submenu {
    display: none !important;
}