/* Start Menu Styles */
.startmenu {
    position: absolute;
    bottom: var(--taskbar-height);
    left: 0;
    width: 470px;
    background: #ECE9D8; /* Fondo gris claro de XP */
    border: 1px solid #000000; /* Borde negro */
    border-right: 1px solid #FFFFFF; /* Borde blanco a la derecha */
    border-bottom: 1px solid #FFFFFF; /* Borde blanco abajo */
    border-radius: 0; /* Sin redondeo */
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3); /* Sombra para profundidad */
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transform: translateY(12px);
    transform-origin: left bottom;
    transition:
        opacity var(--xp-motion-fast) var(--xp-ease-out),
        transform var(--xp-motion-fast) var(--xp-ease-out);
}

.startmenu.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* Menu Top Bar */
.menutopbar {
    background: linear-gradient(to bottom, #316AC5 0%, #0054E3 100%); /* Degradado azul de XP */
    padding: 5px 10px; /* Padding ajustado */
    display: flex;
    align-items: center;
    gap: 8px; /* Espacio ajustado */
    border-radius: 0; /* Sin redondeo */
}

.userpicture {
    width: 48px;
    height: 48px;
    border: 2px solid white;
    border-radius: 4px;
    background: white;
    padding: 2px;
}

.username {
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

/* Start Menu Middle Section */
.start-menu-middle {
    display: flex;
    background: #ECE9D8; /* Fondo gris claro */
    min-height: 350px; /* Altura aumentada para más contenido */
}

.middle-section {
    flex: 1;
}

.middle-left {
    background: #ECE9D8; /* Fondo gris claro */
    border-right: 1px solid #A0A0A0; /* Borde gris */
    display: flex;
    flex-direction: column;
}

.middle-right {
    background: #C7E2FF; /* Fondo azul más claro para coincidir */
    border-left: 1px solid #FFFFFF; /* Borde blanco a la izquierda */
}

/* Menu Items */
.menu-items {
    flex: 1;
    padding: 2px 0; /* Padding ajustado */
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px; /* Espacio ajustado */
    padding: 4px 10px; /* Padding ajustado */
    cursor: pointer;
    transition: background 0.1s; /* Transición más rápida */
    position: relative;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

.menu-item:hover:not(.disabled) {
    background: #316AC5; /* Azul de selección de XP */
    color: white;
}

.menu-item:focus-visible,
.all-programs-button:focus-visible,
.all-programs-item:focus-visible,
.recently-used-item:focus-visible,
.footer-button:focus-visible {
    outline: 1px dotted #000;
    outline-offset: -3px;
    background: #316AC5;
    color: white;
}

.menu-item.disabled {
    opacity: 0.5;
    cursor: default;
}

.menu-item img {
    width: 24px; /* Tamaño de icono ajustado */
    height: 24px;
}

.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 11px;
    font-weight: normal;
}

.projects-bold {
    font-weight: bold;
}

.item-description {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 2px;
}

.menu-item:hover .item-description {
    opacity: 1;
}

/* Menu Divider */
.menu-divider {
    margin: 0;
    padding: 0;
}

.divider {
    border: none;
    border-top: 1px solid #A0A0A0; /* Borde gris */
    margin: 2px 5px; /* Margen ajustado */
}

.divider-darkblue {
    background: #C7E2FF;
}

.divider-darkblue .divider {
    border-color: #B5C5D7;
}

/* All Programs Button */
.all-programs-container {
    padding: 5px; /* Padding ajustado */
    border-top: 1px solid #A0A0A0; /* Borde gris */
}

.all-programs-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px; /* Padding ajustado */
    cursor: pointer;
    border-radius: 0; /* Sin redondeo */
    transition: background 0.1s; /* Transición más rápida */
}

.all-programs-button:hover {
    background: #316AC5; /* Azul de selección de XP */
    color: white;
}

.all-programs-button img {
    width: 16px;
    height: 16px;
}

/* Start Menu Footer */
.start-menu-footer {
    background: linear-gradient(to bottom, #316AC5 0%, #0054E3 100%); /* Degradado azul de XP */
    padding: 5px 10px; /* Padding ajustado */
    border-radius: 0; /* Sin redondeo */
}

.footer-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px; /* Espacio ajustado */
}

.footer-button {
    display: flex;
    align-items: center;
    gap: 4px; /* Espacio ajustado */
    padding: 4px 8px; /* Padding ajustado */
    cursor: pointer;
    border-radius: 0; /* Sin redondeo */
    transition: background 0.1s; /* Transición más rápida */
    color: white;
    font-size: 11px;
}

.footer-button:hover {
    background: rgba(255,255,255,0.2); /* Fondo blanco transparente en hover */
}

.footer-button img {
    width: 20px;
    height: 20px;
}


/* All Programs Menu */
.all-programs-menu {
    position: absolute;
    left: 100%;
    bottom: 0;
    width: 200px;
    background: #ECE9D8; /* Fondo gris claro */
    border: 1px solid #000000; /* Borde negro */
    border-right: 1px solid #FFFFFF; /* Borde blanco a la derecha */
    border-bottom: 1px solid #FFFFFF; /* Borde blanco abajo */
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3); /* Sombra para profundidad */
    margin-left: 3px;
    display: none;
    opacity: 0;
    transform: translateX(-8px);
}

