/**
 * WebOS — Estilos base del sistema operativo
 * 
 * Variables CSS para tematización, boot screen, escritorio, taskbar, menú contextual.
 * Temas: dark (default) y light.
 */

/* ===== Variables CSS ===== */
:root {
    /* Dark theme (default) */
    --color-bg: #1a1a2e;
    --color-surface: rgba(30, 30, 50, 0.85);
    --color-surface-solid: #1e1e32;
    --color-glass: rgba(255, 255, 255, 0.08);
    --color-glass-hover: rgba(255, 255, 255, 0.15);
    --color-glass-active: rgba(255, 255, 255, 0.2);
    --color-border: rgba(255, 255, 255, 0.1);
    --color-border-hover: rgba(255, 255, 255, 0.2);
    --color-text: #e8e8f0;
    --color-text-secondary: #a0a0b8;
    --color-primary: #6c63ff;
    --color-primary-hover: #7b73ff;
    --color-danger: #ff4757;
    --color-success: #2ed573;
    --color-warning: #ffa502;

    /* Window */
    --window-bg: rgba(25, 25, 45, 0.95);
    --titlebar-bg: rgba(40, 40, 65, 0.95);
    --titlebar-height: 38px;
    --window-radius: 12px;
    --window-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);

    /* Taskbar */
    --taskbar-height: 56px;
    --taskbar-bg: rgba(20, 20, 40, 0.88);

    /* Typography */
    --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 20px;
    --font-size-xl: 28px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.35s ease;

    /* Blur */
    --blur-amount: 20px;
}

/* Light theme */
[data-theme="light"] {
    --color-bg: #e8e8f0;
    --color-surface: rgba(255, 255, 255, 0.85);
    --color-surface-solid: #ffffff;
    --color-glass: rgba(0, 0, 0, 0.04);
    --color-glass-hover: rgba(0, 0, 0, 0.08);
    --color-glass-active: rgba(0, 0, 0, 0.12);
    --color-border: rgba(0, 0, 0, 0.1);
    --color-border-hover: rgba(0, 0, 0, 0.2);
    --color-text: #1a1a2e;
    --color-text-secondary: #606080;
    --color-primary: #5a52d5;
    --color-primary-hover: #6c63ff;

    --window-bg: rgba(255, 255, 255, 0.95);
    --titlebar-bg: rgba(240, 240, 250, 0.95);
    --window-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);

    --taskbar-bg: rgba(240, 240, 250, 0.88);
}

/* ===== Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
}

/* ===== Wallpapers (CSS gradients) ===== */
body.wallpaper-gradient-1 {
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
}

body.wallpaper-gradient-2 {
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
}

