:root {
    --bg-color: #0b0c15;
    --taskbar-bg: rgba(10, 15, 30, 0.85);
    --window-bg: rgba(20, 25, 40, 0.95);
    --window-border: #334466;
    --title-bar-bg: #1a2035;
    --title-bar-text: #00a8ff;
    --highlight-color: #00e5ff;
    --text-color: #e0e0e0;
    --icon-text-color: #ffffff;
    --start-menu-bg: rgba(15, 20, 35, 0.95);
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Segoe UI', 'Roboto', sans-serif;
    user-select: none;
    background-color: var(--bg-color);
    /* Cyberpunk Grid Background */
    background-image:
        linear-gradient(rgba(0, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 255, 0.05) 1px, transparent 1px),
        radial-gradient(circle at 50% 50%, rgba(0, 100, 255, 0.2) 0%, transparent 80%);
    background-size: 40px 40px, 40px 40px, 100% 100%;
    background-position: center;
}

#desktop {
    width: 100vw;
    height: calc(100vh - 40px);
    position: relative;
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
}

.desktop-icon {
    width: 80px;
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: background-color 0.1s, border-color 0.1s;
}

.desktop-icon:hover {
    background-color: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.desktop-icon.selected {
    background-color: rgba(0, 229, 255, 0.2);
    border: 1px solid rgba(0, 229, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.desktop-icon img {
    width: 48px;
    height: 48px;
    margin-bottom: 5px;
    pointer-events: none;
}

.desktop-icon span {
    color: var(--icon-text-color);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    font-size: 12px;
    text-align: center;
    word-wrap: break-word;
    max-width: 100%;
}

#taskbar {
    width: 100vw;
    height: 40px;
    background-color: var(--taskbar-bg);
    position: absolute;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    backdrop-filter: blur(10px);
    z-index: 10000;
    border-top: 1px solid rgba(255,255,255,0.1);
}

#start-button {
    width: 36px;
    height: 36px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    border-radius: 4px;
}

#start-button:hover {
    background-color: rgba(255,255,255,0.1);
}

#start-button svg {
    fill: #00a2ed;
    width: 24px;
    height: 24px;
}

#taskbar-apps {
    flex-grow: 1;
    display: flex;
    align-items: center;
    padding-left: 10px;
}

.taskbar-item {
    padding: 5px 10px;
    margin-right: 5px;
    background-color: rgba(255,255,255,0.05);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background-color 0.2s;
    max-width: 150px;
    overflow: hidden;
    white-space: nowrap;
}

.taskbar-item:hover {
    background-color: rgba(255,255,255,0.15);
}

.taskbar-item.active {
    background-color: rgba(255,255,255,0.2);
    border-bottom: 2px solid var(--highlight-color);
}

.taskbar-item img {
    width: 16px;
    height: 16px;
    margin-right: 5px;
}

#clock {
    color: #fff;
    font-size: 12px;
    text-align: right;
    padding: 5px 10px;
    cursor: default;
}

#start-menu {
    position: absolute;
    bottom: 45px;
    left: 10px;
    width: 400px; /* Reduced width for responsiveness */
    max-width: 90vw;
    height: 500px;
    max-height: 80vh;
    background-color: var(--start-menu-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    backdrop-filter: blur(15px);
    display: none;
    flex-direction: column;
    z-index: 10001;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    padding: 20px;
    color: #fff;
}

#start-menu.open {
    display: flex;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.start-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    overflow-y: auto;
}

.start-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.start-menu-item:hover {
    background-color: rgba(255,255,255,0.1);
}

.start-menu-item img {
    width: 32px;
    height: 32px;
    margin-bottom: 5px;
}

.start-menu-item span {
    font-size: 11px;
    text-align: center;
}

/* Window System */
.window {
    position: absolute;
    background-color: var(--window-bg);
    border: 1px solid var(--window-border);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), 0 0 5px rgba(0, 229, 255, 0.1);
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    overflow: hidden;
    min-width: 200px;
    min-height: 100px;
    backdrop-filter: blur(10px);
    resize: both;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.window.active-window {
    border-color: var(--highlight-color);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6), 0 0 10px rgba(0, 229, 255, 0.3);
}

.window.minimized {
    display: none;
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100vh - 40px) !important;
    border-radius: 0;
}

.title-bar {
    height: 30px;
    background-color: var(--title-bar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    user-select: none;
    border-bottom: 1px solid #334466;
}

.title-bar-title {
    font-size: 12px;
    color: var(--title-bar-text);
    display: flex;
    align-items: center;
}

.title-bar-title img {
    width: 16px;
    height: 16px;
    margin-right: 5px;
}

.title-bar-controls {
    display: flex;
}

.control-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: "Segoe MDL2 Assets", sans-serif;
    font-size: 10px;
    color: #555;
}

.control-btn:hover {
    background-color: #e5e5e5;
}

.control-btn.close-btn:hover {
    background-color: #e81123;
    color: white;
}

.window-content {
    flex-grow: 1;
    overflow: auto;
    position: relative;
    background-color: transparent;
    color: var(--text-color);
}

/* File Explorer App */
.explorer-container {
    display: flex;
    height: 100%;
    flex-direction: column;
}

.explorer-toolbar {
    height: 40px;
    background-color: #f9f9f9;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    padding: 0 10px;
}

.explorer-toolbar input {
    width: 100%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 2px;
}

.explorer-body {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

.explorer-sidebar {
    width: 200px;
    background-color: #f0f0f0;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 5px;
    font-size: 12px;
}

.explorer-main {
    flex-grow: 1;
    background-color: #fff;
    overflow-y: auto;
    padding: 10px;
}

.tree-node {
    padding: 2px 5px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.tree-node:hover {
    background-color: #e5f3ff;
}

.tree-node.selected {
    background-color: #cce8ff;
    border: 1px solid #99d1ff;
}

.tree-arrow {
    width: 16px;
    display: inline-block;
    text-align: center;
    font-size: 10px;
    color: #666;
}

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.file-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    border-radius: 2px;
}

.file-item:hover {
    background-color: #e5f3ff;
}

.file-item.selected {
    background-color: #cce8ff;
    border-color: #99d1ff;
}

.file-item img {
    width: 48px;
    height: 48px;
    margin-bottom: 5px;
}

.file-item span {
    font-size: 12px;
    text-align: center;
    word-break: break-all;
    max-width: 100%;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #0b0c15;
}
::-webkit-scrollbar-thumb {
    background: #334466;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--highlight-color);
}

/* Boot Animation */
@keyframes crt-turn-on {
    0% { transform: scale(1, 0.002); opacity: 0; filter: brightness(30); }
    30% { transform: scale(1, 0.002); opacity: 1; filter: brightness(10); }
    50% { transform: scale(1, 1); opacity: 1; filter: brightness(1); }
    100% { transform: scale(1, 1); opacity: 1; filter: brightness(1); }
}

body.booting #desktop, body.booting #taskbar {
    animation: crt-turn-on 0.2s cubic-bezier(0.230, 1.000, 0.320, 1.000);
}

/* Text Viewer */
.text-viewer-content {
    padding: 20px;
    font-family: 'Consolas', monospace;
    font-size: 14px;
    white-space: pre-wrap;
    color: #333;
}

/* Iframe Viewer */
.iframe-viewer {
    width: 100%;
    height: 100%;
    border: none;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    color: #fff;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #fff;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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