.all-programs-menu.show {
    display: block;
    animation: submenu-pop var(--xp-motion-fast) var(--xp-ease-out) both;
}

.all-programs-items {
    padding: 2px;
}

.all-programs-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 11px;
}

.all-programs-item:hover:not(.disabled) {
    background: #316AC5;
    color: white;
}

.all-programs-item.disabled {
    opacity: 0.5;
    cursor: default;
}

.all-programs-item img {
    width: 20px;
    height: 20px;
}

.all-programs-separator {
    height: 1px;
    background: #A0A0A0; /* Borde gris */
    margin: 2px 5px;
}

/* Recently Used Menu */
.recently-used-menu {
    position: absolute;
    left: 100%;
    top: auto;
    width: 200px;
    background: #ECE9D8; /* Fondo gris claro */
    border: 1px solid #000000; /* Borde negro */
    border-right: 1px solid #FFFFFF; /* Borde blanco a la derecha */
    border-bottom: 1px solid #FFFFFF; /* Borde blanco abajo */
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3); /* Sombra para profundidad */
    margin-left: 3px;
    display: none;
    opacity: 0;
    transform: translateX(-8px);
}

.recently-used-menu.show {
    display: block;
    animation: submenu-pop var(--xp-motion-fast) var(--xp-ease-out) both;
}

.recently-used-items {
    padding: 2px;
}

.recently-used-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 11px;
}

.recently-used-item:hover:not(.disabled) {
    background: #316AC5;
    color: white;
}

.recently-used-item.disabled {
    opacity: 0.5;
    cursor: default;
}

.recently-used-item img {
    width: 20px;
    height: 20px;
}

/* Menu Arrow */
.mut-menu-arrow {
    color: #000;
    font-size: 10px;
    opacity: 0.6;
}

.menu-item:hover .mut-menu-arrow {
    color: white;
    opacity: 1;
}

.menu-item:focus-visible .mut-menu-arrow {
    color: white;
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .startmenu {
        width: 100%;
        max-width: 380px;
        left: 50%;
        transform: translateX(-50%) translateY(20px);
    }
    
    .startmenu.show {
        transform: translateX(-50%) translateY(0);
    }
    
    .start-menu-middle {
        min-height: 300px;
    }
    
    .all-programs-menu,
    .recently-used-menu {
        position: fixed;
        left: 50%;
        bottom: calc(var(--taskbar-height) + 60px);
        transform: translateX(-50%);
        margin-left: 0;
    }

    .all-programs-menu.show,
    .recently-used-menu.show {
        animation: submenu-pop-mobile var(--xp-motion-fast) var(--xp-ease-out) both;
    }
}