body.wallpaper-gradient-3 {
    background: linear-gradient(135deg, #1a002e, #3d0066, #5c0099);
}

body.wallpaper-gradient-4 {
    background: linear-gradient(135deg, #141e30, #243b55);
}

body.wallpaper-gradient-5 {
    background: linear-gradient(135deg, #0d0d0d, #1a1a2e, #16213e);
}

/* Light theme wallpapers */
[data-theme="light"] body.wallpaper-gradient-1,
body[data-theme="light"].wallpaper-gradient-1 {
    background: linear-gradient(135deg, #a8c0d6, #d4c4e7, #e8d5b7);
}

[data-theme="light"] body.wallpaper-gradient-2,
body[data-theme="light"].wallpaper-gradient-2 {
    background: linear-gradient(135deg, #89f7fe, #66a6ff);
}

[data-theme="light"] body.wallpaper-gradient-3,
body[data-theme="light"].wallpaper-gradient-3 {
    background: linear-gradient(135deg, #fbc2eb, #a6c1ee);
}

[data-theme="light"] body.wallpaper-gradient-4,
body[data-theme="light"].wallpaper-gradient-4 {
    background: linear-gradient(135deg, #fdcbf1, #e6dee9);
}

[data-theme="light"] body.wallpaper-gradient-5,
body[data-theme="light"].wallpaper-gradient-5 {
    background: linear-gradient(135deg, #96e6a1, #d4fc79);
}

/* ===== Boot Screen ===== */
#boot-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0a0a1a;
    transition: opacity 0.6s ease;
}

#boot-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.boot-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 32px;
    animation: boot-pulse 1.5s ease-in-out infinite;
}

.boot-logo svg {
    width: 100%;
    height: 100%;
}

@keyframes boot-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

.boot-title {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: #fff;
    letter-spacing: 4px;
    margin-bottom: 40px;
}

.boot-progress-container {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.boot-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ===== Desktop ===== */
#desktop {
    position: fixed;
    inset: 0;
    bottom: var(--taskbar-height);
    overflow: hidden;
}

/* Desktop Icons */
.desktop-icons {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    padding: 20px;
    height: 100%;
}

.desktop-icon {
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.desktop-icon:hover {
    background: var(--color-glass-hover);
}

.desktop-icon:active {
    background: var(--color-glass-active);
}

.desktop-icon .icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.desktop-icon .icon svg {
    width: 100%;
    height: 100%;
}

.desktop-icon .label {
    font-size: var(--font-size-xs);
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
    word-break: break-word;
    max-width: 72px;
}

/* ===== Taskbar ===== */
#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--taskbar-height);
    background: var(--taskbar-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 9999;
}

.taskbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.taskbar-center {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.taskbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

/* Start Button */
#start-button {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

#start-button:hover {
    background: var(--color-glass-hover);
}

#start-button:active {
    background: var(--color-glass-active);
}

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

/* Taskbar App Icons */
.taskbar-app {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background var(--transition-fast);
}

.taskbar-app:hover {
    background: var(--color-glass-hover);
}

.taskbar-app.active {
    background: var(--color-glass-active);
}

.taskbar-app.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 3px;
    background: var(--color-primary);
    border-radius: 2px;
}

.taskbar-app.minimized::after {
    width: 6px;
    height: 3px;
}

.taskbar-app svg {
    width: 24px;
    height: 24px;
}

/* Taskbar Clock */
.taskbar-clock {
    font-size: var(--font-size-sm);
    text-align: right;
    line-height: 1.3;
    cursor: default;
}

.taskbar-clock .time {
    font-weight: 600;
    color: var(--color-text);
}

.taskbar-clock .date {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

/* Taskbar User */
.taskbar-user {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.taskbar-user:hover {
    background: var(--color-glass-hover);
}

/* ===== Context Menu ===== */
#context-menu {
    position: fixed;
    min-width: 200px;
    background: var(--window-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--window-shadow);
    z-index: 99999;
    display: none;
}

#context-menu.visible {
    display: block;
    animation: context-fade-in 0.15s ease;
}

@keyframes context-fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.context-item:hover {
    background: var(--color-glass-hover);
}

.context-item .context-icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.context-separator {
    height: 1px;
    background: var(--color-border);
    margin: 4px 8px;
}

/* ===== App Launcher (Start Menu) ===== */
#app-launcher {
    position: fixed;
    bottom: calc(var(--taskbar-height) + 12px);
    left: 12px;
    width: 360px;
    max-height: 500px;
    background: var(--window-bg);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--window-shadow);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#app-launcher.visible {
    display: flex;
    animation: launcher-fade-in 0.2s ease;
}

@keyframes launcher-fade-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.launcher-search {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.launcher-search input {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-glass);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-family: var(--font-family);
    outline: none;
    transition: border-color var(--transition-fast);
}

.launcher-search input:focus {
    border-color: var(--color-primary);
}

.launcher-search input::placeholder {
    color: var(--color-text-secondary);
}

.launcher-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
    overflow-y: auto;
    max-height: 380px;
}

.launcher-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.launcher-item:hover {
    background: var(--color-glass-hover);
}

.launcher-item:active {
    background: var(--color-glass-active);
}

.launcher-item .icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.launcher-item .icon svg {
    width: 100%;
    height: 100%;
}

.launcher-item .name {
    font-size: var(--font-size-xs);
    text-align: center;
    color: var(--color-text);
    line-height: 1.2;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .desktop-icon .icon {
        width: 40px;
        height: 40px;
    }

    #app-launcher {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
    }

    .launcher-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== Mobile Warning ===== */
#mobile-warning {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: var(--color-bg);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
}

@media (max-width: 600px) {
    #mobile-warning {
        display: flex;
    }
}
