* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #2c3e50;
}

/* Barra Superior */
#top-bar {
    width: 100%;
    height: 40px;
    background-color: #1c2833;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    color: white;
    z-index: 10000;
    position: relative;
}

.menu-container { position: relative; }

#btn-start, #btn-reset {
    padding: 6px 12px;
    background-color: #34495e;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
}

#btn-start:hover, #btn-reset:hover { background-color: #2980b9; }
#btn-reset { background-color: #c0392b; }
#btn-reset:hover { background-color: #e74c3c; }

/* Menú de Inicio */
#start-menu {
    position: absolute;
    top: 35px;
    left: 0;
    background-color: #2c3e50;
    border: 1px solid #34495e;
    border-radius: 4px;
    width: 180px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    padding: 5px 0;
    z-index: 10001;
}

.menu-item {
    background: none;
    border: none;
    color: white;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    width: 100%;
}

.menu-item:hover { background-color: #3498db; }
.hidden { display: none !important; }
.top-controls { display: flex; align-items: center; gap: 15px; }
#bg-picker { border: none; width: 30px; height: 25px; cursor: pointer; background: transparent; }

/* Escritorio */
#desktop {
    width: 100%;
    height: calc(100vh - 80px);
    position: relative;
    padding: 15px;
}

/* Accesos Directos del Escritorio */
.shortcut {
    position: absolute; /* Permite posicionamiento libre */
    width: 80px;
    height: 85px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: move;
    border-radius: 6px;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
    padding: 5px;
    touch-action: none;
}

/* Separación por defecto en rejilla para que no se superpongan inicialmente */
.shortcut[data-app="notepad"] { top: 20px; left: 20px; }
.shortcut[data-app="calc"] { top: 120px; left: 20px; }
.shortcut[data-app="browser"] { top: 220px; left: 20px; }

.shortcut:hover,
.shortcut.selected-icon {
    background-color: rgba(255, 255, 255, 0.15);
    outline: 1px dashed rgba(255, 255, 255, 0.3);
}

.shortcut:active { background-color: rgba(255, 255, 255, 0.25); }

.shortcut.dragging-icon {
    background-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
    z-index: 99;
}

.shortcut-icon { font-size: 32px; margin-bottom: 4px; pointer-events: none; }

.shortcut-text {
    color: white; font-size: 12px; font-weight: 500;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; pointer-events: none;
}

/* Widget del Gráfico Arrastrable en el Fondo */
#desktop-widget {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 230px;
    background-color: rgba(28, 40, 51, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 2; /* Por debajo de las ventanas */
    cursor: move;
    pointer-events: auto;
    user-select: none;
    touch-action: none;
    transition: background-color 0.2s;
}

#desktop-widget.dragging-widget {
    background-color: rgba(28, 40, 51, 0.9);
    border-color: rgba(52, 152, 219, 0.5);
}

.widget-title {
    color: #e5e8e8; font-size: 12px; font-weight: 600; margin-bottom: 8px;
    text-align: center; letter-spacing: 0.5px; pointer-events: none;
}

#widget-chart { display: block; width: 100%; height: auto; pointer-events: none; }

/* Barra de Tareas Inferior */
#taskbar {
    width: 100%;
    height: 40px;
    background-color: #1a252f;
    position: fixed;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    z-index: 9999;
}

#taskbar-items-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
    margin-right: 15px;
}

.taskbar-item {
    display: flex;
    align-items: center;
    background-color: #34495e;
    border-radius: 4px;
    padding: 2px 8px;
    gap: 6px;
    flex: 1;
    min-width: 80px;
    max-width: 160px;
    height: 32px;
    color: white;
}

.taskbar-item.task-active {
    background-color: #3498db;
    border-bottom: 3px solid #fff;
    font-weight: bold;
}

.taskbar-item.task-minimized {
    background-color: rgba(52, 73, 94, 0.4);
    opacity: 0.6;
}

.taskbar-text {
    font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    cursor: pointer; flex: 1; user-select: none;
}

.taskbar-ctrl {
    background-color: rgba(255, 255, 255, 0.15); border: none; color: white;
    width: 18px; height: 18px; border-radius: 3px; cursor: pointer;
    font-size: 10px; display: flex; align-items: center; justify-content: center; font-weight: bold;
}

.taskbar-ctrl:hover { background-color: rgba(255, 255, 255, 0.35); }
.taskbar-ctrl.btn-task-close:hover { background-color: #c0392b; }

#system-clock {
    color: #e5e8e8; font-size: 13px; font-weight: 500; white-space: nowrap;
    cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
#system-clock:hover { background-color: rgba(255, 255, 255, 0.1); }

/* Menú Contextual (Clic derecho) */
#context-menu {
    position: absolute; background-color: #2c3e50; border: 1px solid #34495e;
    border-radius: 5px; width: 190px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex; flex-direction: column; padding: 5px 0; z-index: 20000;
}