/* Animation for menu items */
@keyframes menuItemSlide {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.startmenu.show .menu-item {
    animation: menuItemSlide 0.18s var(--xp-ease-out);
    animation-fill-mode: both;
}

.startmenu.show .menu-item:nth-child(1) { animation-delay: 0.02s; }
.startmenu.show .menu-item:nth-child(2) { animation-delay: 0.04s; }
.startmenu.show .menu-item:nth-child(3) { animation-delay: 0.06s; }
.startmenu.show .menu-item:nth-child(4) { animation-delay: 0.08s; }
.startmenu.show .menu-item:nth-child(5) { animation-delay: 0.1s; }
.startmenu.show .menu-item:nth-child(6) { animation-delay: 0.12s; }
.startmenu.show .menu-item:nth-child(7) { animation-delay: 0.14s; }
.startmenu.show .menu-item:nth-child(8) { animation-delay: 0.16s; }

@keyframes submenu-pop {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes submenu-pop-mobile {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .startmenu,
    .startmenu.show,
    .all-programs-menu.show,
    .recently-used-menu.show,
    .startmenu.show .menu-item {
        animation: none !important;
        transition: none !important;
    }

    .startmenu,
    .startmenu.show,
    .all-programs-menu,
    .recently-used-menu {
        transform: none;
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .startmenu,
    .startmenu.show,
    .all-programs-menu,
    .recently-used-menu {
        transform: translateX(-50%);
    }
}

/* Balanced, accessible programs catalogue */
.all-programs-menu {
    width: 330px;
    max-height: min(650px, calc(100vh - var(--taskbar-height) - 12px));
    z-index: 1002;
    overflow: hidden;
}

.all-programs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-shadow: 1px 1px #123a83;
    background: linear-gradient(#316ac5, #0054e3);
    border-bottom: 1px solid #003c9d;
}

.all-programs-scroll {
    max-height: calc(min(650px, 100vh - var(--taskbar-height) - 12px) - 100px);
    overflow-y: auto;
    scrollbar-color: #316ac5 #ece9d8;
}

.all-programs-group {
    padding: 4px 3px 3px;
    border-bottom: 1px solid #aca899;
    box-shadow: 0 1px #fff;
}

.all-programs-group:last-child {
    border-bottom: 0;
    box-shadow: none;
}

.all-programs-group h2 {
    margin: 0;
    padding: 3px 7px 2px;
    color: #164f9c;
    font: 700 10px Tahoma, Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.all-programs-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.all-programs-item {
    min-height: 29px;
    padding: 4px 8px;
}

.all-programs-item img {
    object-fit: contain;
}

.recently-used-items {
    min-height: 26px;
}

.recently-used-empty {
    padding: 5px 8px 6px;
    color: #666;
    font-size: 10px;
    font-style: italic;
}

@media (max-width: 768px) {
    .all-programs-menu {
        position: fixed;
        left: 50% !important;
        bottom: calc(var(--taskbar-height) + 60px);
        width: min(350px, calc(100vw - 20px));
        max-height: calc(100dvh - var(--taskbar-height) - 78px);
        margin-left: 0;
        transform: translateX(-50%);
    }

    .all-programs-scroll {
        max-height: calc(100dvh - var(--taskbar-height) - 112px);
        overscroll-behavior: contain;
    }

    .all-programs-item {
        min-height: 36px;
        font-size: 12px;
    }
}

/* Useful additions keep the existing Luna chrome, Tahoma and classic icons. */
.all-programs-header button {
    min-width: 28px;
    min-height: 25px;
    padding: 2px 6px;
}

.xp-program-search {
    display: grid;
    gap: 4px;
    padding: 8px;
    color: #222;
    font: 11px Tahoma, Arial, sans-serif;
    background: #ece9d8;
    border-bottom: 1px solid #aca899;
}

.xp-program-search input {
    width: 100%;
    min-height: 26px;
    font: 12px Tahoma, Arial, sans-serif;
}

.app-search-empty {
    margin: 0;
    padding: 14px 10px;
    font: 11px Tahoma, Arial, sans-serif;
}

.all-programs-menu [hidden] { display: none !important; }

@media (max-width: 768px) {
    .startmenu.library-open .start-menu-middle { display: none; }
    .startmenu .all-programs-menu {
        position: relative;
        left: 0 !important;
        bottom: auto;
        width: 100%;
        max-height: none;
        border: 0;
        margin: 0;
        box-shadow: none;
        transform: none;
        animation: none;
    }
    .startmenu .all-programs-menu.show { opacity: 1; }
    .startmenu .all-programs-scroll {
        max-height: calc(100dvh - var(--taskbar-height) - 225px);
    }
    .all-programs-item, .all-programs-header button { min-height: 44px; }
}
