/**
 * @package     Joomla.Site
 * @subpackage  mod_ouimenu
 *
 * @copyright   (C) 2024 Pros.bzh <https://pros.bzh>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

/* Base menu styles */
.mod-ouimenu {
    position: relative;
    width: 100%;
    height: auto;
  
    /* Remove overflow hidden to allow absolute positioning outside container */
    overflow: visible;
}

/* Menu items */
.mod-ouimenu li {
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.mod-ouimenu .nav-item {width:100%;}


.mod-ouimenu li:last-child {
    border-bottom: none;
}

.mod-ouimenu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.mod-ouimenu a:hover {
    background-color: #f5f5f5;
}

/* Submenu styles - absolute positioning */
.mod-ouimenu__sub {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%; /* Fixed width for submenus */
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    max-height: 500px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Show submenu when parent is active */
.mod-ouimenu li.active > .mod-ouimenu__sub {
    opacity: 1;
    visibility: visible;
}

/* Mobile styles are now the default - submenus appear below */

/* Icons for menu items */
.mod-ouimenu__folder-icon,
.mod-ouimenu__document-icon,
.mod-ouimenu__arrow-icon,
.mod-ouimenu__back-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.mod-ouimenu__folder-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffc107'%3E%3Cpath d='M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z'/%3E%3C/svg%3E");
}

.mod-ouimenu__document-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%234caf50'%3E%3Cpath d='M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z'/%3E%3C/svg%3E");
}

.mod-ouimenu__arrow-icon {
    margin-left: auto;
    margin-right: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23757575'%3E%3Cpath d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z'/%3E%3C/svg%3E");
}

.mod-ouimenu__back-icon {
    transform: rotate(180deg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23757575'%3E%3Cpath d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z'/%3E%3C/svg%3E");
}

/* Back button styles */
.mod-ouimenu__back {
    background-color: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
    z-index: 1001;
}

.mod-ouimenu__back-link {
    font-weight: bold;
    color: #555;
    cursor: pointer;
    display: block;
    width: 100%;
}

/* Active item styles */
.mod-ouimenu li.active > a {
    background-color: #e8f5e9;
    color: #2e7d32;
}

/* Hover effect for parent items */
.mod-ouimenu li.parent:hover > .mod-ouimenu__sub {
    opacity: 1;
    visibility: visible;
}

/* Add a slight delay to prevent accidental closing */
.mod-ouimenu li.parent > .mod-ouimenu__sub {
    transition-delay: 0.1s;
}

/* Ensure submenus of submenus also appear below */
.mod-ouimenu__sub .mod-ouimenu__sub {
    top: 100%;
    left: 0;
}

/* Arrow pointing down for submenus that unfold below */
.mod-ouimenu li.parent > a .mod-ouimenu__arrow-icon {
    transform: rotate(90deg);
}