/* DESKTOP STYLES */

.desktop-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    /* Will contain higher Z children */
}

.desktop-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('../assets/wallpapers/default.jpg');
    background-size: cover;
    background-position: center;
    z-index: -1;
}

.desktop-background.fallback {
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
}

/* Desktop Grid */
.desktop-grid {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    height: calc(100vh - 48px);
    /* Minus taskbar */
    padding: 10px;
    gap: 4px;
    z-index: var(--z-desktop-icons);
}

.desktop-icon {
    width: 76px;
    height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 0;
    border: 1px solid transparent;
    border-radius: 4px;
    margin-bottom: 8px;
    transition: all 0.1s;
}

.desktop-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.desktop-icon.selected {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.icon-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin-bottom: 4px;
    /* CSS Fallback for missing images */
    background-color: transparent;
}

.icon-img[src=''] {
    display: none;
}

/* CSS Update for SVG Icons */
.icon-img-container {
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-img-container svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.icon-label {
    color: white;
    font-size: 12px;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    word-wrap: break-word;
    max-width: 100%;
    line-height: 1.2;
}

/* Taskbar */
.taskbar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(32, 32, 32, 0.85);
    backdrop-filter: blur(20px);
    z-index: 2000;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Left align Start, Right align Tray */
    padding: 0 16px;
}

.taskbar-icons {
    display: flex;
    gap: 8px;
    height: 100%;
    align-items: center;
}

.taskbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.taskbar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.taskbar-btn:active {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(0.95);
}

/* Start Button specific */
.start-btn svg {
    fill: #00a4ef;
}

/* System Tray (Right Side) */
.system-tray {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 100%;
}

.tray-item {
    padding: 4px 8px;
    border-radius: 4px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    cursor: default;
    color: white;
}

.tray-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tray-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 12px;
    line-height: 1.2;
    padding: 0 8px;
    min-width: 70px;
}

.tray-icon-group {
    display: flex;
    gap: 8px;
}

/* Language Popup Menu */
.lang-popup-menu {
    position: absolute;
    bottom: 50px;
    /* Above taskbar */
    right: 120px;
    /* Approximate position aligned with Lang icon */
    width: 200px;
    background: rgba(32, 32, 32, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

.lang-popup-menu.hidden {
    display: none;
    pointer-events: none;
}

.lang-item {
    padding: 10px 12px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lang-item.selected {
    background: rgba(255, 255, 255, 0.05);
    /* Subtle highlight */
    font-weight: 500;
}

.lang-code {
    font-weight: 600;
    width: 30px;
}

/* Start Menu */
.start-menu {
    position: absolute;
    bottom: 60px;
    /* Above taskbar */
    left: 10px;
    /* Aligned roughly with Start Button */
    width: 640px;
    height: 700px;
    background: rgba(32, 32, 32, 0.85);
    /* Slightly more opaque */
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    /* Below Lang Menu (9999), Above Desktop */
    display: flex;
    flex-direction: column;
    padding: 24px;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-origin: bottom left;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    visibility: hidden;
    color: white;
}

.start-menu.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Search Bar */
.start-search-container {
    margin-bottom: 20px;
}

.start-search-bar {
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Very subtle border */
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    /* Accent line */
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: white;
    font-size: 14px;
}

.start-search-bar::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-icon-placeholder {
    margin-right: 10px;
    opacity: 0.7;
}

/* Pinned Apps Section */
.start-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 12px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
}

.all-apps-btn {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.start-apps-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px 8px;
    padding: 0 12px;
    margin-bottom: auto;
    /* Push footer to bottom */
    overflow-y: auto;
    max-height: 500px;
}

/* App Item */
.start-app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
    text-align: center;
}

.start-app-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.start-app-icon {
    width: 32px;
    height: 32px;
    /* Basic style for placeholder icons */
    background: #0078D7;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: white;
}

/* If using SVGs inside */
.start-app-icon svg {
    width: 100%;
    height: 100%;
}

.start-app-name {
    font-size: 11px;
    color: #e0e0e0;
    line-height: 1.2;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer (User & Power) */
.start-menu-footer {
    height: 64px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 48px;
    margin: 0 -24px -24px -24px;
    /* Stretch to edges */
    background: rgba(0, 0, 0, 0.2);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.footer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
}

.footer-user:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #555;
    background-image: url('../assets/avatars/user.jpg');
    /* Fallback */
    background-size: cover;
}

.user-name-small {
    font-size: 13px;
    font-weight: 500;
}

.footer-power-container {
    position: relative;
    /* To anchor the popup */
}

.footer-power {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.footer-power:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Sharper, smoother SVG */
.power-icon-svg {
    stroke: white;
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.footer-power:hover .power-icon-svg {
    transform: scale(1.1);
}

/* Power Menu Popup */
.power-menu-popup {
    position: absolute;
    bottom: 55px;
    right: 0;
    width: 160px;
    background: #2b2b2b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.power-menu-popup:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.power-menu-popup.hidden {
    display: flex;
    /* Override display:none to allow transition */
    visibility: hidden;
}

.power-item {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
}

.power-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.power-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}