/* Apple-style Menu with Light Orange Theme */

/* Main Navigation */
.apple-navbar {
    background-color: rgba(255, 245, 235, 0.8); /* Very light orange background */
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 1px 0 rgba(255, 140, 66, 0.2); /* Light orange shadow */
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 48px;
    transition: all 0.3s ease;
}

.apple-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 22px;
}

/* Main Menu Items */
.apple-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 100%;
}

.apple-menu-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.apple-menu-link {
    color: #FF8C42; /* Light orange */
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    padding: 0 10px;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.apple-menu-link:hover {
    color: #FF5722; /* Darker orange */
}

/* Dropdown Menus */
.apple-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: rgba(255, 245, 235, 0.95); /* Very light orange background */
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(255, 140, 66, 0.2); /* Light orange shadow */
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    padding: 10px 0;
    z-index: 1001;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 140, 66, 0.1); /* Light orange border */
}

.apple-menu-item:hover .apple-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.apple-dropdown-item {
    display: block;
    padding: 8px 16px;
    color: #FF8C42; /* Light orange */
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.apple-dropdown-item:hover {
    background-color: #FFC09F; /* Lighter orange */
    color: #FF5722; /* Darker orange */
}

/* Submenu */
.apple-submenu {
    position: relative;
}

.apple-submenu-dropdown {
    position: absolute;
    top: 0;
    left: 100%;
    background-color: rgba(255, 245, 235, 0.95); /* Very light orange background */
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(255, 140, 66, 0.2); /* Light orange shadow */
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    padding: 10px 0;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 140, 66, 0.1); /* Light orange border */
}

.apple-submenu:hover .apple-submenu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.apple-dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.apple-dropdown-toggle::after {
    content: "›";
    font-size: 18px;
    margin-left: 8px;
    color: #FF8C42; /* Light orange */
}

/* Right side menu */
.apple-right-menu {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.apple-search {
    background-color: rgba(255, 220, 190, 0.3); /* Very light orange background */
    border-radius: 8px;
    border: 1px solid rgba(255, 140, 66, 0.2); /* Light orange border */
    padding: 6px 12px;
    font-size: 14px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    margin-right: 15px;
    width: 180px;
    color: #FF5722; /* Darker orange */
}

.apple-search:focus {
    background-color: rgba(255, 220, 190, 0.5); /* Slightly darker light orange background */
    outline: none;
    border-color: rgba(255, 140, 66, 0.5); /* Darker light orange border */
}

.apple-search::placeholder {
    color: rgba(255, 140, 66, 0.7); /* Light orange with opacity */
}

.apple-user-menu {
    position: relative;
}

.apple-user-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #FF8C42; /* Light orange */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.apple-user-icon:hover {
    background-color: #FF5722; /* Darker orange */
}

/* Mobile Toggle Button */
.apple-mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    color: #FF8C42; /* Light orange */
    cursor: pointer;
    margin-right: 15px;
    padding: 8px;
    position: absolute;
    left: 10px; /* Position at the left edge instead of right */
    right: auto; /* Remove right positioning */
}