#context-menu button {
    background: none; border: none; color: white; padding: 10px 15px;
    text-align: left; cursor: pointer; font-size: 13px; width: 100%;
}
#context-menu button:hover { background-color: #3498db; }

/* Estructura de Ventana */
.window {
    position: absolute; width: 300px; height: 240px; background-color: #f8f9fa;
    border: 1px solid #bdc3c7; box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    display: flex; flex-direction: column; min-width: 220px; min-height: 160px;
    border-radius: 5px 5px 0 0; overflow: hidden; touch-action: none;
}

.window-header {
    background-color: #3498db; color: white; padding: 8px 12px;
    cursor: move; display: flex; justify-content: space-between; align-items: center; user-select: none;
}

.window-controls button { background: none; border: none; color: white; margin-left: 10px; cursor: pointer; font-weight: bold; font-size: 14px; }
.window-content { flex: 1; overflow: hidden; position: relative; display: flex; flex-direction: column; }

/* Aplicaciones */
.app-notepad { width: 100%; height: 100%; border: none; resize: none; padding: 10px; font-family: monospace; font-size: 14px; outline: none; }
.app-calc { display: grid; grid-template-rows: 45px 1fr; height: 100%; padding: 5px; background: #eaeded; }
.calc-screen { width: 100%; height: 35px; text-align: right; padding: 5px; font-size: 18px; margin-bottom: 5px; border: 1px solid #bdc3c7; background: white; }
.calc-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.calc-buttons button { padding: 6px; font-size: 14px; cursor: pointer; background: #f2f3f4; border: 1px solid #ccd1d1; border-radius: 3px; }

/* Navegador */
.app-browser { display: flex; flex-direction: column; height: 100%; background: #f4f6f7; }
.browser-bar { display: flex; padding: 5px; gap: 5px; background: #d5dbdb; border-bottom: 1px solid #bdc3c7; }
.browser-url { flex: 1; padding: 4px 8px; border: 1px solid #bdc3c7; border-radius: 3px; font-size: 13px; outline: none; }
.browser-btn { padding: 4px 10px; background: #3498db; color: white; border: none; border-radius: 3px; cursor: pointer; font-weight: bold; font-size: 12px; }
.browser-frame-container { flex: 1; position: relative; width: 100%; height: 100%; }
.app-browser-iframe { width: 100%; height: 100%; border: none; background: white; }

.window.dragging .app-browser-iframe, .window.resizing .app-browser-iframe { pointer-events: none; }

.window-resizer {
    width: 16px; height: 16px; position: absolute; right: 0; bottom: 0; cursor: se-resize; user-select: none; touch-action: none;
    background: linear-gradient(135deg, transparent 40%, #bdc3c7 40%, #bdc3c7 60%, transparent 60%, transparent 80%, #bdc3c7 80%);
}

.window.minimized { display: none; }
.window.maximized { width: 100% !important; height: calc(100vh - 80px) !important; top: 0 !important; left: 0 !important; }
.window.maximized .window-resizer { display: none; }
/* NUEVO: Botón para Minimizar Todo (Mostrar Escritorio) */
#btn-minimize-all {
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    color: #bdc3c7;
    width: 15px;
    height: 100%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
    margin-left: 5px;
}

#btn-minimize-all:hover {
    background-color: rgba(255, 255, 255, 0.25);
    color: white;
}

/* NUEVO: Estado para aplicaciones fijadas que se encuentran cerradas */
.taskbar-item.task-pinned-closed {
    background-color: rgba(52, 73, 94, 0.4);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    opacity: 0.7;
}
.taskbar-item.task-pinned-closed:hover {
    background-color: rgba(52, 73, 94, 0.8);
    opacity: 1;
}

/* Efecto hover en el botón interno del menú de la barra */
#taskbar-context-menu button:hover {
    background-color: #3498db;
}

/* Estilos para las tarjetas del Historial en el Centro de Actividades */
.history-item {
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #3498db;
    border-radius: 4px;
    padding: 8px 10px;
    color: white;
    position: relative;
    animation: fadeInHistory 0.2s ease-out;
}
.history-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.history-title { font-size: 12px; font-weight: bold; color: #f4f6f7; margin-bottom: 2px; }
.history-desc { font-size: 11px; color: #b2babb; line-height: 1.3; }
.history-time { font-size: 9px; color: #7f8c8d; text-align: right; margin-top: 4px; }
.history-del-btn { position: absolute; top: 6px; right: 8px; background: none; border: none; color: #95a5a6; cursor: pointer; font-size: 10px; }
.history-del-btn:hover { color: #e74c3c; }
.history-empty-text { color: #7f8c8d; font-size: 12px; text-align: center; padding: 20px 0; font-style: italic; }

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