/* Responsive */
@media (max-width: 992px) {
    /* Make navbar fully green on mobile */
    .apple-navbar {
        background-color: #4CAF50; /* Verde brotăcel pentru navbar */
        height: 56px; /* Slightly taller for better touch targets */
    }
    
    /* Adjust container padding for mobile */
    .apple-container {
        padding: 0 15px 0 50px;
        position: relative;
    }
    
    /* Make mobile toggle button more visible and move it to the left edge */
    .apple-mobile-toggle {
        display: block;
        position: absolute;
        left: 0; /* Position it at the far left */
        right: auto; /* Remove right positioning */
        top: 50%; /* Center vertically */
        transform: translateY(-50%); /* Perfect vertical centering */
        margin-left: 0;
        margin-right: 0;
        color: white; /* White color for better contrast */
        font-size: 28px;
        padding: 10px 15px;
        background: none;
        border-radius: 8px;
        z-index: 1010; /* Ensure it's above other elements */
    }
    
    /* Optimize top bar items like search and user buttons */
    .apple-right-menu {
        margin-left: 10px;
    }
    
    .apple-right-menu form {
        display: none; /* Hide search on mobile to save space */
    }
    
    /* Make sure user menu and cart buttons are styled better for mobile */
    .apple-right-menu .apple-menu-item {
        margin-right: 5px;
    }
    
    .apple-right-menu .apple-menu-item .apple-menu-link {
        color: white;
        font-weight: 600;
        background: none;
        border-radius: 6px;
        margin: 0;
        padding: 10px;
    }
    
    /* Fix dropdown positioning for user menu to open downward on mobile */
    .apple-right-menu .apple-dropdown {
        right: 0;
        left: 0; /* Full width */
        width: 100%;
        max-width: 100%;
        position: fixed;
        top: 56px; /* Match navbar height */
        transform: none;
        border-radius: 0;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        z-index: 1100;
        display: none;
        padding: 0;
        background-color: rgba(76, 175, 80, 0.95); /* Verde brotăcel pentru dropdown */
    }
    
    /* Make dropdown visible when active with grid - using green */
    .apple-right-menu .apple-dropdown.active {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        animation: fadeIn 0.2s ease;
        background-color: rgba(76, 175, 80, 0.95); /* Verde brotăcel pentru dropdown grid */
    }
    
    /* Apply the reversed order to the last three items */
    /* For a menu with exactly 3 items */
    .apple-right-menu .apple-dropdown.active.items-3 .apple-dropdown-item:nth-child(1) {
        order: 3;
    }
    
    .apple-right-menu .apple-dropdown.active.items-3 .apple-dropdown-item:nth-child(2) {
        order: 2;
    }
    
    .apple-right-menu .apple-dropdown.active.items-3 .apple-dropdown-item:nth-child(3) {
        order: 1;
    }
    
    /* For a menu with exactly 6 items */
    .apple-right-menu .apple-dropdown.active.items-6 .apple-dropdown-item:nth-child(4) {
        order: 6;
    }
    
    .apple-right-menu .apple-dropdown.active.items-6 .apple-dropdown-item:nth-child(5) {
        order: 5;
    }
    
    .apple-right-menu .apple-dropdown.active.items-6 .apple-dropdown-item:nth-child(6) {
        order: 4;
    }
    
    /* For a menu with exactly 9 items */
    .apple-right-menu .apple-dropdown.active.items-9 .apple-dropdown-item:nth-child(7) {
        order: 9;
    }
    
    .apple-right-menu .apple-dropdown.active.items-9 .apple-dropdown-item:nth-child(8) {
        order: 8;
    }
    
    .apple-right-menu .apple-dropdown.active.items-9 .apple-dropdown-item:nth-child(9) {
        order: 7;
    }
    
    /* Generic solution using nth-last-child */
    .apple-right-menu .apple-dropdown.active .apple-dropdown-item:nth-last-child(3) {
        order: 3;
    }
    
    .apple-right-menu .apple-dropdown.active .apple-dropdown-item:nth-last-child(2) {
        order: 2;
    }
    
    .apple-right-menu .apple-dropdown.active .apple-dropdown-item:nth-last-child(1) {
        order: 1;
    }
    
    /* Mobile-specific styles for dropdown items */
    
    /* Hide text labels on mobile for profile, orders and logout */
    .apple-dropdown-item .profile-menu-text,
    .apple-dropdown-item .orders-menu-text,
    .apple-dropdown-item .logout-menu-text {
        display: none;
    }
    
    /* Center icons in menu items and make them larger for better touch */
    .profile-menu-item,
    .orders-menu-item,
    .logout-menu-item {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 20px 15px !important;
        position: relative;
        border-right: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background-color: rgba(76, 175, 80, 0.9); /* Verde brotăcel pentru item-uri */
    }
    
    /* Show icon for profile menu item */
    .profile-menu-item::before {
        content: "\f2bd"; /* Font Awesome user-circle icon */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 24px;
        display: inline-block;
        color: white;
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    /* Show icons for orders menu item */
    .orders-menu-item::before {
        content: "\f07a"; /* Font Awesome shopping cart icon */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 24px;
        display: inline-block;
        color: white;
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    /* Show icon for logout menu item */
    .logout-menu-item::before {
        content: "\f2f5"; /* Font Awesome sign-out-alt icon */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 24px;
        display: inline-block;
        color: white;
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    /* Make badge smaller and more compact */
    .orders-menu-item .badge {
        position: absolute;
        top: 10px;
        right: 10px;
        font-size: 0.6rem;
        padding: 0.2rem 0.4rem;
        min-width: 16px;
        height: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Hide the invoice icon and inner badge on mobile */
    .orders-menu-item .badge i,
    .orders-menu-item .badge .badge {
        display: none;
    }
    
    .apple-menu {
        display: none;
        position: absolute;
        top: 56px; /* Match navbar height */
        left: 0;
        right: 0;
        background-color: rgba(60, 160, 60, 0.95); /* Verde brotăcel mai închis */
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 0;
        box-shadow: 0 10px 20px rgba(76, 175, 80, 0.2);
    }
    
    .apple-menu.active {
        display: flex;
    }
    
    /* Make all menu items have the same background color */
    .apple-menu-item {
        width: 100%;
        height: auto;
        background-color: rgba(60, 160, 60, 0.95); /* Match dropdown background color */
    }
    
    /* Make all menu links have the dropdown background color by default */
    .apple-menu-link {
        padding: 12px 20px;
        width: 100%;
        display: block;
        color: white;
        font-weight: 500;
        font-size: 16px;
        background-color: rgba(50, 150, 50, 0.85); /* Verde brotăcel mai închis */
    }
    

    
    .apple-menu-link:hover {
        color: #E8F5E9; /* Verde brotăcel foarte deschis pentru hover */
        background-color: rgba(80, 185, 80, 0.8); /* Verde brotăcel mai deschis pentru hover */
    }
    
    /* Make sure Font Awesome icons are visible */
    .apple-menu-link i,
    .apple-dropdown-item i {
        color: white;
        margin-right: 8px;
        font-size: 18px; /* Slightly larger icons */
    }
    
    /* Make login and registration links more visible */
    .apple-right-menu .apple-menu-item .apple-menu-link {
        color: white;
        font-weight: 600;
        background-color: rgba(255, 255, 255, 0.2); /* Slightly more visible background */
        border-radius: 6px;
        margin: 5px 20px;
        padding: 10px 15px;
        text-align: center;
    }
    
    /* Verde pentru dropdown toggle */
    .apple-dropdown-toggle {
        background-color: rgba(76, 175, 80, 0.7);
    }
    
    .apple-dropdown-toggle::after {
        content: "↓";
        font-size: 14px;
        margin-left: 5px;
        color: white; /* Ensure the dropdown arrow is white */
    }
    
    /* Verde pentru dropdown */
    .apple-dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background-color: rgba(50, 150, 50, 0.85); /* Verde brotăcel mai închis pentru dropdown */
        border-radius: 0;
        padding-left: 20px;
        display: none;
        border: none;
        width: 100%;
    }
    
    .apple-dropdown.active {
        display: block;
    }
    
    .apple-dropdown-item {
        color: white; /* White text for better contrast */
        font-weight: 500;
        padding: 12px 20px;
        border-left: 3px solid rgba(255, 255, 255, 0.3);
    }
    
    .apple-dropdown-item:hover {
        background-color: rgba(100, 200, 100, 0.5); /* Verde brotăcel semi-transparent pentru hover */
        color: white;
        border-left: 3px solid white;
    }
    
    .apple-submenu-dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background-color: rgba(40, 140, 40, 0.85); /* Verde brotăcel și mai închis pentru submenu */
        padding-left: 20px;
        display: none;
        border: none;
        width: 100%;
    }
    
    .apple-submenu-dropdown.active {
        display: block;
    }
    
    .apple-search {
        width: 140px;
    }
    
    /* Hide username text and show icon instead */
    .apple-right-menu .apple-menu-item .user-menu-text {
        display: none;
    }
    
    /* Add user icon when username is hidden */
    .apple-right-menu .apple-menu-item .user-menu-link::before {
        content: "\f007"; /* Font Awesome user icon */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 22px;
        display: inline-block;
        color: white;
    }
    
    /* Style the user icon container with green */
    .apple-right-menu .apple-menu-item .user-menu-link {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        background-color: rgba(60, 150, 60, 0.3); /* Verde brotăcel semi-transparent */
    }
    
    /* Remove dropdown arrow for user menu on mobile */
    .apple-right-menu .apple-menu-item .user-menu-link.apple-dropdown-toggle::after {
        content: "";
        display: none;
    }
    
    /* Make the login and registration links more compact for mobile */
    .apple-right-menu {
        margin-left: auto;
        display: flex;
        align-items: center;
    }
    
    /* For non-authenticated users - login and register buttons */
    .apple-right-menu .apple-menu-item:not(:last-child) {
        margin-right: 2px;
    }
    
    /* Style login and register buttons as compact icons with green */
    .apple-right-menu .apple-menu-item a.apple-menu-link:not(.user-menu-link):not(.apple-dropdown-toggle) {
        font-size: 0; /* Hide text */
        width: 38px;
        height: 38px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: rgba(60, 150, 60, 0.3); /* Verde brotăcel semi-transparent */
        border-radius: 50%;
    }
    
    /* Add icons to login and register buttons */
    .apple-right-menu .apple-menu-item a[href*="login"]::before {
        content: "\f2f6"; /* Font Awesome sign-in icon */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 18px;
        color: white;
    }
    
    .apple-right-menu .apple-menu-item a[href*="register"]::before {
        content: "\f234"; /* Font Awesome user-plus icon */
        font-family: "Font Awesome 5 Free";
        font-weight: 900;
        font-size: 18px;
        color: white;
    }
    
    /* Optimize dropdown menu placement and size */
    .apple-menu-item .apple-dropdown {
        width: 100%;
        left: 0;
        right: 0;
        z-index: 1100;
    }
    
    /* Make dropdown menu text wrap properly */
    .apple-dropdown-item {
        white-space: normal;
        word-break: break-word;
        padding: 10px 15px;
    }
    
    /* Ensure text doesn't overflow on small screens */
    .apple-menu-link {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: calc(100vw - 120px); /* Adjust based on other elements */
    }
    
    /* Make all dropdown menus full width for consistent mobile experience */
    .apple-menu-item .apple-dropdown,
    .apple-submenu .apple-submenu-dropdown {
        width: 100%;
        max-width: 100%;
        left: 0;
        right: 0;
    }
    
    /* Ensure dropdown menu text fits and wraps properly */
    .apple-dropdown-item,
    .apple-submenu-dropdown .apple-dropdown-item {
        white-space: normal !important;
        word-break: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* For a single row of 3 items */
    .apple-right-menu .apple-dropdown.active.items-3 .apple-dropdown-item:nth-child(1) {
        order: 3;
    }
    
    .apple-right-menu .apple-dropdown.active.items-3 .apple-dropdown-item:nth-child(2) {
        order: 2;
    }
    
    .apple-right-menu .apple-dropdown.active.items-3 .apple-dropdown-item:nth-child(3) {
        order: 1;
    }
    
    /* Add specific classes to be added via JavaScript when menu is shown */
    .order-reverse-1 { order: 3 !important; }
    .order-reverse-2 { order: 2 !important; }
    .order-reverse-3 { order: 1 !important; }
    
    /* Animation for smooth appearance */
    @keyframes fadeIn {
        0% { opacity: 0; transform: translateY(-10px); }
        100% { opacity: 1; transform: translateY(0); }
    }
}

@media (max-width: 576px) {
    .apple-search {
        display: none;
    }
    
    .apple-container {
        padding: 0 10px;
    }
    
    /* Optimize for very small screens */
    .apple-dropdown-item {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .apple-menu-link {
        font-size: 15px;
        max-width: calc(100vw - 100px);
    }
    
    /* Make badges smaller on small screens */
    .apple-dropdown-item .badge {
        max-width: 60px;
        font-size: 0.7rem;
    }
    
    /* Make login/register icons smaller on very small screens */
    .apple-right-menu .apple-menu-item a.apple-menu-link:not(.user-menu-link):not(.apple-dropdown-toggle) {
        width: 32px;
        height: 32px;
    }
    
    /* Make the user menu grid 2 columns on very small screens instead of 3 */
    .apple-right-menu .apple-dropdown.active {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Make the menu items text smaller on very small screens */
    .apple-dropdown-item {
        font-size: 13px;
        padding: 8px 12px;
    }
    

}

/* Extra small screen optimizations */
@media (max-width: 400px) {
    /* Further optimize spacing for very small screens */
    .apple-container {
        padding: 0 5px;
    }
    
    /* Make login/register icons even smaller */
    .apple-right-menu .apple-menu-item a.apple-menu-link:not(.user-menu-link):not(.apple-dropdown-toggle) {
        width: 30px;
        height: 30px;
        margin: 0 2px;
    }
    
    .apple-right-menu .apple-menu-item a[href*="login"]::before,
    .apple-right-menu .apple-menu-item a[href*="register"]::before {
        font-size: 16px;
    }
    
    /* Force single column layout for user menu on tiny screens */
    .apple-right-menu .apple-dropdown.active {
        grid-template-columns: repeat(1, 1fr) !important;
    }
    
    /* Adjust dropdown items for better readability */
    .apple-dropdown-item {
        padding: 8px 10px;
        font-size: 14px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }
    
    /* Make dropdown icons more prominent */
    .apple-dropdown-item i {
        margin-right: 8px;
        font-size: 18px;
    }
    
    /* Reduce navbar height for compact display */
    .apple-menu {
        height: 50px;
    }
    
    /* Ensure notifications are visible but compact */
    .apple-badge {
        padding: 0.15rem 0.35rem;
        font-size: 0.65rem;
    }
}

.apple-submenu-dropdown.active-touch {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.apple-mobile-toggle {
    display: block;
    margin-left: auto;
}

.apple-search {
    width: 140px;
}

.apple-dropdown-toggle::after {
    content: "↓";
    font-size: 14px;
    margin-left: 5px;
    color: white; /* Ensure the dropdown arrow is white */
} 